/* ============================================================
   Dashboard Shell — Design System v2
   ============================================================ */

/* ── Design Tokens ── */
:root {
  --sidebar-w: 240px;
  --topbar-h: 60px;

  /* Colors */
  --bg:          #f4f6fb;
  --surface:     #ffffff;
  --border:      #e5e9f2;
  --border-mid:  #d0d7e8;

  --text:        #172033;
  --text-sub:    #475569;
  --muted:       #8895a7;

  --primary:     #1e3a8a;
  --primary-h:   #163175;
  --primary-mid: #3b5db8;
  --primary-bg:  #eef2ff;
  --primary-bg-h:#e0e7ff;

  --success:     #16a34a;
  --success-bg:  #dcfce7;
  --success-text:#14532d;

  --warn:        #d97706;
  --warn-bg:     #fef3c7;
  --warn-text:   #78350f;

  --danger:      #dc2626;
  --danger-bg:   #fee2e2;
  --danger-text: #7f1d1d;

  --info:        #2563eb;
  --info-bg:     #dbeafe;
  --info-text:   #1e3a8a;

  /* Shadows */
  --shadow-card: 0 2px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg:   0 8px 32px rgba(15, 23, 42, 0.10);

  /* Shape */
  --radius-card: 14px;
  --radius-btn:  8px;
  --radius-input:8px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  margin: 0;
  padding: 0;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ── */
.app-shell {
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 400;
  overflow-y: auto;
  overflow-x: hidden;
}

/* brand */
.sidebar-head {
  padding: 20px 16px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand-icon {
  width: 34px;
  height: 34px;
  background: var(--primary);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-brand-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}

/* nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 8px 4px;
  margin-top: 6px;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text-sub);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 120ms, color 120ms;
}

.sidebar-link:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.sidebar-link.is-active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 700;
}

.sidebar-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}

.sidebar-link-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
  opacity: 0.75;
}

.sidebar-link.is-active .sidebar-link-icon,
.sidebar-link:hover .sidebar-link-icon {
  opacity: 1;
}

/* sub-link */
.sidebar-link-sub {
  padding-left: 34px;
  font-size: 13px;
  font-weight: 500;
}

/* group (details/summary) */
.sidebar-group {
  margin-top: 2px;
}

.sidebar-group > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text-sub);
  font-size: 13.5px;
  font-weight: 600;
  user-select: none;
  transition: background 120ms;
}

.sidebar-group > summary::-webkit-details-marker { display: none; }

.sidebar-group > summary:hover,
.sidebar-group[open] > summary {
  background: var(--primary-bg);
  color: var(--primary);
}

.sidebar-group-arrow {
  margin-left: auto;
  font-size: 10px;
  transition: transform 160ms;
  opacity: 0.6;
}

.sidebar-group[open] .sidebar-group-arrow {
  transform: rotate(180deg);
}

.sidebar-group-body {
  padding: 2px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* footer */
.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.sidebar-user-name {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text);
}

.sidebar-logout {
  display: inline-block;
  margin-top: 3px;
  color: var(--danger);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}
.sidebar-logout:hover { color: #991b1b; }

.sidebar-close { display: none !important; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  z-index: 350;
}

/* ── App Main ── */
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-screen-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.topbar-breadcrumb {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Topbar stats strip ── */
.topbar-stats {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  justify-content: center;
  flex-wrap: nowrap;
  overflow: hidden;
}

.topbar-stat-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-sub);
  font-size: 12.5px;
  white-space: nowrap;
  transition: background 100ms;
}
.topbar-stat-item:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.topbar-stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-warn    { background: var(--warn); }
.dot-info    { background: var(--info); }
.dot-ok      { background: var(--success); }
.dot-primary { background: var(--primary); }

.topbar-stat-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.topbar-stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.topbar-stat-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  flex-shrink: 0;
}

/* sidebar primary link (QR 등록 강조) */
.sidebar-link-primary {
  background: var(--primary-bg);
  color: var(--primary) !important;
  font-weight: 700;
}
.sidebar-link-primary:hover {
  background: var(--primary-bg-h);
}
.sidebar-link-primary.is-active {
  background: var(--primary);
  color: #fff !important;
}
.sidebar-link-primary.is-active::before {
  background: #fff;
}

@media (max-width: 900px) {
  .topbar-stats { display: none; }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  gap: 6px;
}

.topbar-quick {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-mid);
  background: var(--surface);
  color: var(--text-sub);
  transition: background 100ms, color 100ms, border-color 100ms;
}

.topbar-quick:hover {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: #c7d2fe;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-sub);
  transition: background 100ms;
}
.icon-btn:hover { background: var(--primary-bg); color: var(--primary); }

/* topbar user dropdown */
.topbar-menu { position: relative; }
.topbar-menu > summary { list-style: none; cursor: pointer; user-select: none; }
.topbar-menu > summary::-webkit-details-marker { display: none; }

.topbar-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-mid);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-sub);
  transition: background 100ms;
}
.topbar-menu[open] .topbar-menu-toggle,
.topbar-menu-toggle:hover {
  background: var(--primary-bg);
  border-color: #c7d2fe;
  color: var(--primary);
}

.topbar-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
}
.topbar-menu-panel a {
  display: block;
  padding: 8px 14px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
}
.topbar-menu-panel a:hover { background: var(--primary-bg); color: var(--primary); }
.topbar-menu-divider { height: 1px; background: var(--border); margin: 3px 0; }
.topbar-menu-panel .danger { color: var(--danger); }
.topbar-menu-muted {
  display: block;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--muted);
}

/* ── Content Shell ── */
.content {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

body.page-wide .content { max-width: 1560px; }
body.page-help .content { max-width: 1200px; }

.footer {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 28px 20px;
  font-size: 12px;
  color: var(--muted);
}
body.page-wide .footer { max-width: 1560px; }
body.page-help .footer { max-width: 1200px; }

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-breadcrumb {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 4px;
}
.page-breadcrumb a { color: var(--muted); text-decoration: none; }
.page-breadcrumb a:hover { color: var(--primary); }

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  margin: 0 0 3px;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-sub);
  margin: 0;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}

/* ── Cards ── */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.panel-body {
  padding: 18px 20px;
}

.panel-title, .section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.panel-title .step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

/* ── Stat Cards ── */
.cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 14px 14px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 80px;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}
.stat-dot-default { background: #94a3b8; }
.stat-dot-success { background: var(--success); }
.stat-dot-danger  { background: var(--danger); }
.stat-dot-warn    { background: var(--warn); }
.stat-dot-info    { background: var(--info); }

.stat-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

/* tone colors */
.stat-success .stat-value { color: var(--success); }
.stat-danger  .stat-value { color: var(--danger); }
.stat-warn    .stat-value { color: var(--warn); }
.stat-info    .stat-value { color: var(--info); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 16px;
  height: 38px;
  border-radius: var(--radius-btn);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 100ms, opacity 100ms, box-shadow 100ms;
  outline: none;
  background: var(--primary);
  color: #fff;
}

.btn:hover { background: var(--primary-h); }
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: #64748b;
  color: #fff;
  border-color: transparent;
}
.btn-secondary:hover { background: #475569; }

.btn-outline {
  background: transparent;
  color: var(--text-sub);
  border-color: var(--border-mid);
}
.btn-outline:hover { background: var(--primary-bg); color: var(--primary); border-color: #c7d2fe; }

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  border-color: var(--border-mid);
}
.btn-ghost:hover { background: var(--bg); }

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: #fca5a5;
}
.btn-danger-outline:hover { background: var(--danger-bg); }

/* legacy alias */
.btn-inline { height: 38px; }

/* ── Inputs ── */
.input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-input);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
  width: 100%;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.10);
}
.input::placeholder { color: var(--muted); }

.input-sm { height: 34px; font-size: 12.5px; }
.input-lg { height: 48px; font-size: 15px; padding: 0 14px; }

/* ── QR Scan input ── */
.qr-capture {
  height: 48px;
  font-size: 15px;
  padding: 0 42px 0 14px;
  border-radius: 10px;
  border: 2px solid var(--border-mid);
}
.qr-capture:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(30, 58, 138, 0.10);
}

.qr-capture-wrap {
  position: relative;
}
.qr-capture-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 18px;
  pointer-events: none;
}

/* ── Last Scan Result ── */
.last-scan-card {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.last-scan-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  gap: 8px;
}

.last-scan-empty-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--muted);
}

.last-scan-empty-text {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.last-scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.last-scan-title-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.last-scan-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 5px 10px;
}

.last-scan-key {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.last-scan-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
  font-family: "Consolas", "Fira Code", monospace;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-ok      { background: var(--success-bg); color: var(--success-text); }
.badge-error   { background: var(--danger-bg);  color: var(--danger-text); }
.badge-dup     { background: var(--warn-bg);    color: var(--warn-text); }
.badge-neutral { background: #f1f5f9;           color: #475569; }

/* ── Right Side Panel ── */
.side-panel {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.side-panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.side-panel-section {
  padding: 14px 16px;
}

.side-panel-section + .side-panel-section {
  border-top: 1px solid var(--border);
}

.side-panel-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.side-kv {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.side-kv-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.side-kv-key {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.side-kv-val {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
}

/* ── QR Layout Grid ── */
.qr-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 296px;
  gap: 16px;
  align-items: start;
}

.qr-col-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* ── Table Toolbar ── */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.filter-pills {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border-mid);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
  transition: background 100ms, color 100ms;
}
.filter-pill:hover { background: var(--primary-bg); color: var(--primary); border-color: #c7d2fe; }
.filter-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.table-toolbar-spacer { flex: 1 1 auto; min-width: 8px; }

.toolbar-search {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-mid);
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  min-width: 180px;
  max-width: 260px;
  width: 100%;
  transition: border-color 100ms, box-shadow 100ms;
}
.toolbar-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.08);
}

.toolbar-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

.btn-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid var(--border-mid);
  background: var(--surface);
  color: var(--text-sub);
  cursor: pointer;
  white-space: nowrap;
  transition: background 100ms, color 100ms;
  text-decoration: none;
}
.btn-toolbar:hover { background: var(--bg); color: var(--text); }

.btn-toolbar-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-toolbar-primary:hover { background: var(--primary-h); }

/* ── Table Empty State ── */
.table-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 240px;
  color: var(--muted);
}

.table-empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 2px dashed #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.table-empty-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-sub);
}

.table-empty-sub {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  max-width: 280px;
  line-height: 1.5;
}

/* ── Tabulator Overrides ── */
.tabulator {
  border: none !important;
  background: var(--surface) !important;
  border-radius: 0 !important;
}

.tabulator .tabulator-header {
  background: #f1f4fb !important;
  border-bottom: 1px solid var(--border) !important;
}

.tabulator .tabulator-header .tabulator-col {
  background: #f1f4fb !important;
  border-right: 1px solid var(--border) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  color: var(--primary) !important;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tabulator .tabulator-row {
  border-bottom: 1px solid var(--border) !important;
  min-height: 44px !important;
}

.tabulator .tabulator-row:hover {
  background: #f8fafc !important;
}

.tabulator .tabulator-row .tabulator-cell {
  font-size: 13px !important;
  color: var(--text) !important;
  border-right: 1px solid var(--border) !important;
  vertical-align: middle !important;
}

.tabulator .tabulator-placeholder {
  display: none !important;
}

/* ctn/sn cell */
.cell-mono {
  font-family: "Consolas", "Fira Code", monospace;
  font-weight: 600;
}

/* row status left-border */
.tabulator .tabulator-row.row-ok    { border-left: 3px solid var(--success) !important; }
.tabulator .tabulator-row.row-error { border-left: 3px solid var(--danger)  !important; }
.tabulator .tabulator-row.row-dup   { border-left: 3px solid var(--warn)    !important; }

/* ── Tabulator Footer / Pagination ── */
.tabulator .tabulator-footer {
  background: #f8fafc !important;
  border-top: 1px solid var(--border) !important;
  padding: 9px 14px !important;
  border-radius: 0 0 var(--radius-card) var(--radius-card) !important;
}

.tabulator .tabulator-footer .tabulator-footer-contents {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  flex-wrap: wrap !important;
}

.tabulator .tabulator-footer .tabulator-page-counter {
  font-size: 11.5px !important;
  color: var(--muted) !important;
  font-weight: 600 !important;
  flex: 1 1 auto !important;
}

.tabulator .tabulator-footer .tabulator-paginator {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  flex-wrap: nowrap !important;
}

.tabulator .tabulator-footer .tabulator-paginator label {
  font-size: 11.5px !important;
  color: var(--muted) !important;
  font-weight: 600 !important;
  margin-right: 2px !important;
}

.tabulator .tabulator-footer .tabulator-page-size {
  height: 28px !important;
  border: 1px solid var(--border-mid) !important;
  border-radius: 6px !important;
  font-size: 12px !important;
  padding: 0 6px !important;
  color: var(--text) !important;
  background: var(--surface) !important;
  outline: none !important;
  cursor: pointer !important;
  margin-right: 8px !important;
}

.tabulator .tabulator-footer .tabulator-page {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 28px !important;
  height: 28px !important;
  padding: 0 8px !important;
  border-radius: 6px !important;
  border: 1px solid var(--border-mid) !important;
  background: var(--surface) !important;
  color: var(--text-sub) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  transition: background 100ms, color 100ms !important;
  white-space: nowrap !important;
}

.tabulator .tabulator-footer .tabulator-page:hover:not([disabled]) {
  background: var(--primary-bg) !important;
  color: var(--primary) !important;
  border-color: #c7d2fe !important;
}

.tabulator .tabulator-footer .tabulator-page.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

.tabulator .tabulator-footer .tabulator-page[disabled] {
  opacity: 0.35 !important;
  cursor: not-allowed !important;
}

/* sort arrows */
.tabulator .tabulator-header .tabulator-col .tabulator-col-sorter-element {
  color: var(--border-mid) !important;
}
.tabulator .tabulator-header .tabulator-col[aria-sort="ascending"]  .tabulator-col-sorter-element,
.tabulator .tabulator-header .tabulator-col[aria-sort="descending"] .tabulator-col-sorter-element {
  color: var(--primary) !important;
}

/* ── Toast Notification ── */
#toast-container {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  min-width: 0;
}

.toast {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(15,23,42,0.16);
  font-size: 13.5px;
  font-weight: 700;
  pointer-events: auto;
  max-width: min(440px, 88vw);
  word-break: break-word;
  animation: toast-in 0.22s ease;
  cursor: pointer;
  user-select: none;
}

.toast-warn {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid #fca5a5;
}
.toast-ok {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid #86efac;
}
.toast-info {
  background: var(--info-bg);
  color: var(--info-text);
  border: 1px solid #93c5fd;
}

.toast-icon {
  font-size: 17px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-body { display: flex; flex-direction: column; gap: 2px; }
.toast-title { font-size: 13.5px; font-weight: 800; }
.toast-sub   { font-size: 12px; font-weight: 600; opacity: 0.75; }

.toast-out { animation: toast-out 0.2s ease forwards; }

@keyframes toast-in  { from { opacity:0; transform:translateY(-14px); } to { opacity:1; transform:translateY(0); } }
@keyframes toast-out { from { opacity:1; transform:translateY(0); } to { opacity:0; transform:translateY(-10px); } }

/* ── Key-Value ── */
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 0.5rem 0.75rem; margin: 0; }
.kv dt { color: var(--muted); font-weight: 700; font-size: 12px; }
.kv dd { margin: 0; font-weight: 700; color: var(--text); word-break: break-all; font-size: 12.5px; }

/* ── Hints ── */
.hint {
  font-size: 12.5px;
  color: var(--text-sub);
  line-height: 1.5;
}
.hint-tight { margin-top: 0.3rem; }

.ime-warning {
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid #fde68a;
  border-radius: 7px;
  padding: 6px 10px;
  margin-bottom: 8px;
}

/* ── Modals ── */
.modal {
  border: none;
  padding: 0;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  max-width: min(520px, 92vw);
}
.modal::backdrop { background: rgba(15, 23, 42, 0.55); }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 20px 16px;
}

/* form-actions */
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ── Auth ── */
.auth-wrap {
  min-height: calc(100vh - var(--topbar-h) - 24px);
  display: grid;
  place-items: center;
  padding: 20px 0;
}
.auth-card {
  width: min(480px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 28px 24px;
}
.auth-title {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 20px;
  font-weight: 800;
}

/* ── General page elements ── */
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

/* ── Row remove btn ── */
.btn-row-remove {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid #fca5a5;
  background: transparent;
  color: var(--danger);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.btn-row-remove:hover { background: var(--danger-bg); }

/* ── Legacy list-toolbar & tabs ── */
.list-toolbar { display: flex; flex-direction: column; gap: 8px; }
.list-toolbar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-toolbar-label { font-size: 12.5px; font-weight: 700; color: var(--text-sub); white-space: nowrap; }
.list-per-page { height: 40px; border: 1px solid var(--border-mid); border-radius: var(--radius-input); padding: 0 10px; font-size: 13px; color: var(--text); background: var(--surface); }
.list-per-page:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(30,58,138,0.08); }

.tabs { display: flex; gap: 2px; }
.tab {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-mid);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  transition: background 100ms, color 100ms;
}
.tab:hover { background: var(--primary-bg); color: var(--primary); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .qr-layout {
    grid-template-columns: 1fr;
  }
  .side-panel {
    position: static;
  }
  .cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-110%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-close { display: inline-flex !important; }
  .topbar-actions { display: none; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px 16px 40px; }
}

@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
}
