/* Design tokens ported 1:1 from the Insol Inventory design file
   (Insol Inventory.dc.html -> tokens(theme)). */
:root {
  --bg: #f3f5fa; --surface: #ffffff; --surface-alt: #f7f9fc;
  --border: #e2e6ee; --border-strong: #c9d0dd;
  --text: #161a23; --text-muted: #69707f;
  --accent: #2f5fe0; --accent-hover: #2447b8; --accent-soft: #eaf0fe;
  --success: #1f9d55; --success-soft: #e7f7ee;
  --warning: #a8710a; --warning-soft: #fdf3e0;
  --danger: #c62d31; --danger-soft: #fbe9e9;
  --muted: #69707f; --muted-soft: #eef0f4;
  --shadow: 0 1px 2px rgba(20,25,40,.06), 0 6px 16px rgba(20,25,40,.06);
  --font: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #10131a; --surface: #171b25; --surface-alt: #1d2230;
  --border: #2a3040; --border-strong: #3a4257;
  --text: #eef1f7; --text-muted: #93a0b8;
  --accent: #5b82ff; --accent-hover: #7996ff; --accent-soft: #1c2c55;
  --success: #3ecf7e; --success-soft: #123324;
  --warning: #e0a934; --warning-soft: #3a2c10;
  --danger: #ef5350; --danger-soft: #3a1717;
  --muted: #93a0b8; --muted-soft: #232838;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 24px rgba(0,0,0,.4);
}

@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes cardEnter { from{ opacity:0; transform:translateY(10px); } to{ opacity:1; transform:translateY(0); } }
@keyframes screenFadeThrough { from{ opacity:0; transform:translateY(8px) scale(.99); } to{ opacity:1; transform:none; } }
@keyframes dialogIn { from{ opacity:0; transform:scale(.95); } to{ opacity:1; transform:scale(1); } }
@keyframes overlayFadeIn { from{ opacity:0; } to{ opacity:1; } }
@keyframes drawerSlideIn { from{ opacity:0; transform:translateX(-16px); } to{ opacity:1; transform:translateX(0); } }
@keyframes fabPulse { 0%,100%{ box-shadow:0 0 0 0 rgba(47,95,224,.35); } 50%{ box-shadow:0 0 0 10px rgba(47,95,224,0); } }
@keyframes themeRevealGrow { from{ width:0; height:0; } to{ width:6000px; height:6000px; } }
@media (prefers-reduced-motion: reduce) { *{ animation-duration:.001ms !important; transition-duration:.001ms !important; } }

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* --- Layout --- */
header { background: var(--surface); border-bottom: 1px solid var(--border);
         display: flex; align-items: center; gap: 10px; padding: 0 24px; height: 56px; flex-shrink: 0; }
header .spacer { flex: 1; }
main { margin: 24px 0; padding: 0 16px 60px; transition: opacity 200ms ease-out; }
main.screen-enter { animation: screenFadeThrough 420ms ease-out both; }

/* --- Cards & tables --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
        padding: 20px; margin-bottom: 16px; animation: cardEnter 450ms ease-out both; }
.row-enter { animation: cardEnter 450ms ease-out both; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase;
     letter-spacing: .04em; background: var(--surface-alt); white-space: nowrap; }
td { font-size: 13.5px; }
td.mono { font-family: var(--mono); font-size: 13px; }
td.muted { color: var(--text-muted); }
td.chevron { text-align: center; color: var(--text-muted); width: 24px; padding: 9px 8px; }
tr:hover td { background: var(--surface-alt); }
tr.clickable { cursor: pointer; }
.table-wrap, .tableCard { background: var(--surface); border: 1px solid var(--border);
        border-radius: 10px; overflow: auto; }
.table-wrap table, .tableCard table { border: none; }
.tableFooter { font-size: 12px; color: var(--text-muted); margin-top: 10px; }

/* --- Forms --- */
label { display: block; margin: 10px 0 4px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border);
        border-radius: 8px; font: inherit; font-size: 14px; background: var(--surface-alt); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; border: none; border-radius: 0; background: none; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 180px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase;
        letter-spacing: .03em; margin: 18px 0 12px; }
.section-title:first-child { margin-top: 0; }

/* --- Buttons --- */
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
       background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600;
       transition: transform 150ms ease-out; }
.btn:hover { border-color: var(--accent); color: var(--accent); transform: scale(1.045); }
.btn:active { transform: scale(.92); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); color: #fff; border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { background: var(--muted-soft); color: var(--text-muted); cursor: not-allowed; border-color: var(--border); }
.btn:disabled:hover { transform: none; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* --- Login --- */
.login-wrap { min-height: calc(100vh - 44px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { position: relative; width: 380px; max-width: 100%; background: var(--surface);
        border: 1px solid var(--border); border-radius: 14px; padding: 36px 32px; box-shadow: var(--shadow); }
.login-top-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.5; }

/* --- Filters --- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; align-items: flex-start; }
.filters > select, .filters > input { width: auto; min-width: 150px; flex: 1; }

/* --- Badges --- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 5px; font-size: 12px;
         font-weight: 600; white-space: nowrap; }
.badge.b-success { color: var(--success); background: var(--success-soft); }
.badge.b-info { color: var(--accent); background: var(--accent-soft); }
.badge.b-warning { color: var(--warning); background: var(--warning-soft); }
.badge.b-danger { color: var(--danger); background: var(--danger-soft); }
.badge.b-muted { color: var(--text-muted); background: var(--muted-soft); }
.muted { color: var(--text-muted); }
.error { color: var(--danger); margin-top: 8px; font-size: 12.5px; }
.photo-preview { max-width: 240px; max-height: 240px; border-radius: 8px; border: 1px solid var(--border); }

dialog { border: 1px solid var(--border); border-radius: 12px; padding: 24px; max-width: 460px;
         width: 92%; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
         animation: dialogIn 240ms cubic-bezier(.2,.9,.3,1.1) both; }
dialog::backdrop { background: rgba(0,0,0,.5); animation: overlayFadeIn 200ms ease-out both; }
.modal-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header-row h3 { margin: 0; font-size: 17px; }

/* --- Logo --- */
.logo-chip { background: #fff; border-radius: 999px; padding: 5px 12px; display: inline-flex;
             align-items: center; gap: 6px; border: 1px solid var(--border); }
.logo-chip img { height: 22px; display: block; }

/* --- Theme switch (icon button, matches design's iconBtn) --- */
.theme-btn { flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px;
        border: 1px solid var(--border); background: var(--surface-alt); cursor: pointer;
        font-size: 14px; display: flex; align-items: center; justify-content: center;
        transition: transform 150ms ease-out; }
.theme-btn:hover { transform: scale(1.045); }
.theme-btn:active { transform: scale(.92); }
.theme-btn .theme-icon-sun { color: #EDCC0B; }
.theme-btn img { width: 18px; height: 18px; object-fit: contain; display: block; }
.theme-btn-text { border: none; background: transparent; color: var(--text-muted); font: inherit;
        font-size: 12px; cursor: pointer; transition: transform 150ms ease-out; }
.theme-btn-text:hover { transform: scale(1.045); }
.theme-btn-text:active { transform: scale(.92); }
.theme-reveal { position: fixed; border-radius: 50%; transform: translate(-50%,-50%);
        background: transparent; pointer-events: none; z-index: 99999;
        animation: themeRevealGrow 1100ms ease-out forwards; }

/* --- Columns popover (anchored under the "Columns" button, not a modal) --- */
.col-menu-wrap { position: relative; display: inline-block; }
.col-menu-backdrop { position: fixed; inset: 0; z-index: 9; }
.col-menu { position: absolute; top: 110%; right: 0; background: var(--surface);
        border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 10px;
        z-index: 10; min-width: 170px; transform-origin: top right;
        animation: dialogIn 180ms ease-out both; }
.col-menu-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 4px; cursor: pointer; }

/* --- Label print: A4 sheet grid + code-type radios --- */
.radio-row { display: flex; gap: 20px; margin-bottom: 14px; }
.radio-label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.label-a4-outer { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 8px 0 4px; }
.label-a4-sheet { display: grid; gap: 1px; background: var(--border-strong); width: 260px; max-width: 100%;
        aspect-ratio: 210 / 297; border: 1px solid var(--border-strong); box-shadow: var(--shadow);
        border-radius: 2px; overflow: hidden; }
.label-a4-cell { cursor: pointer; min-width: 0; min-height: 0; background: #fff; }
.label-a4-cell.used { background: var(--muted-soft); }
.label-a4-cell.start { background: var(--accent); }
.label-a4-caption { font-size: 12.5px; color: var(--text-muted); text-align: center; }

/* --- Scanner --- */
#scan-video { width: 100%; max-height: 60vh; border-radius: 8px; background: #000; }
.mobile-only { display: none; }

/* Dictionary tab strip: base layout (must precede the mobile @media block —
   equal-specificity rules resolve by source order, so an unconditional rule
   declared AFTER a @media block would silently cancel its override). */
.dict-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.dict-tabs .btn { background: var(--surface-alt); border-color: transparent; }
.dict-tabs .btn.primary { background: var(--accent); color: #fff; }

/* Nav lives only in the burger panel now — header stays logo+trigger only,
   on every viewport width. */
.burger-nav { display: flex; flex-direction: column; gap: 2px; }

/* --- Burger menu: trigger on the left, panel slides in from the left --- */
.burger-btn { display: block; background: none; border: 1px solid var(--border); border-radius: 8px;
              width: 36px; height: 36px; font-size: 16px; line-height: 1; color: var(--text);
              flex-shrink: 0; transition: transform 150ms ease-out; }
.burger-btn:hover { transform: scale(1.045); }
.burger-btn:active { transform: scale(.92); }
.burger-panel { position: fixed; inset: 0 auto 0 0; width: min(300px, 85vw); z-index: 50;
                background: var(--surface); box-shadow: 4px 0 24px rgba(0,0,0,.2); padding: 20px;
                transform: translateX(-100%); transition: transform .28s ease-out;
                display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.burger-panel.open { transform: translateX(0); }
.burger-backdrop { position: fixed; inset: 0; z-index: 49; background: rgba(0,0,0,.45);
                   opacity: 0; pointer-events: none; transition: opacity .26s; }
.burger-backdrop.open { opacity: 1; pointer-events: auto; }
.burger-header { display: flex; align-items: center; gap: 12px; padding: 10px; margin: -10px -10px 8px -10px;
                 border-bottom: 1px solid var(--border); border-radius: 10px;
                 color: inherit; text-decoration: none; transition: background 150ms ease-out; }
.burger-header:hover { background: var(--bg); }
.burger-header.active { background: var(--accent-soft); }
.burger-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft);
                 background-size: cover; background-position: center;
                 color: var(--accent); display: flex; align-items: center; justify-content: center;
                 font-size: 13px; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.burger-user-name { font-size: 13px; font-weight: 600; }
.burger-user-role { font-size: 12px; color: var(--text-muted); }
.burger-nav a { display: block; padding: 12px 14px; border-radius: 8px; color: var(--text);
                text-align: left; font-size: 15px; font-weight: 500; }
.burger-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.burger-footer { margin-top: auto; display: flex; justify-content: space-between; align-items: center;
                 padding-top: 16px; border-top: 1px solid var(--border); }

/* --- Pagination: numbered with ellipsis --- */
.pager-row { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pager-num { min-width: 32px; height: 32px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--border);
        background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600;
        transition: transform 150ms ease-out; }
.pager-num:hover { border-color: var(--accent); color: var(--accent); transform: scale(1.045); }
.pager-num:active { transform: scale(.92); }
.pager-num.active { border-color: var(--accent); background: var(--accent); color: #fff; }
.pager-ellipsis { min-width: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* --- Empty state --- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center;
        padding: 60px 20px; gap: 12px; text-align: center; }
.empty-icon { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--border);
        display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 20px; }
.empty-title { font-size: 15px; font-weight: 600; }
.empty-sub { font-size: 13px; color: var(--text-muted); max-width: 320px; }

/* --- Truncated change cell (audit narrow) --- */
.change-stack { display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.change-old { font-size: 12.5px; color: var(--text-muted); text-decoration: line-through; }
.change-new { font-size: 13.5px; font-weight: 500; }
.trunc-cell { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.trunc-cell.expanded { max-width: 280px; white-space: normal; word-break: break-word; }

/* --- Profile screen --- */
.profile-grid { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.photo-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px;
        display: flex; flex-direction: column; align-items: center; gap: 12px; animation: cardEnter 450ms ease-out both; }
.photo-circle { width: 120px; height: 120px; border-radius: 50%; background: var(--surface-alt);
        border: 1px solid var(--border); background-size: cover; background-position: center;
        display: flex; align-items: center; justify-content: center; font-size: 36px; font-weight: 700;
        color: var(--accent); overflow: hidden; }
.photo-btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* --- FAB row (mobile equipment list) --- */
.fab-row { position: fixed; bottom: 0; left: 0; right: 0; gap: 10px; padding: 14px;
        background: var(--surface); border-top: 1px solid var(--border); z-index: 15; }
.fab-scan { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
        padding: 14px 0; border-radius: 12px; border: none; background: var(--accent); color: #fff;
        font-size: 15px; font-weight: 700; animation: fabPulse 2.4s ease-in-out infinite; }
.fab-add { flex: 1; display: flex; align-items: center; justify-content: center; padding: 14px 0;
        border-radius: 12px; border: 1.5px solid var(--accent);
        background: transparent; color: var(--accent); font-size: 15px; font-weight: 700; }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }

/* --- Mobile layout --- */
@media (max-width: 760px) {
  .mobile-only { display: flex; }
  .desktop-only { display: none !important; }
  header { padding: 0 12px; gap: 8px; }
  .logo-chip img { height: 18px; }
  .actions { flex-wrap: wrap; }
  .actions .btn { flex: 1 1 auto; text-align: center; min-width: 0; }
  .row { flex-direction: column; }
  .row > div { min-width: 100%; }
  .profile-grid { grid-template-columns: 1fr; }
  table { font-size: 13px; }
  dialog { max-width: 94vw; padding: 18px; }
  main { padding-bottom: 90px; } /* clears the fixed FAB row */
}

@media (max-width: 760px) {
  th, td { padding: 7px 10px; font-size: 13px; }
  main { margin: 16px 0; }
}
