@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:           #F1F4F9;
  --surface:      #FFFFFF;
  --surface-2:    #F8FAFC;
  --border:       #E2E8F0;
  --border-strong:#CBD5E1;
  --navy:         #0B1629;
  --navy-mid:     #1E2D45;
  --blue:         #2563EB;
  --blue-light:   #EFF6FF;
  --blue-mid:     #BFDBFE;
  --green:        #059669;
  --green-light:  #ECFDF5;
  --green-mid:    #A7F3D0;
  --red:          #DC2626;
  --red-light:    #FEF2F2;
  --red-mid:      #FECACA;
  --amber:        #D97706;
  --amber-light:  #FFFBEB;
  --amber-mid:    #FDE68A;
  --text-1:       #0F172A;
  --text-2:       #475569;
  --text-3:       #94A3B8;
  --mono:         'JetBrains Mono', ui-monospace, monospace;
  --sans:         'Plus Jakarta Sans', system-ui, sans-serif;
  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:    0 16px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--text-1); font-size: 14px; line-height: 1.6; min-height: 100vh; }

/* ── NAV ── */
.topnav { position: sticky; top: 0; z-index: 100; background: var(--navy); border-bottom: 1px solid rgba(255,255,255,.06); }
.topnav-inner { max-width: 1160px; margin: 0 auto; padding: 0 28px; height: 58px; display: flex; align-items: center; gap: 20px; }
.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-logo-mark { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; flex: 0 0 36px; }
.nav-logo-mark img { display: block; width: 34px; height: 34px; object-fit: contain; }
.nav-brand { font-size: 15px; font-weight: 700; color: white; }
.nav-brand span { color: #60A5FA; }
.nav-sep { width: 1px; height: 20px; background: rgba(255,255,255,.12); }
.nav-breadcrumb { font-size: 13px; color: #94A3B8; font-weight: 500; }
.nav-spacer { flex: 1; }
.nav-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #34D399; box-shadow: 0 0 0 2px rgba(52,211,153,.25); animation: pulse-dot 2.5s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.nav-status-label { font-size: 12px; color: #94A3B8; font-weight: 500; display: flex; align-items: center; gap: 6px; }

/* ── LAYOUT ── */
.wrap { max-width: 1160px; margin: 0 auto; padding: 32px 28px 64px; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 800; letter-spacing: -.03em; color: var(--text-1); margin-bottom: 4px; }
.page-header p { font-size: 13.5px; color: var(--text-2); }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── FLASH ── */
.flash { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; border-radius: var(--radius); margin-bottom: 20px; border: 1px solid transparent; animation: flash-in .25s ease; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.flash svg { flex-shrink: 0; margin-top: 1px; }
.flash pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; }
.flash.ok  { background: var(--green-light); border-color: var(--green-mid); color: #064E3B; }
.flash.ok  svg { stroke: var(--green); }
.flash.err { background: var(--red-light);   border-color: var(--red-mid);   color: #7F1D1D; }
.flash.err svg { stroke: var(--red); }
.notice-info { display: flex; gap: 10px; padding: 14px 16px; border-radius: var(--radius); background: var(--blue-light); border: 1px solid var(--blue-mid); color: #1E3A8A; font-size: 13px; line-height: 1.6; }
.notice-info svg { flex-shrink: 0; margin-top: 1px; stroke: var(--blue); fill: none; }

/* ── SECTION CARDS ── */
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 16px; box-shadow: var(--shadow-sm); overflow: hidden; transition: box-shadow .15s, border-color .15s; }
.section:hover { border-color: var(--border-strong); }
.section:not(.collapsed) { box-shadow: 0 4px 14px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.04); }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px; border-bottom: 1px solid transparent; cursor: pointer; user-select: none; transition: background .15s, border-color .15s; }
.section:not(.collapsed) .section-header { border-bottom-color: var(--border); }
.section-header:hover { background: var(--surface-2); }
.section-header-left { display: flex; align-items: center; gap: 14px; }
.section-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.section-icon.blue  { background: var(--blue-light); }  .section-icon.blue  svg { stroke: var(--blue); }
.section-icon.green { background: var(--green-light); } .section-icon.green svg { stroke: var(--green); }
.section-icon.amber { background: var(--amber-light); } .section-icon.amber svg { stroke: var(--amber); }
.section-icon.navy  { background: #EEF2FF; }             .section-icon.navy  svg { stroke: #4F46E5; }
.section-icon svg { width: 18px; height: 18px; fill: none; stroke-width: 1.8; }
.section-title { font-size: 15px; font-weight: 700; color: var(--text-1); }
.section-subtitle { font-size: 12.5px; color: var(--text-2); margin-top: 2px; line-height: 1.5; }
.section-chevron { transition: transform .25s ease; color: var(--text-3); flex-shrink: 0; }
.section-chevron svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.section.collapsed .section-chevron { transform: rotate(-90deg); }
.section-body { padding: 24px; }
.section.collapsed .section-body { display: none; }

/* ── FORMS ── */
.field-group { margin-bottom: 18px; }
.field-group:last-child { margin-bottom: 0; }
.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 7px;
}

.field-label svg {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  flex: 0 0 16px;
  display: block;
  stroke: currentColor;
  fill: none;
  overflow: hidden;
}
.field-row { display: flex; gap: 10px; align-items: stretch; }
.field-row input, .field-row select { flex: 1; }
input, select, textarea { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: var(--sans); font-size: 14px; color: var(--text-1); background: var(--surface); transition: border-color .15s, box-shadow .15s; appearance: none; }
input[type="checkbox"] { appearance: auto; -webkit-appearance: checkbox; width: 16px; height: 16px; min-width: 16px; padding: 0; margin: 0; border-radius: 4px; accent-color: var(--blue); vertical-align: middle; cursor: pointer; }
.sync-check input[type="checkbox"], .discTableWrap input[type="checkbox"] { display: inline-block; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
.mono-input { font-family: var(--mono) !important; font-size: 13px !important; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2394A3B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.field-hint { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }
.field-hint code { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 12px; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1.5px solid transparent; border-radius: var(--radius-sm); padding: 9px 16px; font-family: var(--sans); font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; flex-shrink: 0; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy);       color: white;          border-color: var(--navy); }       .btn-primary:hover { background: var(--navy-mid); }
.btn-blue    { background: var(--blue);       color: white;          border-color: var(--blue); }       .btn-blue:hover    { background: #1D4ED8; }
.btn-ghost   { background: transparent;       color: var(--text-2);  border-color: var(--border); }     .btn-ghost:hover   { background: var(--surface-2); color: var(--text-1); }
.btn-danger  { background: var(--red-light);  color: var(--red);     border-color: var(--red-mid); }    .btn-danger:hover  { background: var(--red); color: white; }
.btn-success { background: var(--green-light);color: var(--green);   border-color: var(--green-mid); }  .btn-success:hover { background: var(--green); color: white; }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 6px; }
.btn-sm svg { width: 13px; height: 13px; }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-blue  { background: var(--blue-light);  color: var(--blue);  border: 1px solid var(--blue-mid); }
.badge-green { background: var(--green-light); color: var(--green); border: 1px solid var(--green-mid); }
.badge-amber { background: var(--amber-light); color: var(--amber); border: 1px solid var(--amber-mid); }
.badge-slate { background: #F1F5F9;            color: var(--text-2);border: 1px solid var(--border); }

/* ── DATA TABLE ── */
.data-table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th { background: var(--surface-2); padding: 10px 14px; text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: #F8FAFC; }
.data-table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .mono-cell { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }

/* ── EMPTY STATE ── */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 24px; gap: 10px; }
.empty-state svg { width: 40px; height: 40px; stroke: var(--text-3); fill: none; stroke-width: 1.5; }
.empty-state h3 { font-size: 15px; font-weight: 700; color: var(--text-2); }
.empty-state p { font-size: 13px; color: var(--text-3); max-width: 340px; line-height: 1.6; }

/* ── MISC ── */
.kbd { font-family: var(--mono); background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 2px 6px; font-size: 11px; color: var(--text-1); }
.info-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-strong); font-size: 10px; font-weight: 700; color: var(--text-2); cursor: pointer; background: var(--surface-2); transition: all .15s; }
.info-icon:hover { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }

/* ── WIREGUARD STATUS ── */
.wg-status-panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; }
.wg-status-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.wg-status-row:last-child { border-bottom: none; padding-bottom: 0; }
.wg-status-row:first-child { padding-top: 0; }
.wg-lbl { font-weight: 600; color: var(--text-2); min-width: 220px; flex-shrink: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
.wg-val { font-family: var(--mono); font-size: 12.5px; color: var(--text-1); word-break: break-all; flex: 1; }
.wg-empty { color: var(--text-3); font-style: italic; }
details summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--blue); list-style: none; display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; }
details summary::before { content: "B6"; font-size: 10px; }
details[open] summary::before { content: "BC"; }
details pre { margin-top: 10px; font-family: var(--mono); font-size: 12px; background: var(--navy); color: #A8D5C2; padding: 14px 16px; border-radius: var(--radius-sm); white-space: pre-wrap; word-break: break-word; line-height: 1.7; }
.cmd-list { margin-top: 12px; background: var(--navy); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.cmd-list code { font-family: var(--mono); font-size: 12.5px; color: #A8D5C2; }

/* ── TABLES TOOLBAR ── */
.tables-toolbar { position: sticky; top: 58px; z-index: 50; background: rgba(241,244,249,.9); backdrop-filter: saturate(160%) blur(10px); border: 1px solid rgba(226,232,240,.8); border-radius: var(--radius); padding: 12px 16px; display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.tables-toolbar .left  { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tables-toolbar .right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.count-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; }
.count-badge strong { color: var(--blue); font-size: 14px; }

/* ── ROW CARDS ── */
.rowCard { border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; transition: border-color .15s, box-shadow .15s; animation: row-in .2s ease; }
@keyframes row-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.rowCard:hover { border-color: var(--blue-mid); box-shadow: 0 0 0 3px rgba(37,99,235,.05); }
.rowCard-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: linear-gradient(to right, var(--surface-2), var(--surface)); border-bottom: 1px solid var(--border); }
.rowCard-title { font-weight: 700; font-size: 14px; color: var(--text-1); }
.rowCard-meta  { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.rowCard-body  { padding: 14px 16px; }
.rowGrid { display: grid; grid-template-columns: 1.4fr .65fr 1fr 1fr .65fr .7fr; gap: 10px; align-items: end; }
.rowGrid .field-group { margin-bottom: 0; }
.help-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tip-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px; }

/* ── API CONNECTOR TEMPLATES ── */
.api-template-panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 12px; margin-bottom: 12px; }
.api-template-top { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(280px, 1.4fr); gap: 12px; align-items: end; }
.api-template-summary { display: flex; gap: 10px; align-items: center; min-width: 0; }
.connector-icon { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; color: var(--blue); font-weight: 800; font-size: 12px; letter-spacing: .02em; }
.connector-icon img { width: 24px; height: 24px; object-fit: contain; display: block; }
.api-template-name { font-weight: 800; font-size: 13.5px; color: var(--text-1); overflow-wrap: anywhere; }
.api-template-help { font-size: 12px; color: var(--text-2); line-height: 1.5; margin-top: 2px; }
.api-template-objects { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.api-object-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 11.5px; font-weight: 600; }
.api-template-note { font-size: 12px; color: var(--text-3); margin-top: 8px; line-height: 1.5; }
@media (max-width: 780px) { .api-template-top { grid-template-columns: 1fr; } }

/* ── COMPACT TABLES / VIEWS MANAGER ── */
.sync-manager { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text-1); overflow: hidden; box-shadow: var(--shadow-sm); }
.sync-manager input, .sync-manager select { background: var(--surface); border-color: var(--border-strong); color: var(--text-1); }
.sync-manager input::placeholder { color: var(--text-3); }
.sync-manager .field-label { color: var(--text-2); }

/* Section header right-side pill — only shows the pill when section is collapsed */
.section-header-right { display: flex; align-items: center; gap: 12px; }
.section:not(.collapsed) .section-header-right .collapsed-only { display: none; }

/* Status strip: one line, low visual weight, sits above the toolbar */
.sync-statusbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); font-size: 13px; color: var(--text-2);
}
.sync-statusbar .sync-next { color: var(--text-3); font-size: 12.5px; }
.sync-statusbar .sync-duration { color: var(--text-2); font-size: 12.5px; font-weight: 700; padding-left: 12px; border-left: 1px solid var(--border); }
.sync-statusbar .count-pill { margin-left: auto; }

/* Toolbar: tiered into a primary action row and a filter row */
.sync-toolbar {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.sync-toolbar-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sync-toolbar-primary .btn { min-height: 38px; }
.sync-toolbar-spacer { flex: 1 1 auto; }
.sync-inline-form { margin: 0; display: flex; align-items: center; gap: 8px; }

/* Filter row: search takes most space, selects compact */
.sync-search { flex: 2 1 280px; min-width: 240px; min-height: 38px; }
.sync-toolbar-filters select { flex: 0 1 180px; min-width: 150px; min-height: 38px; }

/* Pills */
.sync-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #047857; background: var(--green-light); border: 1px solid var(--green-mid); white-space: nowrap; }
.sync-pill.is-warn { color: #92400e; background: var(--amber-light); border-color: var(--amber-mid); }
.sync-pill.is-error { color: #b91c1c; background: var(--red-light); border-color: var(--red-mid); }
.count-pill { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.count-pill strong { color: var(--blue); font-size: 14px; line-height: 1; }

/* Inline add panel — wider headline fields, compact secondary fields */
.sync-add-panel { display: none; padding: 16px 24px 18px; background: var(--blue-light); border-bottom: 1px solid var(--blue-mid); }
.sync-add-panel.open { display: block; }
.sync-add-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px;
  align-items: end;
}
.sync-add-grid > div { min-width: 0; }
.sync-add-grid input, .sync-add-grid select { min-width: 0; width: 100%; }
.sync-add-actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; min-width: 0; }
.sync-add-actions .btn { white-space: nowrap; }
@media (max-width: 1180px) { .sync-add-actions { grid-column: 1 / -1; } }

/* Bulk-actions bar */
.sync-bulkbar { display: none; align-items: center; gap: 10px; padding: 11px 24px; background: var(--green-light); border-bottom: 1px solid var(--green-mid); color: #065f46; font-size: 13px; font-weight: 600; }
.sync-bulkbar.open { display: flex; }
.sync-bulkbar .btn { min-height: 32px; }

/* Data table */
.sync-table-wrap { overflow-x: hidden; overflow-y: visible; background: var(--surface); }
.sync-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 0; table-layout: fixed; }
.sync-table thead, .sync-table tbody { width: 100%; }
.sync-table tbody { display: table-row-group; }
.sync-table tr { display: table-row; }
.sync-table th, .sync-table td { min-width: 0; overflow-wrap: anywhere; word-break: normal; }
.sync-table thead th {
  position: sticky; top: 0; z-index: 5;
  padding: 11px 12px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  text-align: left; border-bottom: 1px solid var(--border);
}
.sync-table tbody td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-1); }
.sync-table tbody tr:last-child td { border-bottom: none; }
.sync-row { cursor: pointer; transition: background .12s; }
.sync-row:hover { background: var(--surface-2); }
.sync-row.is-expanded { background: var(--blue-light); }
.sync-row.is-expanded td { border-bottom-color: var(--blue-mid); }
.sync-row.is-new { background: var(--green-light); }

.sync-conn-header td { padding: 0 !important; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.sync-conn-toggle { width: 100%; border: 0; background: transparent; color: var(--text-1); cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; font: inherit; text-align: left; }
.sync-conn-title { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.sync-conn-meta { color: var(--text-2); font-size: 12px; font-weight: 600; }
.sync-conn-chevron { transition: transform .15s ease; }
.sync-conn-header.is-collapsed .sync-conn-chevron { transform: rotate(-90deg); }
.sync-order-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 22px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 11px; font-weight: 800; margin-right: 6px; }
.sync-order-actions { display: inline-flex; gap: 4px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.sync-order-actions .btn { padding-left: 8px; padding-right: 8px; }

/* Cell helpers */
.sync-check { width: 42px; text-align: center; }
.sync-name { font-weight: 700; color: var(--text-1); font-family: var(--mono); overflow-wrap: anywhere; }
.sync-muted { color: var(--text-2); }
.sync-right { text-align: right; }
.sync-actions { text-align: right; white-space: nowrap; }
.sync-table th.sync-object-col, .sync-table td.sync-object-col { width: 34%; }
.sync-table th.sync-connection-col, .sync-table td.sync-connection-col { width: 16%; }
.sync-table th.sync-mode-col, .sync-table td.sync-mode-col { width: 11%; }
.sync-table th.sync-rows-col, .sync-table td.sync-rows-col { width: 9%; }
.sync-table th.sync-last-col, .sync-table td.sync-last-col { width: 13%; }
.sync-table th.sync-status-col, .sync-table td.sync-status-col { width: 11%; }
.sync-table th.sync-actions-col, .sync-table td.sync-actions-col { width: 10%; }

/* Inline-edit row */
.sync-edit-row { display: none; background: var(--surface-2); }
.sync-edit-row.open { display: table-row; }
.sync-edit-panel { padding: 16px 18px 18px; border-top: 1px solid var(--blue-mid); border-bottom: 1px solid var(--border); }
.sync-edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.sync-edit-grid > div { min-width: 0; }
.sync-edit-grid input, .sync-edit-grid select { min-width: 0; width: 100%; }
.sync-edit-grid .field-label { white-space: nowrap; letter-spacing: .045em; }
.sync-edit-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; color: var(--text-2); font-size: 12px; }
.sync-edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* Footnote under the table */
.sync-footnote { padding: 12px 24px 14px; color: var(--text-2); font-size: 12px; background: var(--surface); }

/* Status badges (keep existing tones) */
.status-badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.status-ok      { color: #047857; background: var(--green-light); border-color: var(--green-mid); }
.status-syncing { color: #92400e; background: var(--amber-light); border-color: var(--amber-mid); }
.status-paused  { color: var(--text-2); background: #F1F5F9;       border-color: var(--border-strong); }
.status-errored { color: #b91c1c; background: var(--red-light);   border-color: var(--red-mid); }
.status-pending { color: #1d4ed8; background: var(--blue-light);  border-color: var(--blue-mid); }

/* Type badges */
.type-badge { display: inline-flex; border-radius: 6px; padding: 2px 7px; font-size: 10.5px; font-weight: 700; color: #1d4ed8; background: var(--blue-light); border: 1px solid var(--blue-mid); }
.type-view { color: #92400e; background: var(--amber-light); border-color: var(--amber-mid); }
.type-file { color: #6d28d9; background: #F5F3FF;            border-color: #DDD6FE; }
.type-api  { color: #0f766e; background: #CCFBF1;            border-color: #99F6E4; }

/* Mobile / narrow layout */
@media (max-width: 980px) {
  .sync-add-grid, .sync-edit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sync-table { table-layout: auto; }
  .sync-table th.sync-rows-col, .sync-table td.sync-rows-col, .sync-table th.sync-last-col, .sync-table td.sync-last-col { display: none; }
  .sync-statusbar .sync-duration { padding-left: 0; border-left: 0; }
  .sync-statusbar .count-pill { margin-left: 0; }
  .sync-toolbar-spacer { display: none; }
  .sync-search { flex-basis: 100%; }
}
@media (max-width: 640px) {
  .sync-add-grid, .sync-edit-grid { grid-template-columns: 1fr; }
  .sync-statusbar { padding: 12px 16px; }
  .sync-toolbar { padding: 12px 16px; }
  .sync-footnote { padding: 12px 16px; }
}

/* ── DISCOVER MODAL ── */
#discoverModal { display: none; position: fixed; inset: 0; background: rgba(11,22,41,.55); backdrop-filter: blur(4px); z-index: 200; padding: 32px 20px; overflow-y: auto; }
.modal-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); max-width: 1020px; margin: 0 auto; box-shadow: var(--shadow-lg); overflow: hidden; animation: panel-in .25s cubic-bezier(.16,1,.3,1); }
@keyframes panel-in { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px 18px; border-bottom: 1px solid var(--border); background: linear-gradient(to right, var(--surface-2), var(--surface)); }
.modal-title { font-size: 16px; font-weight: 700; color: var(--text-1); display: flex; align-items: center; gap: 10px; }
.modal-title svg { width: 20px; height: 20px; fill: none; stroke: var(--blue); stroke-width: 1.8; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.disc-filter-grid { display: grid; grid-template-columns: 2fr 1fr 1.5fr auto; gap: 10px; align-items: end; margin-bottom: 16px; }
.discTableWrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; max-height: 55vh; overflow-y: auto; }
.discTableWrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.discTableWrap thead th { position: sticky; top: 0; background: var(--surface-2); padding: 10px 14px; text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); z-index: 2; }
.discTableWrap thead th.r { text-align: right; }
.discTableWrap tbody tr:hover { background: var(--surface-2); }
.discTableWrap tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.discTableWrap tbody tr:last-child td { border-bottom: none; }
.discTableWrap .mono-cell { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
.discTableWrap .r { text-align: right; }
.disc-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 10px 0 4px; }
.disc-status.error { color: var(--red); }
.disc-status svg { flex-shrink: 0; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.disc-spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.searchSummary { font-size: 12.5px; color: var(--text-2); padding-top: 4px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) { .rowGrid { grid-template-columns: 1fr 1fr; } .disc-filter-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .wrap { padding: 20px 16px 48px; } .topnav-inner { padding: 0 16px; } .rowGrid { grid-template-columns: 1fr; } }

/* ── WIREGUARD SECTION TIGHTENING ── */
#sec-wg .section-body {
  padding-bottom: 16px;
}

#sec-wg form {
  margin: 0;
}

#sec-wg .field-group {
  margin-bottom: 12px;
}

#sec-wg .divider {
  margin: 16px 0;
}

#sec-wg .notice-info {
  margin-bottom: 12px;
}

#sec-wg .cmd-list {
  margin-top: 8px;
  margin-bottom: 0;
}

#sec-wg .field-label[style*="margin-top:16px"] {
  margin-top: 10px !important;
  margin-bottom: 6px !important;
}

/* Safety override: the configured tables list is a real table body, not the older card-list container. */
.sync-table tbody#rows { display: table-row-group !important; gap: 0 !important; }
.sync-table tbody#rows tr { display: table-row !important; }
.sync-table tbody#rows td { display: table-cell; }

/* Final tidy hardening for the tables/views manager.
   Keeps the table clipped to the rounded card, avoids hover square-edge flicker,
   and prevents the inline edit form from forcing a horizontal scrollbar. */
#sec-tables.section,
#sec-tables .sync-manager {
  overflow: hidden;
  border-radius: var(--radius-lg);
  backface-visibility: hidden;
  transform: translateZ(0);
}
#sec-tables .section-body {
  overflow: hidden;
}
#sec-tables .sync-table-wrap {
  overflow-x: hidden;
}
#sec-tables .sync-table colgroup col:nth-child(1) { width: 4%; }
#sec-tables .sync-table colgroup col:nth-child(2) { width: 32%; }
#sec-tables .sync-table colgroup col:nth-child(3) { width: 15%; }
#sec-tables .sync-table colgroup col:nth-child(4) { width: 9%; }
#sec-tables .sync-table colgroup col:nth-child(5) { width: 8%; }
#sec-tables .sync-table colgroup col:nth-child(6) { width: 12%; }
#sec-tables .sync-table colgroup col:nth-child(7) { width: 10%; }
#sec-tables .sync-table colgroup col:nth-child(8) { width: 10%; }
#sec-tables .sync-edit-row > td {
  padding: 0;
}
#sec-tables .sync-edit-panel {
  max-width: 100%;
}
#sec-tables .sync-edit-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
#sec-tables .sync-edit-grid input,
#sec-tables .sync-edit-grid select {
  min-width: 0;
}
@media (max-width: 980px) {
  #sec-tables .sync-edit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  #sec-tables .sync-edit-grid { grid-template-columns: 1fr; }
}