/* Carbon dark palette — mirrors ``ui_themes._carbon`` / desktop Tk shell */
:root {
  --tk-page: #1a1a1c;
  --tk-card: #262628;
  --tk-card-alt: #2e3033;
  --tk-panel: #2f3135;
  --tk-sidebar: #141416;
  --tk-sidebar-fg: #f4f4f5;
  --tk-border: #3f4146;
  --tk-text: #e8e8ea;
  --tk-muted: #a1a1aa;
  --tk-accent: #22c55e;
  --tk-accent-dark: #16a34a;
  --tk-url: #00bcd4;
  --tk-danger: #dc2626;
  --tk-font: "Segoe UI", "Segoe UI Variable", system-ui, -apple-system, Tahoma, sans-serif;
  --tk-sidebar-w: 232px;
  --tk-sidebar-w-narrow: 56px;
  --tk-header-h: 40px;
  --tk-mobile-stack-h: 52px;
  --tk-mobile-touch-min: 48px;
  --tk-radius-panel: 10px;
  --tk-radius-btn: 6px;
  /* Legacy aliases (existing components) */
  --bg: var(--tk-page);
  --surface: var(--tk-card);
  --border: var(--tk-border);
  --text: var(--tk-text);
  --muted: var(--tk-muted);
  --accent: var(--tk-accent);
  --danger: #f87171;
  --radius: var(--tk-radius-panel);
}

* {
  box-sizing: border-box;
}

/* Thin scrollbars + contained overscroll (POS panels, shell, modals) */
.tk-products-pane,
#cart-items,
.tk-cart-inner,
.tk-sidebar-nav,
.tk-main-inner,
.modal-panel {
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--tk-muted) 70%, var(--tk-border)) var(--tk-panel);
}

.tk-products-pane::-webkit-scrollbar,
#cart-items::-webkit-scrollbar,
.tk-cart-inner::-webkit-scrollbar,
.tk-sidebar-nav::-webkit-scrollbar,
.tk-main-inner::-webkit-scrollbar,
.modal-panel::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.tk-products-pane::-webkit-scrollbar-track,
#cart-items::-webkit-scrollbar-track,
.tk-cart-inner::-webkit-scrollbar-track,
.tk-sidebar-nav::-webkit-scrollbar-track,
.tk-main-inner::-webkit-scrollbar-track,
.modal-panel::-webkit-scrollbar-track {
  background: var(--tk-panel);
  border-radius: 8px;
}

.tk-products-pane::-webkit-scrollbar-thumb,
#cart-items::-webkit-scrollbar-thumb,
.tk-cart-inner::-webkit-scrollbar-thumb,
.tk-sidebar-nav::-webkit-scrollbar-thumb,
.tk-main-inner::-webkit-scrollbar-thumb,
.modal-panel::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--tk-muted) 65%, var(--tk-border));
  border-radius: 8px;
  border: 2px solid var(--tk-panel);
}

.tk-products-pane::-webkit-scrollbar-thumb:hover,
#cart-items::-webkit-scrollbar-thumb:hover,
.tk-cart-inner::-webkit-scrollbar-thumb:hover,
.tk-sidebar-nav::-webkit-scrollbar-thumb:hover,
.tk-main-inner::-webkit-scrollbar-thumb:hover,
.modal-panel::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--tk-muted) 85%, var(--tk-border));
}

body {
  margin: 0;
  font-family: var(--tk-font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1.25rem;
  background: rgba(12, 14, 18, 0.95);
  border-bottom: 1px solid var(--border);
}

.app-nav .brand {
  font-weight: 800;
  margin-right: auto;
  color: var(--text);
}

.app-nav a {
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  color: var(--muted);
}

.app-nav a:hover {
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.app-nav a.nav-active {
  color: var(--accent);
}

main.container,
.tk-main-inner,
.page-content {
  max-width: none;
  margin: 0;
  padding: 16px;
  padding-bottom: 12px;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 1200px) {
  main.container,
  .tk-main-inner,
  .page-content {
    padding: 16px 20px 12px;
  }
}

.section-card {
  margin-bottom: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 16px;
}

.flash {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.flash.ok {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid var(--accent);
}

.flash.error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid var(--danger);
  color: #fecaca;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data th,
table.data td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data th {
  color: var(--muted);
  font-weight: 600;
}

.btn {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--tk-accent);
  color: #052e16;
  font-family: var(--tk-font);
}

.btn-primary:hover {
  background: var(--tk-accent-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

input,
select,
textarea {
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--tk-card);
  color: var(--text);
  font-family: var(--tk-font);
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-box,
.tk-kpi-card {
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-panel);
  padding: 0.65rem 1rem 0.85rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.stat-box .val,
.tk-kpi-card .val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--tk-accent);
  font-variant-numeric: tabular-nums;
}

.stat-box .lbl,
.tk-kpi-card .lbl {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tk-muted);
}

.chart-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  margin-top: 1rem;
}

.chart-bar {
  flex: 1;
  min-width: 8px;
  background: linear-gradient(180deg, var(--accent), #15803d);
  border-radius: 4px 4px 0 0;
  transition: opacity 0.2s;
}

.chart-bar:hover {
  opacity: 0.85;
}

/* Web POS modal: overlay below panel; close control always clickable */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.modal.open {
  display: flex;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.modal-panel,
.tk-dialog-panel,
.modal-card {
  position: relative;
  z-index: 1001;
  width: 100%;
  max-width: 420px;
  max-height: min(70vh, 640px);
  overflow: auto;
  background: var(--tk-panel);
  border: 1px solid var(--tk-border);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
  pointer-events: auto;
}

.modal-panel--wide,
.modal-card--wide {
  max-width: min(96vw, 920px);
  max-height: 70vh;
}

.modal-panel--tall {
  max-height: min(85dvh, 720px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin: -0.25rem -0.35rem -0.25rem 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.modal-body {
  padding: 1rem;
  font-size: 0.92rem;
  color: var(--text);
}

/* Top nav: Settings → Receipt */
.app-nav .nav-settings,
.pos-nav .nav-settings {
  position: relative;
  list-style: none;
}

.app-nav .nav-settings > summary,
.pos-nav .nav-settings > summary {
  cursor: pointer;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  list-style: none;
}

.app-nav .nav-settings > summary::-webkit-details-marker,
.pos-nav .nav-settings > summary::-webkit-details-marker {
  display: none;
}

.app-nav .nav-settings > summary::after,
.pos-nav .nav-settings > summary::after {
  content: " ▾";
  font-size: 0.75em;
  opacity: 0.8;
}

.app-nav .nav-settings[open] > summary,
.pos-nav .nav-settings[open] > summary {
  color: var(--text);
  background: var(--surface);
}

.app-nav .nav-settings-panel,
.pos-nav .nav-settings-panel {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 10rem;
  padding: 0.35rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 50;
}

.app-nav .nav-settings-panel a,
.pos-nav .nav-settings-panel a {
  display: block;
  padding: 0.45rem 0.85rem;
  color: var(--muted);
  text-decoration: none;
}

.app-nav .nav-settings-panel a:hover,
.pos-nav .nav-settings-panel a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.app-nav .nav-settings-panel a.nav-active,
.pos-nav .nav-settings-panel a.nav-active {
  color: var(--accent);
}

/* Settings / receipt page layout */
.settings-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  max-width: 1100px;
}

.settings-sidebar {
  flex: 0 0 200px;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.settings-sidebar-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

.settings-sidebar-link {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.settings-sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
}

.settings-sidebar-link.nav-active {
  color: var(--accent);
  background: rgba(34, 197, 94, 0.12);
}

.settings-main {
  flex: 1;
  min-width: 0;
}

.receipt-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 320px);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 800px) {
  .receipt-settings-grid {
    grid-template-columns: 1fr;
  }
  .settings-layout {
    flex-direction: column;
  }
  .settings-sidebar {
    flex: none;
    width: 100%;
  }
}

.receipt-settings-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.receipt-settings-fields label:not(.receipt-check) {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 0.35rem;
}

.receipt-settings-fields label.receipt-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  cursor: pointer;
}

.receipt-settings-fields #saveReceipt {
  margin-top: 0.75rem;
  max-width: 12rem;
}

.receipt-preview-title {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.receipt-preview-paper {
  max-width: 58mm;
  margin: 0 auto;
  padding: 1rem;
  background: #fff;
  color: #111;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.82rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.receipt-preview-paper h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: #111;
}

.receipt-preview-paper p {
  margin: 0.2rem 0;
  color: #222;
}

.receipt-preview-paper hr {
  border: none;
  border-top: 1px solid #ccc;
  margin: 0.5rem 0;
}

.rp-logo-preview {
  text-align: center;
  font-size: 0.65rem;
  border: 1px dashed #999;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  color: #555;
}

/* --- Tkinter-style app shell (web POS + admin pages) --- */
body.tk-shell {
  overflow-x: hidden;
}

.tk-app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  background: var(--tk-page);
}

.tk-body-row {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Top header — matches ``RetailApp._build_top_header`` strip */
.tk-header {
  flex-shrink: 0;
  background: var(--tk-page);
  border-bottom: 1px solid var(--tk-border);
  min-height: var(--tk-header-h);
}

.tk-header-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 3px 10px;
  min-height: calc(var(--tk-header-h) - 4px);
  flex-wrap: wrap;
}

.tk-header-shop {
  flex: 1 1 140px;
  min-width: 0;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--tk-text);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tk-header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 0.65rem;
  flex: 1 1 280px;
}

.tk-header-sep {
  height: 1px;
  background: var(--tk-border);
}

.tk-sync-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 10px;
  font-size: 0.8125rem;
  color: var(--tk-text);
  border-radius: var(--tk-radius-btn);
  border: 1px solid var(--tk-border);
  background: var(--tk-panel);
}

.tk-sync-strip .toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.tk-sync-strip .toggle input {
  margin-right: 5px;
  accent-color: var(--tk-accent);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.tk-btn-header,
.tk-sync-strip #manualSyncBtn {
  padding: 5px 10px;
  border-radius: var(--tk-radius-btn);
  cursor: pointer;
  border: 1px solid var(--tk-border);
  background: var(--tk-panel);
  color: var(--tk-text);
  font-weight: 600;
  font-size: 0.8125rem;
  font-family: var(--tk-font);
}

.tk-btn-header:hover,
.tk-sync-strip #manualSyncBtn:hover {
  border-color: var(--tk-accent);
  color: var(--tk-accent);
}

.tk-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: min(100%, 420px);
}

.tk-url-text,
#lblServerUrl {
  font-size: 0.625rem;
  color: var(--tk-url);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(260px, 45vw);
}

.tk-net-badge {
  font-size: 0.75rem;
  color: var(--tk-muted);
  white-space: nowrap;
}

.tk-header-clock,
#clock {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--tk-accent);
  font-variant-numeric: tabular-nums;
}

/* Sidebar — grouped nav like ``NAV_GROUPS`` */
.tk-sidebar {
  width: var(--tk-sidebar-w);
  flex-shrink: 0;
  background: var(--tk-sidebar);
  color: var(--tk-sidebar-fg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: width 0.2s ease;
  border-right: 1px solid var(--tk-border);
}

.tk-sidebar.is-collapsed {
  width: var(--tk-sidebar-w-narrow);
}

.tk-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 14px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.tk-sidebar-brand-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.tk-sidebar-jump-wrap {
  flex-shrink: 0;
  padding: 0 8px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tk-sidebar-jump-wrap[hidden] {
  display: none !important;
}

.tk-sidebar-jump {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: var(--tk-radius-btn);
  border: 1px solid color-mix(in srgb, var(--tk-sidebar-fg) 18%, transparent);
  background: color-mix(in srgb, var(--tk-sidebar-fg) 6%, transparent);
  color: var(--tk-sidebar-fg);
  font-family: var(--tk-font);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.tk-sidebar-jump:focus {
  outline: 2px solid color-mix(in srgb, var(--tk-accent) 55%, transparent);
  outline-offset: 1px;
}

.tk-sidebar-jump option,
.tk-sidebar-jump optgroup {
  color: #111;
  background: #fff;
  font-weight: 600;
}

.tk-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.tk-nav-group {
  border: none;
  margin: 0 0 4px;
}

.tk-nav-group-title {
  list-style: none;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tk-muted);
  padding: 10px 8px 4px;
  cursor: default;
  user-select: none;
}

.tk-nav-group-title::-webkit-details-marker {
  display: none;
}

.tk-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: var(--tk-radius-btn);
  color: var(--tk-sidebar-fg);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--tk-font);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.tk-nav-item:hover {
  background: color-mix(in srgb, var(--tk-sidebar-fg) 10%, transparent);
  color: var(--tk-sidebar-fg);
  text-decoration: none;
}

.tk-nav-item.is-active {
  background: color-mix(in srgb, var(--tk-accent) 24%, transparent);
  color: var(--tk-accent);
}

.tk-nav-ico {
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.tk-sidebar-footer {
  padding: 8px 10px 10px;
  border-top: 1px solid color-mix(in srgb, var(--tk-sidebar-fg) 10%, transparent);
  flex-shrink: 0;
  font-size: 0.75rem;
}

.tk-sidebar-footer .tk-muted-footer {
  color: var(--tk-muted);
  margin-bottom: 6px;
  word-break: break-word;
}

.tk-sidebar-footer .tk-signout-form {
  display: block;
  width: 100%;
  margin: 0 0 6px;
}

.tk-sidebar-footer .tk-btn-signout {
  display: block;
  width: 100%;
  padding: 8px;
  margin-bottom: 0;
  border: none;
  border-radius: var(--tk-radius-btn);
  background: transparent;
  color: var(--tk-sidebar-fg);
  font-family: var(--tk-font);
  font-size: 0.8125rem;
  cursor: pointer;
  text-align: center;
}

.tk-sidebar-footer .tk-btn-signout:hover {
  background: color-mix(in srgb, var(--tk-accent) 22%, transparent);
  color: var(--tk-accent);
}

.tk-sidebar-toggle {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: var(--tk-radius-btn);
  background: color-mix(in srgb, var(--tk-sidebar-fg) 8%, transparent);
  color: var(--tk-sidebar-fg);
  font-size: 0.875rem;
  cursor: pointer;
  font-family: var(--tk-font);
}

.tk-sidebar.is-collapsed .tk-sidebar-jump-wrap {
  display: none;
}

.tk-sidebar.is-collapsed .tk-nav-txt,
.tk-sidebar.is-collapsed .tk-sidebar-brand-text,
.tk-sidebar.is-collapsed .tk-nav-group-title,
.tk-sidebar.is-collapsed .tk-muted-footer {
  display: none;
}

.tk-sidebar.is-collapsed .tk-sidebar-brand {
  justify-content: center;
  padding: 14px 4px;
}

.tk-sidebar.is-collapsed .tk-nav-item {
  justify-content: center;
  padding: 8px 4px;
}

.tk-sidebar.is-collapsed .tk-btn-signout {
  font-size: 0;
  padding: 8px;
  line-height: 1;
  position: relative;
  color: transparent;
}

.tk-sidebar.is-collapsed .tk-btn-signout::after {
  content: "⎋";
  font-size: 0.85rem;
  color: var(--tk-sidebar-fg);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.tk-main-col {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--tk-page);
  overflow: hidden;
}

.tk-main-col > .tk-main-inner,
.tk-main-col > main.tk-main-inner {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.tk-page-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--tk-text);
}

.tk-page-sub {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--tk-muted);
}

/* POS workspace: center grid + right cart */
.tk-pos-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--tk-page);
  border-bottom: 1px solid var(--tk-border);
  flex-shrink: 0;
  min-height: 0;
}

.tk-pos-toolbar select,
.tk-pos-toolbar input[type="search"],
.tk-pos-toolbar input[type="text"] {
  min-height: 40px;
  border-radius: var(--tk-radius-btn);
  border: 1px solid var(--tk-border);
  background: var(--tk-card);
  color: var(--tk-text);
  padding: 0 0.65rem;
  font-family: var(--tk-font);
}

.tk-pos-toolbar .tk-toolbar-spacer {
  flex: 1;
  min-width: 8px;
}

.tk-pos-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(260px, 3fr);
  overflow: hidden;
}

.tk-products-pane {
  padding: 1rem;
  overflow: auto;
  border-right: 1px solid var(--tk-border);
  background: var(--tk-page);
}

.tk-cart-pane {
  background: var(--tk-card);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--tk-border);
}

.tk-cart-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 1rem;
  overflow: hidden;
}

.tk-cart-pane-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tk-cart-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--tk-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tk-product-card {
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-panel);
  padding: 0.85rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tk-product-card:not(.oos):not(.inactive):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.tk-btn-add {
  min-height: 44px;
  border: none;
  border-radius: var(--tk-radius-btn);
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: var(--tk-font);
  background: var(--tk-accent);
  color: #052e16;
}

.tk-btn-add:disabled {
  background: var(--tk-border);
  color: var(--tk-muted);
  cursor: not-allowed;
}

.tk-btn-done {
  width: 100%;
  min-height: 52px;
  margin-top: 0.75rem;
  background: linear-gradient(180deg, #4ade80, var(--tk-accent));
  color: #052e16;
  font-size: 1rem;
  font-weight: 800;
  border: none;
  border-radius: var(--tk-radius-panel);
  cursor: pointer;
  font-family: var(--tk-font);
}

.tk-btn-done:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tk-status-msg {
  padding: 0.5rem 0.75rem;
  border-radius: var(--tk-radius-btn);
  background: var(--tk-panel);
  margin-bottom: 0.75rem;
  font-size: 0.86rem;
  border: 1px solid transparent;
}

.tk-status-msg.err {
  border-color: var(--tk-danger);
  color: #fecaca;
}

.tk-shell .card {
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-panel);
}

.tk-shell table.data thead th {
  background: var(--tk-card-alt);
  color: var(--tk-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tk-shell table.data tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tk-grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.pay-method-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tk-mobile-pay-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 0.5rem 1rem;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, rgba(26, 26, 28, 0.92) 30%);
  border-top: 1px solid var(--tk-border);
  justify-content: center;
  box-sizing: border-box;
}

.tk-mobile-pay-bar .tk-btn-done {
  width: 100%;
  max-width: 420px;
  margin: 0;
}

@media (max-width: 900px) {
  .tk-pos-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .tk-products-pane {
    max-height: 52vh;
    border-right: none;
    border-bottom: 1px solid var(--tk-border);
  }

  .tk-cart-pane {
    max-height: none;
    min-height: 38vh;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .tk-cart-inner {
    max-height: min(52vh, 420px);
    overflow: auto;
  }

  .cart-footer {
    position: sticky;
    bottom: 0;
    background: var(--tk-card);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--tk-border);
  }

  .tk-complete-desktop {
    display: none !important;
  }

  .tk-mobile-pay-bar {
    display: flex;
  }
}

/* --- Mobile-first shell (≤767px): drawer nav, sticky bar, compact pages --- */
.tk-mobile-top-wrap {
  display: none;
}

.tk-mobile-topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem;
  min-height: var(--tk-mobile-touch-min);
  background: var(--tk-page);
}

.tk-mobile-menu-btn {
  flex-shrink: 0;
  width: var(--tk-mobile-touch-min);
  height: var(--tk-mobile-touch-min);
  padding: 0;
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-btn);
  background: var(--tk-panel);
  color: var(--tk-text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  font-family: var(--tk-font);
  -webkit-tap-highlight-color: transparent;
}

.tk-mobile-brand {
  flex: 1;
  min-width: 0;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--tk-text);
}

.tk-mobile-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.tk-mobile-icon-btn {
  width: var(--tk-mobile-touch-min);
  height: var(--tk-mobile-touch-min);
  padding: 0;
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-btn);
  background: var(--tk-panel);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tk-mobile-bell-wrap {
  position: relative;
}

.tk-mobile-bell-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  max-width: min(92vw, 280px);
  padding: 0.65rem 0.75rem;
  background: var(--tk-panel);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  z-index: 2020;
  font-size: 0.85rem;
}

.tk-mobile-bell-popover[hidden] {
  display: none !important;
}

.tk-mobile-bell-row {
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.tk-mobile-bell-action {
  display: block;
  width: 100%;
  text-align: left;
  margin-top: 0.35rem;
  padding: 0.5rem 0.65rem;
  min-height: 44px;
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-btn);
  background: var(--tk-card);
  color: var(--tk-text);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--tk-font);
}

.tk-mobile-profile-wrap {
  position: relative;
}

.tk-mobile-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 140px;
  min-height: var(--tk-mobile-touch-min);
  padding: 0 0.5rem;
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-btn);
  background: var(--tk-panel);
  color: var(--tk-text);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--tk-font);
  -webkit-tap-highlight-color: transparent;
}

.tk-mobile-profile-avatar {
  font-size: 1rem;
  flex-shrink: 0;
}

.tk-mobile-profile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tk-mobile-profile-caret {
  font-size: 0.55rem;
  opacity: 0.7;
  flex-shrink: 0;
}

.tk-mobile-profile-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  max-width: min(88vw, 260px);
  padding: 0.35rem 0;
  background: var(--tk-panel);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  z-index: 2020;
}

.tk-mobile-profile-menu[hidden] {
  display: none !important;
}

.tk-mobile-profile-item {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--tk-text);
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  font-family: var(--tk-font);
  cursor: pointer;
  box-sizing: border-box;
}

.tk-mobile-profile-item:hover,
.tk-mobile-profile-item:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

.tk-mobile-profile-signout {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--tk-border);
  margin-top: 0.25rem;
  padding-top: 0.25rem;
}

.tk-mobile-profile-signout-btn {
  color: var(--tk-danger);
}

.tk-mobile-pos-sync {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
  padding: 0.35rem 0.65rem 0.5rem;
  font-size: 0.78rem;
  border-top: 1px solid var(--tk-border);
  background: color-mix(in srgb, var(--tk-panel) 88%, var(--tk-page));
}

.tk-mobile-sync-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
  color: var(--tk-muted);
}

.tk-mobile-sync-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--tk-accent);
}

.tk-mobile-sync-now {
  padding: 0.35rem 0.65rem;
  min-height: 40px;
  border-radius: var(--tk-radius-btn);
  border: 1px solid var(--tk-border);
  background: var(--tk-card);
  color: var(--tk-text);
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: var(--tk-font);
}

.tk-mobile-last-sync {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tk-mobile-drawer-backdrop {
  display: none;
}

@media (max-width: 767px) {
  .tk-mobile-top-wrap {
    display: block;
  }

  .tk-header,
  .tk-header-sep {
    display: none !important;
  }

  .tk-mobile-drawer-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1990;
    background: rgba(0, 0, 0, 0.52);
    -webkit-tap-highlight-color: transparent;
  }

  .tk-sidebar {
    position: fixed;
    left: 0;
    top: var(--tk-mobile-stack-h, 52px);
    bottom: 0;
    width: min(300px, 88vw);
    max-width: 300px;
    z-index: 2000;
    transform: translate3d(-102%, 0, 0);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--tk-border);
    border-bottom: none;
    box-shadow: 8px 0 36px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
  }

  html.tk-mobile-drawer-open .tk-sidebar {
    transform: translate3d(0, 0, 0);
  }

  .tk-sidebar.is-collapsed {
    width: min(300px, 88vw);
  }

  .tk-sidebar-footer,
  .tk-sidebar-toggle {
    display: none !important;
  }

  .tk-sidebar-nav {
    padding-bottom: 1rem;
  }

  .tk-nav-item {
    min-height: 44px;
  }

  .tk-body-row {
    flex: 1;
    min-height: 0;
  }

  .tk-main-col {
    width: 100%;
    min-width: 0;
  }

  main.container,
  .tk-main-inner,
  .page-content {
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .section-card,
  .card {
    margin-bottom: 10px;
    padding: 0.75rem 0.85rem;
  }

  .tk-page-title {
    font-size: 1.15rem;
  }

  .tk-page-sub--desktop {
    display: none !important;
  }

  .tk-page-sub--mobile {
    display: block !important;
  }

  /* Dashboard KPI grid: 2 columns, compact */
  .tk-grid-stats,
  .grid-stats.dashboard-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 0.85rem !important;
  }

  .tk-kpi-card,
  .stat-box {
    min-height: 90px;
    padding: 12px !important;
  }

  .tk-kpi-card .val,
  .stat-box .val {
    font-size: 1.05rem;
  }

  .tk-kpi-card .lbl,
  .stat-box .lbl {
    font-size: 0.65rem;
  }

  .chart-row {
    height: 88px;
    margin-top: 0.65rem;
  }

  /* Touch-friendly controls */
  .btn {
    min-height: var(--tk-mobile-touch-min);
    padding: 0.55rem 1rem;
  }

  .tk-btn-header,
  .tk-sync-strip #manualSyncBtn {
    min-height: 44px;
  }

  /* Tables → stacked cards */
  table.data.tk-table-stacked thead {
    display: none;
  }

  table.data.tk-table-stacked,
  table.data.tk-table-stacked tbody,
  table.data.tk-table-stacked tr,
  table.data.tk-table-stacked td {
    display: block;
    width: 100%;
  }

  table.data.tk-table-stacked tr {
    margin-bottom: 10px;
    padding: 0.65rem 0.75rem;
    background: var(--tk-card);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius-panel);
    box-sizing: border-box;
  }

  table.data.tk-table-stacked td {
    border: none;
    padding: 0.28rem 0;
    text-align: right;
    font-size: 0.88rem;
  }

  table.data.tk-table-stacked td::before {
    content: attr(data-label);
    float: left;
    font-weight: 700;
    color: var(--tk-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    max-width: 48%;
    text-align: left;
  }

  table.data.tk-table-stacked td::after {
    content: "";
    display: table;
    clear: both;
  }

  table.data.tk-table-stacked td[colspan] {
    text-align: center;
  }

  table.data.tk-table-stacked td[colspan]::before {
    display: none;
  }

  /* Full-screen modals (above drawer z-index) */
  .modal {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    z-index: 2100;
  }

  .modal-overlay {
    z-index: 2099;
  }

  .modal-panel,
  .tk-dialog-panel,
  .modal-card {
    position: relative;
    z-index: 2101;
    max-width: 100% !important;
    width: 100% !important;
    max-height: 100dvh !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    border-left: none;
    border-right: none;
  }

  .modal-header {
    padding: 0.65rem 0.85rem;
    position: sticky;
    top: 0;
    background: var(--tk-panel);
    z-index: 1;
  }

  .modal-close {
    width: var(--tk-mobile-touch-min);
    height: var(--tk-mobile-touch-min);
  }

  /* POS: smaller product tiles, cart drawer */
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.55rem;
  }

  .product-card,
  .tk-product-card {
    padding: 0.55rem 0.65rem;
  }

  .pc-name {
    font-size: 0.82rem;
  }

  .tk-pos-toolbar {
    padding: 0.45rem 0.65rem;
    gap: 0.45rem;
  }

  .tk-pos-toolbar select,
  .tk-pos-toolbar input[type="search"] {
    min-height: var(--tk-mobile-touch-min);
  }

  .btn-nav-help {
    min-height: var(--tk-mobile-touch-min);
  }

  .tk-cart-inner {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .tk-cart-title {
    flex-shrink: 0;
    margin: 0;
    padding: 0.5rem 0;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .tk-cart-title::after {
    content: "▲";
    font-size: 0.7rem;
    opacity: 0.65;
    flex-shrink: 0;
  }

  .tk-cart-pane.tk-mobile-cart-expanded .tk-cart-title::after {
    content: "▼";
  }

  .tk-cart-pane-inner {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .tk-cart-pane:not(.tk-mobile-cart-expanded) .tk-cart-pane-inner {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
  }

  .tk-cart-pane.tk-mobile-cart-expanded .tk-cart-pane-inner {
    max-height: min(52vh, 420px);
    opacity: 1;
    pointer-events: auto;
  }

  .tk-pos-workspace {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }

  .tk-cart-inner {
    max-height: none !important;
    overflow: visible !important;
  }

  .tk-mobile-pay-bar .tk-btn-done {
    min-height: var(--tk-mobile-touch-min);
  }
}

/* Desktop: hide mobile-only subtitle variant */
.tk-page-sub--mobile {
  display: none;
}

/* Theme colors come from ``web_theme`` + DB ``ui_theme`` (same presets as Tkinter). */

/* Web POS product grid + cart (shared with ``templates/index.html``) */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.75rem;
}

.product-card {
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-panel);
  padding: 0.85rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.product-card:not(.oos):not(.inactive):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.product-card.inactive {
  opacity: 0.5;
}

.product-card.oos {
  opacity: 0.85;
}

.product-card.low-stock {
  border-color: rgba(239, 68, 68, 0.65);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.25);
}

.pc-head {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  align-items: flex-start;
}

.pc-name {
  font-weight: 600;
  font-size: 0.92rem;
  margin: 0;
  line-height: 1.3;
}

.badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
}

.badge-oos {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.badge-low {
  background: rgba(239, 68, 68, 0.25);
  color: #fecaca;
}

.pc-meta {
  font-size: 0.8rem;
  color: var(--tk-muted);
  margin: 0.35rem 0;
}

.pc-price {
  color: var(--tk-accent);
  font-weight: 700;
}

.cart-line {
  background: var(--tk-panel);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-btn);
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.45rem;
  scroll-snap-align: start;
  scroll-snap-stop: normal;
}

.cart-line-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.qty-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.qty-row input[type="number"] {
  width: 4.5rem;
  text-align: center;
  padding: 0.35rem;
  border-radius: var(--tk-radius-btn);
  border: 1px solid var(--tk-border);
  background: var(--tk-page);
  color: var(--tk-text);
  font-family: var(--tk-font);
}

.qty-row button {
  width: 36px;
  height: 36px;
  border-radius: var(--tk-radius-btn);
  border: 1px solid var(--tk-border);
  background: var(--tk-card-alt);
  color: var(--tk-text);
  font-size: 1.1rem;
  cursor: pointer;
  font-family: var(--tk-font);
}

.qty-row button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.cart-footer {
  border-top: 1px solid var(--tk-border);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  flex-shrink: 0;
}

.cart-footer .row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 0.88rem;
}

.row-total {
  font-weight: 800;
  font-size: 1.05rem;
  margin-top: 0.35rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--tk-border);
}

.row-total span:last-child {
  color: var(--tk-accent);
}

#cart-items {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 60px;
  scroll-snap-type: y proximity;
  scroll-padding-block: 0.35rem;
}

#toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--tk-accent);
  color: #052e16;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-weight: 700;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transition: transform 0.35s ease;
  z-index: 1100;
  font-family: var(--tk-font);
}

#toast.show {
  transform: translateX(-50%) translateY(0);
}

#toast.bad {
  background: var(--tk-danger);
  color: #fff;
}

.btn-nav-help {
  min-height: 40px;
  padding: 0 0.75rem;
  border-radius: var(--tk-radius-btn);
  border: 1px solid var(--tk-border);
  background: var(--tk-panel);
  color: var(--tk-muted);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--tk-font);
}

.btn-nav-help:hover {
  color: var(--tk-text);
}

/* Web POS: box / piece toggle (sub-quantity) */
.pos-sell-mode {
  display: flex;
  gap: 6px;
  margin: 0.5rem 0 0.35rem;
}

.psm-btn {
  flex: 1;
  min-height: 36px;
  border-radius: var(--tk-radius-btn);
  border: 1px solid var(--tk-border);
  background: var(--tk-panel);
  color: var(--tk-muted);
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--tk-font);
  cursor: pointer;
}

.psm-btn.is-active {
  border-color: var(--tk-accent);
  color: var(--tk-accent);
  background: rgba(34, 197, 94, 0.12);
}

.pm-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
}

/* Settings: ten UI themes (same names as desktop ``ui_themes``) */
.tk-theme-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tk-muted);
  margin: 0 0 0.5rem;
}

.tk-theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 0.6rem;
  margin: 0 0 1rem;
  max-width: 720px;
}

.tk-theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  border-radius: var(--tk-radius-btn);
  border: 2px solid var(--tk-border);
  background: var(--tk-panel);
  padding: 0.55rem 0.4rem 0.65rem;
  margin: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tk-theme-option:hover {
  border-color: color-mix(in srgb, var(--tk-accent) 45%, var(--tk-border));
}

.tk-theme-option:has(input:checked) {
  border-color: var(--tk-accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tk-accent) 35%, transparent);
}

.tk-theme-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.tk-theme-swatch {
  width: 100%;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--tk-border);
  background: linear-gradient(90deg, var(--swatch-page) 50%, var(--swatch-accent) 50%);
}

.tk-theme-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--tk-text);
}

/* --- Admin pages: compact layout, action bars, data tables --- */
.tk-page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.tk-page-actions .tk-page-actions-fill {
  flex: 1;
  min-width: 8px;
}

.tk-input-compact {
  min-height: 40px;
  border-radius: var(--tk-radius-btn);
  border: 1px solid var(--tk-border);
  background: var(--tk-card);
  color: var(--tk-text);
  padding: 0 0.65rem;
  font-family: var(--tk-font);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.tk-modal-table-wrap {
  max-height: 55vh;
  overflow: auto;
}

table.data.tk-table-compact th,
table.data.tk-table-compact td {
  padding: 0.35rem 0.5rem;
  font-size: 0.84rem;
  line-height: 1.35;
  vertical-align: middle;
}

.tk-shell table.data.tk-table-compact thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--tk-card-alt);
  box-shadow: 0 1px 0 var(--tk-border);
}

table.data.tk-sortable thead th[data-sort].tk-sort-asc::after {
  content: " ▲";
  font-size: 0.65em;
  opacity: 0.75;
}

table.data.tk-sortable thead th[data-sort].tk-sort-desc::after {
  content: " ▼";
  font-size: 0.65em;
  opacity: 0.75;
}

@media (max-width: 768px) {
  .tk-stacked-cards .section-card,
  .tk-stacked-cards .card {
    margin-bottom: 12px;
  }
}

/* Settings + system content (e.g. dashboard): tabbed sections */
.tk-settings-tabs,
.tk-system-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--tk-border);
}

.tk-settings-tabs button,
.tk-system-tabs button {
  padding: 8px 12px;
  margin: 0 0 -1px;
  border: 1px solid transparent;
  border-radius: var(--tk-radius-btn) var(--tk-radius-btn) 0 0;
  background: transparent;
  color: var(--tk-muted);
  font-family: var(--tk-font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.tk-settings-tabs button:hover,
.tk-system-tabs button:hover {
  color: var(--tk-text);
}

.tk-settings-tabs button.is-active,
.tk-system-tabs button.is-active {
  color: var(--tk-accent);
  border-color: var(--tk-border);
  border-bottom-color: var(--tk-card);
  background: var(--tk-card);
}

.tk-settings-panel,
.tk-system-tab-panel {
  display: none;
  margin: 0;
  padding: 0;
}

.tk-settings-panel.is-active,
.tk-system-tab-panel.is-active {
  display: block;
}

/* Main page column: system content area */
.system-content {
  min-width: 0;
}

.tk-settings-hub {
  margin-bottom: 16px;
}
