/* =====================================================================
   Panasonic Customer Care Console
   A single stylesheet, no build step, no CDN. Tokens first, then
   components. Light and dark are the same layout with a swapped palette.
   ===================================================================== */

:root {
  /* Brand -- Panasonic blue, warmed slightly so it survives a dark bg */
  --brand:            #0b57d0;
  --brand-strong:     #0842a0;
  --brand-soft:       #e8f0fe;
  --brand-ring:       rgba(11, 87, 208, 0.35);

  --bg:               #f4f6fb;
  --bg-elevated:      #ffffff;
  --bg-sunken:        #eef1f7;
  --sidebar:          #0f1729;
  --sidebar-hover:    rgba(255, 255, 255, 0.07);
  --sidebar-active:   rgba(96, 165, 250, 0.16);
  --sidebar-text:     #9aa8c0;
  --sidebar-text-str: #f1f5fb;

  --text:             #101828;
  --text-muted:       #5a6478;
  --text-faint:       #8b95a8;

  --border:           #dfe4ee;
  --border-strong:    #c6cddc;

  --ok:               #067647;
  --ok-bg:            #e7f6ee;
  --warn:             #b54708;
  --warn-bg:          #fdf3e7;
  --danger:           #b42318;
  --danger-bg:        #fdeceb;
  --info:             #0b57d0;
  --info-bg:          #e8f0fe;
  --neutral:          #56617a;
  --neutral-bg:       #eef0f5;
  --purple:           #6941c6;
  --purple-bg:        #f2edfd;

  --shadow-sm:  0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-md:  0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.05);
  --shadow-lg:  0 12px 16px -4px rgba(16, 24, 40, 0.10), 0 4px 6px -2px rgba(16, 24, 40, 0.05);
  --shadow-xl:  0 24px 48px -12px rgba(16, 24, 40, 0.22);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --sidebar-w: 250px;
  --topbar-h: 62px;

  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI Variable Display", "Segoe UI", ui-sans-serif, system-ui,
          -apple-system, Roboto, "Helvetica Neue", sans-serif;
}

[data-theme="dark"] {
  --brand:            #7aa7ff;
  --brand-strong:     #a8c4ff;
  --brand-soft:       rgba(122, 167, 255, 0.14);
  --brand-ring:       rgba(122, 167, 255, 0.32);

  --bg:               #0a0f1c;
  --bg-elevated:      #121a2b;
  --bg-sunken:        #0d1424;
  --sidebar:          #080d18;
  --sidebar-hover:    rgba(255, 255, 255, 0.06);
  --sidebar-active:   rgba(122, 167, 255, 0.14);
  --sidebar-text:     #8494ae;
  --sidebar-text-str: #eaf0fa;

  --text:             #e7edf7;
  --text-muted:       #97a3b8;
  --text-faint:       #6c788f;

  --border:           #223049;
  --border-strong:    #33445f;

  --ok:               #55d99a;
  --ok-bg:            rgba(85, 217, 154, 0.13);
  --warn:             #f5b451;
  --warn-bg:          rgba(245, 180, 81, 0.13);
  --danger:           #ff8b81;
  --danger-bg:        rgba(255, 139, 129, 0.13);
  --info:             #7aa7ff;
  --info-bg:          rgba(122, 167, 255, 0.13);
  --neutral:          #9aa6bd;
  --neutral-bg:       rgba(154, 166, 189, 0.13);
  --purple:           #c0a6ff;
  --purple-bg:        rgba(192, 166, 255, 0.13);

  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:  0 4px 10px rgba(0, 0, 0, 0.42);
  --shadow-lg:  0 14px 28px rgba(0, 0, 0, 0.48);
  --shadow-xl:  0 30px 60px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Colour transitions only -- animating layout on theme flip looks jittery */
body, .sidebar, .card, .topbar, table, input, select, textarea {
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-faint); background-clip: content-box; }

/* ============================ LAYOUT ============================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* ---------------------------- SIDEBAR --------------------------- */

.sidebar {
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(140deg, #2b7fff, #0b3fa8);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.5px;
  box-shadow: 0 4px 12px rgba(11, 63, 168, 0.45);
  flex-shrink: 0;
}

.brand-text { min-width: 0; }
.brand-title {
  color: var(--sidebar-text-str);
  font-weight: 640;
  font-size: 14.5px;
  letter-spacing: -0.2px;
  white-space: nowrap;
}
.brand-sub {
  color: var(--sidebar-text);
  font-size: 11.5px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  margin-top: 1px;
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
}

.nav-label {
  color: #55637d;
  font-size: 10.5px;
  font-weight: 660;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  padding: 16px 10px 7px;
}
.nav-label:first-child { padding-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--r-md);
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 520;
  user-select: none;
  border: 1px solid transparent;
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-str); }
.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  border-color: rgba(122, 167, 255, 0.2);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: #60a5fa;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .92; }
.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--sidebar-text);
  background: rgba(255, 255, 255, 0.07);
  padding: 1px 7px;
  border-radius: 20px;
}
.nav-item.active .nav-count { background: rgba(255, 255, 255, 0.16); color: #fff; }

.sidebar-foot {
  padding: 13px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11.5px;
  color: #55637d;
}
.sidebar-foot .db-path {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #47536b;
  word-break: break-all;
  margin-top: 4px;
  line-height: 1.4;
}

/* ------------------------------ MAIN ---------------------------- */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
}

.page-title {
  font-size: 16.5px;
  font-weight: 640;
  letter-spacing: -0.3px;
  white-space: nowrap;
}
.page-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -1px;
}

.topbar-spacer { flex: 1; }

.search-box {
  position: relative;
  width: 300px;
  max-width: 34vw;
}
.search-box svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
.search-box input { padding-left: 33px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}

.view { display: none; }
.view.active { display: block; animation: fade .22s ease; }

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------- CONTROLS -------------------------- */

input, select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 8px 11px;
  width: 100%;
  outline: none;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:disabled, select:disabled, textarea:disabled {
  background: var(--bg-sunken);
  color: var(--text-muted);
  cursor: not-allowed;
}
textarea { resize: vertical; min-height: 74px; line-height: 1.55; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b95a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 560;
  padding: 8px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  outline: none;
}
.btn:hover { background: var(--bg-sunken); border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--brand-ring); }
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
[data-theme="dark"] .btn-primary { color: #071426; }

.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text); border-color: transparent; }

.btn-icon { padding: 8px; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ----------------------------- CARDS ---------------------------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-weight: 620; font-size: 14.5px; letter-spacing: -0.2px; }
.card-sub { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 18px; }

/* --------------------------- STAT TILES ------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 17px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  cursor: default;
}
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--brand); box-shadow: var(--shadow-md); }
.stat::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent, var(--brand));
  opacity: .85;
}
.stat-label {
  font-size: 11.5px;
  font-weight: 620;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat-value {
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -1.2px;
  font-variant-numeric: tabular-nums;
  margin-top: 7px;
  line-height: 1.05;
}
.stat-foot { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* ----------------------------- GRID ----------------------------- */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 1180px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ----------------------------- BARS ----------------------------- */

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 128px 1fr 46px; align-items: center; gap: 12px; }
.bar-name {
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 520;
}
.bar-track { height: 9px; background: var(--bg-sunken); border-radius: 20px; overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: 20px;
  background: var(--accent, var(--brand));
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
  min-width: 3px;
}
.bar-val {
  font-size: 12.5px;
  font-weight: 620;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --------------------------- SPARKLINE -------------------------- */

.spark { width: 100%; height: 130px; display: block; overflow: visible; }
.spark-empty {
  display: grid;
  place-items: center;
  height: 130px;
  color: var(--text-faint);
  font-size: 13px;
}

/* ---------------------------- TABLES ---------------------------- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 660;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
thead th .sort-arrow { opacity: .45; margin-left: 4px; font-size: 9px; }
thead th.sorted { color: var(--brand); }
thead th.sorted .sort-arrow { opacity: 1; }

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--bg-sunken); }

td.mono, .mono { font-family: var(--mono); font-size: 12.2px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
td.actions { width: 1%; white-space: nowrap; }

/* The actions column carries the primary row interactions, so it has to
   stay reachable when a wide record table scrolls sideways. Pin it to the
   right edge; the header cell is sticky on both axes. */
#res-table thead th:last-child,
#res-table tbody td.actions {
  position: sticky;
  right: 0;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
}
#res-table thead th:last-child { background: var(--bg-sunken); z-index: 3; }
#res-table tbody td.actions { z-index: 2; }
#res-table tbody tr:hover td.actions { background: var(--bg-sunken); }

.empty {
  padding: 52px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-icon { font-size: 30px; opacity: .35; margin-bottom: 10px; }
.empty-title { font-weight: 600; font-size: 14.5px; color: var(--text); margin-bottom: 4px; }

/* ---------------------------- BADGES ---------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 620;
  padding: 2.5px 9px;
  border-radius: 20px;
  letter-spacing: 0.2px;
  white-space: nowrap;
  background: var(--neutral-bg);
  color: var(--neutral);
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge.plain::before { display: none; }

.badge-ok      { background: var(--ok-bg);      color: var(--ok); }
.badge-warn    { background: var(--warn-bg);    color: var(--warn); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-purple  { background: var(--purple-bg);  color: var(--purple); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); }

/* ---------------------------- TOOLBAR --------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}
.toolbar .grow { flex: 1; min-width: 130px; }
.toolbar select, .toolbar input { width: auto; min-width: 148px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 11px;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 560;
}
.chip button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 50%;
  opacity: .7;
}
.chip button:hover { opacity: 1; background: rgba(0, 0, 0, .08); }

/* -------------------------- PAGINATION -------------------------- */

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}
.pager .spacer { flex: 1; }
.pager-btns { display: flex; gap: 5px; }

/* ---------------------------- MODAL ----------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 14, 26, 0.55);
  backdrop-filter: blur(3px);
  display: none;
  z-index: 90;
}
.overlay.open { display: block; animation: fade .16s ease; }

.modal {
  position: fixed;
  z-index: 100;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.modal.open { display: flex; animation: pop .2s cubic-bezier(.2, .9, .3, 1.1); }
.modal.wide { width: min(1000px, calc(100vw - 40px)); }

@keyframes pop {
  from { opacity: 0; transform: translate(-50%, -46%) scale(.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 640; letter-spacing: -0.3px; }
.modal-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  flex-shrink: 0;
}
.modal-foot .left { margin-right: auto; }

/* ----------------------------- FORMS ---------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 580;
  margin-bottom: 5px;
  color: var(--text);
}
.field .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; line-height: 1.4; }

.switch { display: flex; align-items: center; gap: 10px; padding-top: 4px; }
.switch input { width: auto; }
.switch-track {
  width: 38px;
  height: 21px;
  border-radius: 20px;
  background: var(--border-strong);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .18s;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .18s cubic-bezier(.4, 0, .2, 1);
}
.switch-track.on { background: var(--brand); }
.switch-track.on::after { transform: translateX(17px); }

.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid currentColor;
  border-radius: var(--r-md);
  padding: 10px 13px;
  font-size: 13px;
  margin-bottom: 15px;
  display: none;
}
.form-error.show { display: block; }

/* ---------------------------- DETAIL ---------------------------- */

.detail-section + .detail-section { margin-top: 22px; }
.detail-section h4 {
  margin: 0 0 11px;
  font-size: 11.5px;
  font-weight: 660;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-section h4::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 13px 20px;
}
.kv-item { min-width: 0; }
.kv-key {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.kv-val {
  font-size: 13.5px;
  margin-top: 2px;
  word-break: break-word;
}
.kv-val.empty-val { color: var(--text-faint); font-style: italic; }

.mini-table { font-size: 12.5px; }
.mini-table thead th { padding: 8px 11px; position: static; }
.mini-table tbody td { padding: 8px 11px; }
.mini-table tbody tr { cursor: default; }

/* --------------------------- TIMELINE --------------------------- */

.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}
.tl-item { position: relative; padding-bottom: 17px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -26px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2.5px solid var(--brand);
  box-shadow: 0 0 0 3px var(--bg-elevated);
}
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }
.tl-remark { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

/* ------------------------- SQL CONSOLE -------------------------- */

.sql-editor {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  min-height: 132px;
  background: var(--bg-sunken);
  tab-size: 2;
}

.sql-samples { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 11px; }
.sql-sample {
  font-size: 11.5px;
  font-family: var(--mono);
  padding: 4px 9px;
  border-radius: var(--r-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
}
.sql-sample:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.result-meta {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}

/* --------------------------- SCHEMA ----------------------------- */

.schema-layout { display: grid; grid-template-columns: 290px 1fr; gap: 16px; align-items: start; }
@media (max-width: 980px) { .schema-layout { grid-template-columns: 1fr; } }

.table-list { max-height: calc(100vh - 210px); overflow-y: auto; }
.table-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 13px;
  cursor: pointer;
  border-left: 2.5px solid transparent;
  font-size: 13px;
}
.table-item:hover { background: var(--bg-sunken); }
.table-item.active {
  background: var(--brand-soft);
  border-left-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}
.table-item .t-name { flex: 1; font-family: var(--mono); font-size: 12.2px; overflow: hidden; text-overflow: ellipsis; }
.table-item .t-count {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

pre.ddl {
  font-family: var(--mono);
  font-size: 12.2px;
  line-height: 1.6;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 15px;
  overflow-x: auto;
  margin: 0;
  white-space: pre;
  color: var(--text-muted);
}

/* ---------------------------- TOASTS ---------------------------- */

.toasts {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-width: 290px;
  max-width: 400px;
  padding: 12px 15px;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: slide-in .24s cubic-bezier(.2, .9, .3, 1.1);
  pointer-events: auto;
}
.toast.ok    { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.leaving { animation: slide-out .18s ease forwards; }
.toast-icon { font-size: 15px; line-height: 1.35; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 620; }
.toast-msg { color: var(--text-muted); font-size: 12.5px; margin-top: 1px; word-break: break-word; }

@keyframes slide-in  { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
@keyframes slide-out { to { opacity: 0; transform: translateX(26px); } }

/* --------------------------- MISC ------------------------------- */

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-bg);
  flex-shrink: 0;
}
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }

.health {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 20px;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row { padding: 44px; text-align: center; color: var(--text-muted); }

.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border) 50%, var(--bg-sunken) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--r-sm);
  height: 13px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 9px; }
.mt-16 { margin-top: 16px; }

kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1.5px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--bg-sunken);
  color: var(--text-muted);
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .search-box { width: 180px; }
}
