/* ==========================================================================
   HomeCMDB – teal/blue infographic theme, light + dark
   ========================================================================== */
:root {
  --teal: #2b8a9d; --teal-600: #23748a; --accent: #d6336c; --ink: #1f5568; --teal-50: #e6f7f7;
  --blue: #2563eb; --blue-600: #1d4ed8; --cyan: #06b6d4; --navy: #0b2a3c;
  --amber: #f59e0b; --red: #e11d48; --green: #10b981; --violet: #7c3aed; --orange: #ea580c;
  --grad: linear-gradient(135deg, #4f9db0 0%, #2f7f94 50%, #245f78 100%);
  --grad-soft: linear-gradient(135deg, rgba(79,157,176,.16), rgba(36,95,120,.10));

  --bg: #e3eff4; --bg-2: #d6e8f0; --surface: #ffffff; --surface-2: #f6fafb; --surface-3: #edf3f6;
  --text: #0f2733; --text-2: #48616e; --text-3: #7d93a0; --border: #d8e4ea; --border-2: #c4d4dc;
  --sidebar: linear-gradient(180deg, #3f8397 0%, #33738a 55%, #2a6379 100%);
  --sidebar-text: #e3f2f6; --sidebar-active: rgba(255,255,255,.18);
  --row-hover: #f0f8fa; --row-sel: #d8f1f1; --row-sel-border: #5cc9c8;
  --shadow: 0 1px 2px rgba(15,39,51,.06), 0 6px 20px rgba(15,39,51,.06);
  --shadow-lg: 0 18px 50px rgba(15,39,51,.18);
  --focus: 0 0 0 3px rgba(43,138,157,.35);
  --radius: 18px; --radius-sm: 9px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #071820; --bg-2: #0a202b; --surface: #0e2530; --surface-2: #112c38; --surface-3: #15333f;
    --text: #e3f1f5; --text-2: #a3bcc6; --text-3: #6f8b97; --border: #1c3e4b; --border-2: #275060;
    --sidebar: linear-gradient(180deg, #05141b 0%, #072230 60%, #0a2f3b 100%);
    --sidebar-text: #a9c8d2; --sidebar-active: rgba(45,212,191,.14);
    --row-hover: #132f3b; --row-sel: #134a4f; --row-sel-border: #5fb3c6; --teal-50: #0f3a3d; --ink: #e3f1f5; --teal: #5fb3c6;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); --shadow-lg: 0 20px 60px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #071820; --bg-2: #0a202b; --surface: #0e2530; --surface-2: #112c38; --surface-3: #15333f;
  --text: #e3f1f5; --text-2: #a3bcc6; --text-3: #6f8b97; --border: #1c3e4b; --border-2: #275060;
  --sidebar: linear-gradient(180deg, #05141b 0%, #072230 60%, #0a2f3b 100%);
  --sidebar-text: #a9c8d2; --sidebar-active: rgba(45,212,191,.14);
  --row-hover: #132f3b; --row-sel: #134a4f; --row-sel-border: #5fb3c6; --teal-50: #0f3a3d; --ink: #e3f1f5; --teal: #5fb3c6;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); --shadow-lg: 0 20px 60px rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg); background-image: radial-gradient(1200px 600px at 85% -10%, var(--bg-2), transparent 70%); background-attachment: fixed; -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
.muted { color: var(--text-2); } .small { font-size: .85em; } .tiny { font-size: .75em; color: var(--text-3); }
.ico { flex: none; vertical-align: -3px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
.nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text); padding: 18px 14px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 750; font-size: 1.12rem; padding: 4px 8px 16px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(14,165,164,.45); color: #fff; }
.brand small { display: block; font-size: .7rem; font-weight: 500; opacity: .65; letter-spacing: .04em; text-transform: uppercase; }
.nav-sec { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; opacity: .55; padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; color: var(--sidebar-text);
  font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav .count { margin-left: auto; font-size: .72rem; background: rgba(255,255,255,.12); padding: 1px 7px; border-radius: 99px; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; font-size: .75rem; opacity: .6; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px; padding: 12px 26px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.gsearch { position: relative; flex: 1; max-width: 560px; }
.gsearch input[type=search] { width: 100%; padding: 10px 14px 10px 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.gsearch input:focus { outline: none; box-shadow: var(--focus); border-color: var(--teal); }
.gsearch > .ico { position: absolute; left: 13px; top: 11px; color: var(--text-3); }
.gsearch kbd { position: absolute; right: 10px; top: 9px; }
.typeahead { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 60; }
.typeahead a { display: flex; gap: 10px; align-items: center; padding: 9px 14px; color: var(--text); }
.typeahead a:hover, .typeahead a.sel { background: var(--row-hover); text-decoration: none; }
kbd { font: 11px ui-monospace, monospace; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); }
.topbar .spacer { flex: 1; }
.iconbtn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.iconbtn:hover { color: var(--teal); border-color: var(--teal); }
.menu-wrap { position: relative; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 70; }
.dropdown .item, .dropdown button.item { display: flex; width: 100%; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown .item:hover { background: var(--row-hover); text-decoration: none; }
.dropdown .sep { height: 1px; background: var(--border); margin: 5px 2px; }
.dropdown .head { padding: 8px 10px; font-size: .78rem; color: var(--text-3); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 700; display: grid; place-items: center; border: 0; cursor: pointer; }
.tenant-pill { display: inline-flex; gap: 8px; align-items: center; padding: 7px 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.mobile-only { display: none; }

.content { padding: 24px 26px 60px; max-width: 1600px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 2px 0 0; color: var(--text-2); }
.crumbs { font-size: .82rem; color: var(--text-3); margin-bottom: 4px; }
.crumbs a { color: var(--text-2); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: transform .06s, box-shadow .15s, background .15s; text-decoration: none !important;
}
.btn:hover { border-color: var(--border-2); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 6px 16px rgba(36,95,120,.30); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; border: 0; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 6px 10px; font-size: .85rem; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { font-weight: 600; font-size: .85rem; color: var(--text-2); display: block; margin-bottom: 5px; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: var(--focus); }
input[type=color] { width: 52px; height: 38px; padding: 2px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--teal); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.field-hint { font-size: .78rem; color: var(--text-3); margin-top: 4px; }
.input-group { display: flex; } .input-group input { border-radius: 10px 0 0 10px; } .input-group .addon { padding: 9px 12px; border: 1px solid var(--border); border-left: 0; border-radius: 0 10px 10px 0; background: var(--surface-2); color: var(--text-2); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.kpi > div { min-width: 0; } .kpi .val { overflow-wrap: anywhere; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; flex: 1; display: flex; gap: 9px; align-items: center; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }

/* KPI tiles – infographic style */
.kpi { position: relative; overflow: hidden; display: flex; gap: 14px; align-items: center; }
.kpi .bubble { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: #fff; flex: none; box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.kpi .val { font-size: 1.8rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: var(--ink); }
.kpi .lbl { color: var(--text-2); font-size: .84rem; font-weight: 500; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--grad-soft); }
.b-teal { background: linear-gradient(135deg, #14b8a6, #0d9488); } .b-blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.b-amber { background: linear-gradient(135deg, #fbbf24, #f59e0b); } .b-violet { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.b-rose { background: linear-gradient(135deg, #f06595, #d6336c); } .b-cyan { background: linear-gradient(135deg, #22d3ee, #0891b2); }
.hero {
  background: var(--grad); color: #fff; border-radius: 20px; padding: 24px 28px; position: relative; overflow: hidden; margin-bottom: 18px;
  box-shadow: 0 14px 40px rgba(36,95,120,.28);
}
.hero h1 { color: #fff; } .hero p { opacity: .88; margin: 0; }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.1); }
.hero::before { width: 260px; height: 260px; right: -60px; top: -120px; } .hero::after { width: 160px; height: 160px; right: 180px; bottom: -110px; }
.hero .btn { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.3); position: relative; z-index: 1; }
.hero .btn:hover { background: rgba(255,255,255,.26); }
.hero .btn.white { background: #fff; color: #0b5e6e; border: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; padding: 9px 2px; border-bottom: 1px dashed var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.empty { padding: 22px; text-align: center; color: var(--text-3); }

.cls-dot { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #fff; flex: none; }
.cls-dot.sm { width: 22px; height: 22px; border-radius: 7px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: .76rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.st-in_use { background: #d1fae5; color: #047857; } .st-in_stock { background: #dbeafe; color: #1d4ed8; }
.st-lent_out { background: #fef3c7; color: #b45309; } .st-repair { background: #ffedd5; color: #c2410c; }
.st-missing { background: #ffe4e6; color: #be123c; } .st-retired { background: #e2e8f0; color: #475569; }
.st-disposed { background: #f1f5f9; color: #64748b; text-decoration: line-through; }
:root[data-theme="dark"] .chip[class*="st-"] { filter: saturate(.9) brightness(.9); background-color: color-mix(in srgb, currentColor 18%, transparent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip[class*="st-"] { background-color: color-mix(in srgb, currentColor 18%, transparent); filter: brightness(1.35); } }
:root[data-theme="dark"] .chip[class*="st-"] { filter: brightness(1.35); }
.warn { color: var(--amber); } .bad { color: var(--red); } .good { color: var(--green); }

/* donut + bars */
.donut-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.donut { width: 180px; height: 180px; flex: none; }
.legend { flex: 1; min-width: 180px; }
.legend a { display: flex; align-items: center; gap: 9px; padding: 5px 0; color: var(--text); }
.legend .sw { width: 11px; height: 11px; border-radius: 4px; flex: none; }
.legend .n { margin-left: auto; font-weight: 650; color: var(--text-2); }
.bar { height: 9px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--grad); }
.hbars li { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr 40px; gap: 10px; align-items: center; padding: 6px 0; }

/* ---------- flash ---------- */
.flashes { position: fixed; top: 74px; right: 22px; z-index: 200; display: grid; gap: 8px; max-width: 420px; }
.flash { padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; animation: slidein .25s ease; }
.flash.success { border-left: 4px solid var(--green); } .flash.error { border-left: 4px solid var(--red); }
.flash.warning { border-left: 4px solid var(--amber); } .flash.info { border-left: 4px solid var(--blue); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

/* ---------- grid (data table) ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search { position: relative; flex: 1; min-width: 220px; max-width: 460px; }
.toolbar .search input[type=search] { padding-left: 36px; }
.toolbar .search .ico { position: absolute; left: 11px; top: 11px; color: var(--text-3); }
.toolbar select { width: auto; min-width: 150px; }
.class-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: thin; }
.class-strip a { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); white-space: nowrap; font-weight: 550; }
.class-strip a:hover { text-decoration: none; border-color: var(--teal); }
.class-strip a.active { border-color: var(--teal); box-shadow: var(--focus); }

.dgrid-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 260px); min-height: 300px; position: relative; }
table.dgrid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; user-select: none; }
.dgrid th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); text-align: left; font-weight: 650; color: var(--text-2); padding: 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dgrid th .th-in { display: flex; align-items: center; gap: 6px; padding: 10px 12px; cursor: pointer; position: relative; }
.dgrid th .th-in:hover { color: var(--text); }
.dgrid th .sort { opacity: .35; font-size: .8em; } .dgrid th.sorted .sort { opacity: 1; color: var(--teal); }
.dgrid th .rs { position: absolute; right: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; }
.dgrid th .rs:hover { background: var(--teal); opacity: .4; }
.dgrid tr.filters th { top: 41px; background: var(--surface); padding: 4px 6px 6px; border-bottom: 1px solid var(--border); }
.dgrid tr.filters .fwrap { display: flex; align-items: center; gap: 2px; }
.dgrid tr.filters input { padding: 4px 8px; border-radius: 7px; font-size: .8rem; min-width: 60px; font-weight: 400; }
.dgrid tr.filters .opbtn { border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 2px 4px; border-radius: 6px; font: 600 .72rem ui-monospace, monospace; }
.dgrid tr.filters .opbtn.active { color: #fff; background: var(--teal); }
.dgrid td { padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 380px; }
.dgrid tbody tr { cursor: default; }
.dgrid tbody tr:hover td { background: var(--row-hover); }
.dgrid tbody tr.sel td { background: var(--row-sel); }
.dgrid tbody tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--row-sel-border); }
.dgrid tbody tr.cursor td { outline: 0; }
.dgrid td.c-check, .dgrid th.c-check { width: 38px; text-align: center; padding-left: 10px; padding-right: 4px; }
.dgrid td.c-photo { width: 52px; padding: 4px 8px; }
.dgrid .thumb { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; display: block; background: var(--surface-3); }
.dgrid .thumb.ph { display: grid; place-items: center; color: #fff; }
.dgrid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.dgrid .tag { font-family: ui-monospace, monospace; font-size: .85em; color: var(--text-2); }
.dgrid .lowstock { color: var(--red); font-weight: 700; }
.grid-foot { display: flex; align-items: center; gap: 12px; padding: 10px 4px; color: var(--text-2); flex-wrap: wrap; }
.grid-foot .grow { flex: 1; }
.selbar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 90; display: flex; gap: 8px; align-items: center;
  background: var(--navy); color: #fff; border-radius: 16px; padding: 9px 10px 9px 18px; box-shadow: var(--shadow-lg);
  animation: up .2s ease; max-width: calc(100vw - 24px); overflow-x: auto;
}
.selbar .btn { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.18); }
.selbar .btn:hover { background: rgba(255,255,255,.2); }
.selbar strong { margin-right: 6px; white-space: nowrap; }
@keyframes up { from { transform: translate(-50%, 20px); opacity: 0; } }

.ctxmenu { position: fixed; z-index: 300; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; font-size: .9rem; }
.ctxmenu .item { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--text); }
.ctxmenu .item:hover { background: var(--row-hover); }
.ctxmenu .item.disabled { opacity: .4; pointer-events: none; }
.ctxmenu .item .ico { color: var(--text-3); }
.ctxmenu .sep { height: 1px; background: var(--border); margin: 5px 2px; }
.ctxmenu .head { padding: 6px 10px 4px; font-size: .74rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.ctxmenu .sub { max-height: 260px; overflow: auto; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 250; display: grid; place-items: center; padding: 20px; }
.modal .backdrop { position: absolute; inset: 0; background: rgba(4,20,28,.55); backdrop-filter: blur(3px); }
.modal .dialog { position: relative; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: min(920px, 100%); max-height: calc(100vh - 40px); overflow: auto; border: 1px solid var(--border); }
.modal .dialog.sm { width: min(460px, 100%); }
.modal .d-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal .d-head h2 { margin: 0; flex: 1; }
.modal .d-body { padding: 18px 20px; }
.modal .d-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }

/* ---------- detail ---------- */
.detail-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.detail-head .photo { width: 150px; height: 150px; border-radius: 16px; object-fit: cover; background: var(--surface-3); flex: none; border: 1px solid var(--border); }
.detail-head .photo.ph { display: grid; place-items: center; color: #fff; }
.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 0; }
.kv > div { padding: 8px 0; border-bottom: 1px dashed var(--border); min-width: 0; overflow-wrap: anywhere; }
.kv > div:nth-child(odd) { color: var(--text-2); font-weight: 500; padding-right: 10px; }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--teal); border-bottom-color: var(--teal); }
.tabpane { display: none; } .tabpane.active { display: block; }
.qrbox { width: 140px; padding: 8px; background: #fff; border-radius: 12px; border: 1px solid var(--border); }
.qrbox svg { width: 100%; height: auto; display: block; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery .tile { position: relative; border-radius: 12px; overflow: hidden; background: var(--surface-3); aspect-ratio: 1; border: 1px solid var(--border); }
.gallery .tile img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.gallery .tile .ov { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px; display: flex; gap: 4px; background: linear-gradient(transparent, rgba(0,0,0,.65)); opacity: 0; transition: opacity .15s; }
.gallery .tile:hover .ov { opacity: 1; }
.gallery .tile .ov form { margin: 0; }
.gallery .tile .ov button { background: rgba(255,255,255,.2); border: 0; color: #fff; border-radius: 7px; padding: 4px 7px; cursor: pointer; }
.gallery .tile .star { position: absolute; top: 8px; left: 8px; color: #fbbf24; }
.gallery .tile .cap { position: absolute; left: 8px; right: 8px; bottom: 8px; color: #fff; font-size: .78rem; text-shadow: 0 1px 3px #000; pointer-events: none; }
.dropzone { border: 2px dashed var(--border-2); border-radius: 14px; padding: 22px; text-align: center; color: var(--text-2); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--teal); background: var(--teal-50); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 400; display: grid; place-items: center; }
.lightbox img { max-width: 94vw; max-height: 88vh; border-radius: 8px; }
.lightbox .lb-cap { color: #fff; position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; }
.lightbox .lb-close, .lightbox .lb-prev, .lightbox .lb-next { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 50%; width: 44px; height: 44px; cursor: pointer; font-size: 22px; }
.lightbox .lb-close { top: 18px; right: 18px; } .lightbox .lb-prev { left: 18px; top: 50%; } .lightbox .lb-next { right: 18px; top: 50%; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 14px 12px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); border: 2px solid var(--surface); }
.timeline .when { font-size: .78rem; color: var(--text-3); }
.timeline .diff { font-size: .8rem; color: var(--text-2); }

/* simple tables */
table.plain { width: 100%; border-collapse: collapse; }
table.plain th { text-align: left; font-size: .78rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.plain td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.plain tr:last-child td { border-bottom: 0; }
table.plain tr:hover td { background: var(--row-hover); }

/* scan */
.scanner { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 4/3; max-width: 560px; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 18% 12%; border: 3px solid rgba(45,212,191,.9); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.scanner .laser { position: absolute; left: 14%; right: 14%; height: 2px; background: #2dd4bf; top: 50%; box-shadow: 0 0 12px #2dd4bf; animation: laser 1.8s ease-in-out infinite; }
@keyframes laser { 0%, 100% { top: 22%; } 50% { top: 78%; } }
.scan-result { display: flex; gap: 14px; align-items: center; }
.scan-result img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }
.segmented { display: inline-flex; background: var(--surface-3); border-radius: 12px; padding: 4px; gap: 2px; }
.segmented button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--teal); box-shadow: var(--shadow); }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .art { background: var(--grad); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.auth .art h1 { font-size: 2.3rem; color: #fff; max-width: 480px; }
.auth .art p { opacity: .9; max-width: 460px; font-size: 1.05rem; }
.auth .art ul { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; }
.auth .art li { display: flex; gap: 12px; align-items: center; }
.auth .art li span { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.18); display: grid; place-items: center; }
.auth .art::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(255,255,255,.07); right: -160px; bottom: -160px; }
.auth .panel { display: grid; place-items: center; padding: 30px; }
.auth form { width: min(380px, 100%); display: grid; gap: 14px; }
.auth .prefs { position: absolute; top: 16px; right: 16px; display: flex; gap: 6px; }

/* labels (screen preview) */
.sheet-preview { background: var(--surface-3); padding: 20px; border-radius: 14px; overflow: auto; }

/* responsive */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 150; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 140; }
  .mobile-only { display: inline-grid; }
  .topbar { padding: 10px 14px; } .content { padding: 16px 14px 90px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; } .auth .art { display: none; }
  .tenant-pill span.tn { display: none; }
  .dgrid-wrap { max-height: none; }
  .hide-sm { display: none !important; }
  .fab { position: fixed; right: 18px; bottom: 18px; width: 58px; height: 58px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 24px rgba(14,165,164,.45); z-index: 80; }
}
@media (min-width: 861px) { .fab { display: none; } }
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr 1fr; gap: 10px; } .kpi { padding: 14px; gap: 10px; } .kpi .val { font-size: 1.1rem; } .kpi .bubble { width: 42px; height: 42px; } }

/* touch devices (phones, tablets) */
@media (hover: none), (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }          /* no iOS auto-zoom on focus */
  .btn { min-height: 42px; } .btn.sm { min-height: 38px; padding: 7px 12px; }
  .iconbtn { width: 42px; height: 42px; }
  .dgrid td { padding-top: 11px; padding-bottom: 11px; }
  .dgrid, .dgrid * { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
  .dgrid td.c-check input { width: 22px; height: 22px; }
  .gallery .tile .ov { opacity: 1; }                                 /* no hover on touch */
  .ctxmenu .item { padding: 11px 12px; }
  .dropdown .item, .dropdown button.item { padding: 11px 12px; }
  .dgrid th .rs { width: 14px; }
  .dgrid-wrap { -webkit-overflow-scrolling: touch; }
}
@media (min-width: 861px) and (max-width: 1180px) { .shell { grid-template-columns: 216px 1fr; } .content { padding: 20px; } }

@media print {
  .sidebar, .topbar, .no-print, .flashes, .selbar { display: none !important; }
  .shell { display: block; } .content { padding: 0; max-width: none; }
  body { background: #fff; color: #000; } .card { box-shadow: none; border: 0; padding: 0; }
}
