/* =========================================================
   NextStep Device Manager — Snipe-IT inspired, modernised
   Bootstrap Icons via CDN
   ========================================================= */

/* ── Tokens ───────────────────────────────────────────────── */
:root {
  /* Sidebar (Snipe-IT palette) */
  --sidebar-bg:          #222d32;
  --sidebar-darker:      #1a2226;
  --sidebar-hover-bg:    rgba(255,255,255,0.06);
  --sidebar-active-bg:   #1a2226;
  --sidebar-active-bar:  #3c8dbc;
  --sidebar-text:        #8aa4af;
  --sidebar-text-hover:  #c8d8df;
  --sidebar-text-active: #ffffff;
  --sidebar-section-lbl: #4b636e;

  /* Primary (Snipe-IT teal-blue) */
  --primary:       #3c8dbc;
  --primary-hover: #337ab7;
  --primary-dark:  #2d6f9e;
  --primary-light: #d9edf7;
  --primary-faint: #f0f8fd;

  /* Content chrome */
  --content-bg:   #ecf0f1;
  --panel-bg:     #ffffff;
  --panel-header: #f7f7f7;

  /* Text */
  --ink:    #333333;
  --muted:  #777777;
  --subtle: #aaaaaa;

  /* Borders */
  --line:        #dddddd;
  --line-strong: #cccccc;

  /* Status colours */
  --ok:            #00a65a;
  --ok-bg:         #dff0d8;
  --ok-border:     #d6e9c6;
  --ok-text:       #3c763d;
  --warn:          #f39c12;
  --warn-bg:       #fcf8e3;
  --warn-border:   #faebcc;
  --warn-text:     #8a6d3b;
  --danger:        #dd4b39;
  --danger-bg:     #f2dede;
  --danger-border: #ebccd1;
  --danger-text:   #a94442;
  --info:          #3c8dbc;
  --info-bg:       #d9edf7;
  --info-border:   #bce8f1;
  --info-text:     #31708f;

  /* Geometry */
  --radius:    6px;
  --radius-lg: 8px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.07);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.10);
  --shadow:    0 2px 8px rgba(0,0,0,0.12);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
  --shadow-soft: var(--shadow-sm);

  /* Legacy aliases for JS-generated HTML */
  --brand:       var(--primary);
  --brand-dark:  var(--primary-dark);
  --panel:       var(--panel-bg);
  --panel-soft:  var(--panel-header);
  --panel-strong:#eeeeee;
  --gold:        #c09853;
  --accent:      var(--ok);
  --slate-900:   var(--sidebar-bg);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { min-height: 100%; background: var(--content-bg); }

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: "Source Sans Pro", "Segoe UI", system-ui, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

.app-shell { min-height: 100vh; }

/* ── Login ────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  background: var(--panel-bg);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: 56px 48px;
}

.login-visual {
  background:
    linear-gradient(160deg, rgba(34,45,50,0.65) 0%, rgba(20,28,34,0.8) 100%),
    url("https://images.unsplash.com/photo-1497366216548-37526070297c?auto=format&fit=crop&w=1600&q=80")
    center / cover no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 40px 44px;
}

.login-visual-caption { max-width: 400px; }
.login-visual-caption h2 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
}
.login-visual-caption p {
  margin: 0;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  line-height: 1.65;
}

/* Brand */
.brand-lockup { display: flex; align-items: center; gap: 10px; }
.brand-lockup > div > span {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.brand-lockup small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.login-panel h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}
.login-panel p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }

/* Alert strips */
.setup-warning, .phi-warning {
  border-left: 4px solid var(--warn);
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.5;
}
.phi-warning {
  border-left-color: var(--info);
  background: var(--info-bg);
  color: var(--info-text);
  margin: 0 0 16px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.button-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  cursor: pointer;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.btn:hover {
  background: var(--primary-hover);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}
.btn:active { filter: brightness(0.94); box-shadow: none; }

.btn i { font-size: 15px; line-height: 1; }

.btn.secondary {
  background: #fff;
  color: #555;
  border-color: #ccc;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.btn.secondary:hover { background: #f5f5f5; border-color: #bbb; color: #333; }

.btn.ghost {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
  box-shadow: none;
}
.btn.ghost:hover { background: var(--primary-faint); }

.btn.danger { background: var(--danger); border-color: #c9302c; }
.btn.danger:hover { background: #c9302c; }

.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #008a4b; }

.btn.small {
  min-height: 28px;
  padding: 3px 10px;
  font-size: 12.5px;
  gap: 5px;
}
.btn.small i { font-size: 13px; }

/* ── App Frame & Header ───────────────────────────────────── */
.app-frame {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0;
  height: 50px;
  background: var(--sidebar-darker);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 0;
  flex-shrink: 0;
}

/* Brand section */
.app-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  width: 230px;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.06);
  height: 100%;
}

.app-header-brand .brand-mark {
  width: 30px;
  height: 30px;
  font-size: 12px;
  flex-shrink: 0;
}

.app-header-brand-text span {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.app-header-brand-text small {
  font-size: 10.5px;
  color: var(--sidebar-text);
  font-weight: 400;
}

.mobile-menu-btn {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 20px;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: var(--radius);
  line-height: 1;
}
.mobile-menu-btn:hover { color: #fff; background: var(--sidebar-hover-bg); }

/* Quick actions */
.app-header-quick-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 12px;
  flex: 1;
  height: 100%;
}

.header-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  height: 32px;
}
.header-action-btn i { font-size: 15px; line-height: 1; }
.header-action-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-decoration: none;
}
.header-action-btn:first-child {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
.header-action-btn:first-child:hover {
  background: var(--primary-hover);
}

/* Right section */
.app-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 100%;
  border-left: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.header-demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(243,156,18,0.18);
  color: #f39c12;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid rgba(243,156,18,0.3);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.header-user-name {
  font-size: 13px;
  color: var(--sidebar-text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-signout-btn {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 17px;
  padding: 5px 7px;
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
  display: grid;
  place-items: center;
}
.header-signout-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ── Layout ───────────────────────────────────────────────── */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  min-height: 0;          /* fills .layout row, not full vh */
  position: relative;
}

/* Section labels */
.nav-section-label {
  padding: 14px 16px 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-section-lbl);
  user-select: none;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  transition: background 0.1s, color 0.1s;
  border-left: 3px solid transparent;
  line-height: 1.4;
}
.nav-link i {
  font-size: 16px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.75;
}
.nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}
.nav-link:hover i { opacity: 1; }
.nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 600;
  border-left-color: var(--sidebar-active-bar);
}
.nav-link.active i { opacity: 1; color: var(--sidebar-active-bar); }

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 14px 16px;
  display: grid;
  gap: 6px;
}
.sidebar-footer .eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--sidebar-section-lbl);
}
.sidebar-footer strong {
  display: block;
  color: #ccc;
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.sidebar-footer .copyright {
  display: block;
  font-size: 10px;
  color: rgba(255,255,255,0.28);
  line-height: 1.4;
  margin-top: 2px;
}
.sidebar-footer .btn.secondary {
  background: rgba(255,255,255,0.07);
  color: var(--sidebar-text);
  border-color: transparent;
  font-size: 12.5px;
  box-shadow: none;
}
.sidebar-footer .btn.secondary:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.mobile-menu { display: none; margin-left: auto; }

/* ── Main & page body ─────────────────────────────────────── */
.main {
  background: var(--content-bg);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* page-body wraps all JS-rendered page content */
.page-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Topbar — full-width white bar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--line);
}

.page-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.page-title p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

/* Content below topbar */
.page-body > *:not(.topbar) {
  margin-left: 20px;
  margin-right: 20px;
}
.page-body > .topbar + * { margin-top: 20px; }
.page-body > * + *:not(.topbar) { margin-top: 16px; }
.page-body::after { content: ''; display: block; height: 28px; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
}

.stat {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: stretch;
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.stat:hover { box-shadow: var(--shadow-sm); }

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  background: var(--primary);
  color: rgba(255,255,255,0.75);
  font-size: 34px;
  flex-shrink: 0;
}

.stat-body {
  padding: 13px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  flex: 1;
}

.stat strong {
  display: block;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.stat span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}

/* Colour variants */
.stat.stat-ok   .stat-icon { background: var(--ok); }
.stat.stat-warn .stat-icon { background: var(--warn); }
.stat.stat-danger .stat-icon { background: var(--danger); }

/* ── Panels / Boxes ───────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.panel.full { grid-column: 1 / -1; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-header);
  border-radius: var(--radius) var(--radius) 0 0;
}
.panel h2, .panel h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

/* Panel body spacing */
.panel > *:not(.panel-header):not(.table-wrap):not(#assetTableSlot) {
  padding: 14px 16px;
}
.panel > .panel-header + .table-wrap,
.panel > .panel-header + #assetTableSlot { padding: 0; }

.table-panel { padding: 0; overflow: hidden; }
.table-panel .toolbar {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-header);
}

.muted { color: var(--muted); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; background: var(--panel-bg); }

table { width: 100%; border-collapse: collapse; min-width: 780px; }

th, td {
  text-align: left;
  padding: 8px 13px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 13.5px;
  line-height: 1.45;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f4f4;
  color: #555;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 2px solid var(--line-strong);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover { background: #f9f9f9; }
tbody tr:last-child td { border-bottom: none; }

.data-table td:first-child a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.data-table td:first-child a:hover { text-decoration: underline; }

.row-actions {
  white-space: nowrap;
  display: flex;
  gap: 5px;
  align-items: center;
}

/* ── Toolbar ──────────────────────────────────────────────── */
.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(140px, 210px);
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

/* ── Scanner Panel ────────────────────────────────────────── */
.scanner-panel {
  display: grid;
  grid-template-columns: minmax(200px, 0.75fr) minmax(300px, 1.25fr);
  gap: 18px;
  align-items: start;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 0;
}
.scanner-panel-hero { background: var(--primary-faint); border-left-color: var(--primary); }

.scanner-panel h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }
.scanner-panel p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.scanner-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

#quickWorkflowSlot { grid-column: 1 / -1; }
#cameraScannerSlot { grid-column: 1 / -1; }

.scanner-controls { display: grid; gap: 8px; }
.scanner-actions { justify-content: flex-end; }

.camera-scanner {
  display: grid;
  grid-template-columns: minmax(180px, 0.5fr) 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
}
.camera-scanner video {
  width: 100%;
  max-height: 240px;
  border-radius: var(--radius);
  background: #111;
}

.quick-workflow-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow-xs);
  display: grid;
  gap: 12px;
}
.quick-workflow-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.quick-workflow-summary h3 { margin: 0; font-size: 15px; font-weight: 700; }
.quick-workflow-summary p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

/* ── Eyebrow ──────────────────────────────────────────────── */
.eyebrow {
  display: inline-block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  background: #d2d6de;
  color: #555;
  white-space: nowrap;
  line-height: 1.6;
  letter-spacing: 0.01em;
}
.badge.ok    { background: var(--ok);     color: #fff; }
.badge.warn  { background: var(--warn);   color: #fff; }
.badge.danger{ background: var(--danger); color: #fff; }

.date-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.date-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f5f5f5;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
}

.date-badge span {
  color: var(--muted);
  font-weight: 700;
}

.date-badge strong {
  color: var(--ink);
  font-weight: 700;
}

.date-badge em {
  font-style: normal;
  color: var(--muted);
}

.date-badge.ok {
  border-color: var(--ok-border);
  background: var(--ok-bg);
  color: var(--ok-text);
}

.date-badge.warn {
  border-color: var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-text);
}

.date-badge.danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.date-badge.ok strong,
.date-badge.ok span,
.date-badge.ok em {
  color: var(--ok-text);
}

.date-badge.warn strong,
.date-badge.warn span,
.date-badge.warn em {
  color: var(--warn-text);
}

.date-badge.danger strong,
.date-badge.danger span,
.date-badge.danger em {
  color: var(--danger-text);
}

.date-badge.empty-date strong {
  color: var(--muted);
}

.turn-in-list {
  display: grid;
  gap: 8px;
}

.turn-in-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafafa;
}

.turn-in-item strong {
  display: block;
  color: var(--ink);
}

.turn-in-item p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.field { display: grid; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field small { color: var(--muted); font-size: 12px; }

label { font-size: 13.5px; font-weight: 600; color: var(--ink); }

input, select, textarea {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: var(--radius);
  padding: 7px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  transition: border-color 0.12s, box-shadow 0.12s;
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.06);
  line-height: 1.42857143;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #66afe9;
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),
              0 0 0 3px rgba(102,175,233,0.22);
}
input::placeholder { color: #bbb; }
textarea { resize: vertical; min-height: 90px; }

.switch-field {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
  min-height: 36px;
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.06);
  cursor: pointer;
}
.switch-field input { width: auto; box-shadow: none; cursor: pointer; }
.switch-field.full { grid-column: 1 / -1; }

/* ── Empty State ──────────────────────────────────────────── */
.empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #ccc;
  border-radius: var(--radius);
  background: #fafafa;
  font-size: 13.5px;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--sidebar-bg);
  box-shadow: 0 4px 14px rgba(0,0,0,0.22);
  z-index: 100;
  font-size: 13.5px;
  animation: toastIn 0.18s ease;
}
.toast.error { background: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.48);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  width: min(800px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
}

/* ── Activity / Audit ─────────────────────────────────────── */
.activity-list { display: grid; gap: 8px; }
.activity-item {
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafafa;
  font-size: 13.5px;
  transition: background 0.1s;
}
.activity-item:hover { background: #f5f5f5; }
.ticket-card-link > a {
  display: block;
  color: inherit;
  text-decoration: none;
}
.ticket-card-link > a:hover strong { color: var(--primary); }

.split-item {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
}
.split-item p { margin: 3px 0 5px; color: var(--muted); font-size: 13px; }

.badge-row { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; margin-top: 5px; }

/* ── Tickets ───────────────────────────────────────────────── */
.ticket-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 16px;
  align-items: start;
}
.ticket-main,
.ticket-sidebar {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.ticket-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow-xs);
}
.ticket-hero h2 {
  margin: 2px 0 6px;
  font-size: 20px;
  line-height: 1.2;
  color: var(--ink);
}
.ticket-hero p {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
}
.ticket-hero-badges {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.ticket-thread {
  display: grid;
  gap: 10px;
}
.ticket-message {
  max-width: min(760px, 100%);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow-xs);
}
.ticket-message.mine {
  margin-left: auto;
  border-color: var(--info-border);
  background: var(--primary-faint);
}
.ticket-message.admin-note {
  border-left: 4px solid var(--primary);
}
.ticket-message-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12.5px;
}
.ticket-message-meta strong {
  color: var(--ink);
  font-size: 13px;
}
.ticket-message p {
  margin: 0;
  white-space: pre-wrap;
}
.ticket-reply-box {
  display: grid;
  gap: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow-xs);
}
.ticket-file-list {
  display: grid;
  gap: 8px;
}
.ticket-file-list a,
.ticket-inline-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f7f7;
  font-size: 12.5px;
  font-weight: 600;
}

/* ── Asset Cards ──────────────────────────────────────────── */
.asset-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.asset-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.12s;
}
.asset-card:hover { box-shadow: var(--shadow-sm); }
.asset-card h3 { margin: 1px 0 3px; font-size: 13.5px; font-weight: 700; }
.asset-card p { margin: 0 0 6px; color: var(--muted); font-size: 12px; }

.asset-thumb, .asset-hero-image {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f4f4f4;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #aaa;
  font-size: 10px;
  font-weight: 700;
}
.asset-thumb { width: 56px; height: 56px; }
.asset-thumb img, .asset-hero-image img { width: 100%; height: 100%; object-fit: cover; }

/* ── Asset Detail ─────────────────────────────────────────── */
.asset-detail-hero {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow-xs);
}
.asset-hero-image { min-height: 170px; border-radius: var(--radius); }
.asset-hero-main h2 { margin: 6px 0 4px; font-size: 20px; font-weight: 700; }
.asset-hero-main p { color: var(--muted); margin: 0 0 8px; }

.tabs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.detail-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.detail-item {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafafa;
}
.detail-item span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 2px;
}
.detail-item strong { display: block; font-size: 13.5px; color: var(--ink); }

/* ── Asset Form ───────────────────────────────────────────── */
.asset-form-page { display: grid; gap: 14px; }

.form-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.form-section-header {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-header);
}
.form-section-header h2 { margin: 0; font-size: 14.5px; font-weight: 700; }
.form-section-header p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.form-section .form-grid { padding: 16px; }

.status-strip {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-header);
  font-size: 13.5px;
}

.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 16px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.97);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  z-index: 5;
  margin-top: 4px;
}

.inset-panel { margin-top: 14px; box-shadow: none; }

/* ── Catalog / Settings ───────────────────────────────────── */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.catalog-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
}
.catalog-panel h3 { margin: 0 0 10px; font-size: 14px; font-weight: 700; }
.catalogForm, .catalogEdit {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
  align-items: center;
}
.catalogEdit { grid-template-columns: 1fr auto auto; }
.catalog-list { display: grid; gap: 6px; margin-top: 10px; }
.mini-check {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 13.5px;
}
.mini-check input { width: auto; box-shadow: none; }

/* ── User management ─────────────────────────────────────── */
.user-avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.user-role-select {
  width: auto;
  min-width: 110px;
  padding: 4px 8px;
  font-size: 12.5px;
  box-shadow: none;
  height: 28px;
}

/* ── Print ────────────────────────────────────────────────── */
.print-document { display: none; }
@media print {
  body > *:not(.print-document) { display: none !important; }
  .print-document { display: block; padding: 24px; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 980px) {
  .login-screen, .layout { grid-template-columns: 1fr; }

  .login-visual {
    min-height: 180px;
    order: -1;
    justify-content: flex-end;
    padding: 20px 24px;
  }

  .app-header-brand { width: auto; border-right: none; }
  .app-header-quick-actions .header-action-btn span { display: none; }
  .app-header-quick-actions .header-action-btn { padding: 5px 9px; gap: 0; }
  .mobile-menu-btn { display: grid; }

  .sidebar {
    position: sticky;
    top: 50px;   /* below the fixed header */
    z-index: 20;
    min-height: auto;
  }
  .sidebar.collapsed .nav-group,
  .sidebar.collapsed .sidebar-footer,
  .sidebar.collapsed .nav-section-label { display: none; }
  .mobile-menu { display: inline-flex; }

  .stats-grid,
  .grid,
  .form-grid,
  .tabs-grid,
  .asset-detail-hero,
  .detail-grid,
  .detail-grid.compact,
  .toolbar,
  .scanner-panel,
  .scanner-form,
  .camera-scanner,
  .ticket-page,
  .catalog-grid { grid-template-columns: 1fr; }

  #quickWorkflowSlot { grid-column: auto; }
  .quick-workflow-summary { flex-direction: column; }
  .ticket-hero { flex-direction: column; }
  .ticket-hero-badges { justify-content: flex-start; }
  .scanner-actions { justify-content: stretch; }
  .catalogEdit { grid-template-columns: 1fr; }

  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .page-body > *:not(.topbar) { margin-left: 14px; margin-right: 14px; }
}

@media (max-width: 680px) {
  .app-header-quick-actions { display: none; }
  .header-user-name { display: none; }
}

@media (max-width: 560px) {
  .login-panel { padding: 28px 20px 36px; }
  .login-panel h1 { font-size: 20px; }

  .button-row { flex-direction: column; align-items: stretch; }
  .button-row .btn { width: 100%; justify-content: center; }

  .status-strip, .split-item, .turn-in-item { flex-direction: column; align-items: stretch; gap: 8px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
