/* Admin console */
body { background: var(--bg); }

/* ---------- Login ---------- */
.login { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.login-art { background: radial-gradient(1200px 600px at -10% -20%, #14b8a6 0, transparent 60%), linear-gradient(160deg, #0f766e, #134e4a); color: #fff; padding: 40px 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand strong { display: block; font-size: 17px; }
.login-brand small { opacity: .8; }
.login-copy h1 { font-size: 38px; font-weight: 800; letter-spacing: -.02em; line-height: 1.12; }
.login-copy p { margin-top: 14px; opacity: .85; font-size: 15px; max-width: 480px; }
.login-copy ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.login-copy li { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.login-copy li svg.lucide { width: 34px; height: 34px; padding: 8px; background: rgba(255,255,255,.12); border-radius: 10px; }
.login-foot { opacity: .7; }
.login-form-wrap { display: grid; place-items: center; padding: 32px; background: #fff; }
.login-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.login-form h2 { font-size: 26px; font-weight: 700; }
.login-form .input { height: 44px; }
.demo-creds { border: 1px dashed var(--gray-300); border-radius: 12px; padding: 12px 14px; font-size: 12.5px; background: var(--gray-50); }
.demo-creds strong { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--gray-700); }
.demo-creds strong svg.lucide { width: 14px; height: 14px; }
.demo-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.demo-grid button { all: unset; cursor: pointer; color: var(--brand); font-weight: 600; }
.demo-grid button:hover { text-decoration: underline; }
.form-error { color: var(--red); background: var(--red-50); border-radius: 10px; padding: 10px 12px; font-weight: 500; font-size: 13px; }
@media (max-width: 900px) { .login { grid-template-columns: 1fr; } .login-art { display: none; } }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: #0b1f1d; color: #cbd5e1; display: flex; flex-direction: column; padding: 16px 12px; z-index: 40; }
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.sb-brand strong { display: block; font-size: 15px; }
.sb-brand small { display: block; font-size: 11.5px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.sb-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.sb-sec { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #64748b; padding: 14px 10px 6px; }
.sb-link { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: #cbd5e1; font-weight: 500; text-decoration: none !important; position: relative; }
.sb-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sb-link.on { background: rgba(20,184,166,.16); color: #fff; }
.sb-link.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #2dd4bf; }
.sb-link svg.lucide { width: 18px; height: 18px; color: #94a3b8; }
.sb-link.on svg.lucide { color: #5eead4; }
.sb-link .count { margin-left: auto; background: #dc2626; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.sb-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid rgba(255,255,255,.08); padding: 12px 4px 0; }
.sb-foot .btn { color: #94a3b8; }
.sb-foot .btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.sb-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sb-user strong { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user small { color: #94a3b8; font-size: 11.5px; text-transform: capitalize; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 28px; background: rgba(245,247,250,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; min-width: 0; }
.crumbs a { color: var(--muted); }
.crumbs b { color: var(--gray-900); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs svg.lucide { width: 14px; height: 14px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.gsearch { width: 280px; }
.gsearch .input { height: 36px; background: #fff; }
.bell { position: relative; }
.bell .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--bg); }
.content { padding: 24px 28px 48px; max-width: 1440px; width: 100%; }
.sb-backdrop { display: none; }

@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 35; }
  .menu-btn { display: inline-flex; }
  .gsearch { display: none; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--gray-100); }
.card-h h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-h h3 svg.lucide { color: var(--gray-400); }
.card-h .sub { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.card-b { padding: 16px 20px; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1200px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .g-4, .g-3, .g-2 { grid-template-columns: 1fr; } }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 24px; }

/* ---------- KPIs ---------- */
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.kpi .k-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--tone-bg); color: var(--tone); }
.kpi .k-val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.kpi .k-sub { font-size: 12.5px; color: var(--muted); }
.kpi a.k-sub { color: var(--brand); font-weight: 600; }
a.kpi { color: inherit; text-decoration: none !important; transition: box-shadow .15s, border-color .15s; }
a.kpi:hover { border-color: var(--gray-300); box-shadow: var(--shadow); }

.gauge { display: flex; align-items: center; gap: 22px; }
.gauge svg { flex-shrink: 0; }
.legend { display: grid; gap: 10px; flex: 1; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend-row .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend-row b { margin-left: auto; font-weight: 700; }

.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 48px; gap: 12px; align-items: center; font-size: 13px; }
.bar-row .nm { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 10px; border-radius: 999px; background: var(--gray-100); display: flex; overflow: hidden; }
.bar-track span { height: 100%; }
.bar-row b { text-align: right; font-weight: 700; }

.trend { width: 100%; height: 180px; }
.trend-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.trend-legend span { display: inline-flex; align-items: center; gap: 6px; }
.trend-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.exp-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.exp-cell { border-radius: 12px; padding: 12px 14px; border: 1px solid var(--border); text-decoration: none !important; color: inherit; }
.exp-cell:hover { border-color: var(--gray-300); }
.exp-cell .v { font-size: 22px; font-weight: 800; }
.exp-cell .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.exp-cell.e0 { background: var(--red-50); border-color: #fecaca; } .exp-cell.e0 .v { color: var(--red); }
.exp-cell.e1 { background: #fff7ed; border-color: #fed7aa; } .exp-cell.e1 .v { color: #c2410c; }
.exp-cell.e2 { background: var(--amber-50); border-color: #fde68a; } .exp-cell.e2 .v { color: var(--amber); }
.exp-cell.e3 { background: var(--gray-50); } .exp-cell.e3 .v { color: var(--gray-700); }

/* ---------- Lists / feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--gray-100); align-items: flex-start; }
.feed li:first-child { border-top: 0; }
.feed .f-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; background: var(--tone-bg); color: var(--tone); }
.feed .f-ico svg.lucide { width: 16px; height: 16px; }
.feed .f-body { flex: 1; min-width: 0; font-size: 13px; }
.feed .f-body strong { font-weight: 600; }
.feed .f-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.feed .f-side { font-size: 12px; color: var(--muted); white-space: nowrap; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state svg.lucide { width: 36px; height: 36px; color: var(--gray-300); margin-bottom: 8px; }

/* ---------- Table ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--gray-100); }
.toolbar .input, .toolbar select.input { height: 36px; width: auto; min-width: 160px; }
.toolbar .input-icon { flex: 1; min-width: 220px; max-width: 360px; }
.toolbar .input-icon .input { width: 100%; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--gray-100); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { all: unset; cursor: pointer; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--gray-600); display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: #fff; color: var(--gray-900); box-shadow: var(--shadow-sm); }
.seg button .n { font-size: 11px; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 16px; background: var(--gray-50); border-bottom: 1px solid var(--border); white-space: nowrap; }
.t td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: var(--gray-50); }
.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.t .strong { font-weight: 600; color: var(--gray-900); }
.t .sub { color: var(--muted); font-size: 12px; }
.kit-cell { display: flex; flex-direction: column; }
.kit-cell .code { font: 600 12px ui-monospace, Consolas, monospace; color: var(--brand); }
.t-foot { padding: 10px 16px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--gray-100); display: flex; justify-content: space-between; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button { all: unset; cursor: pointer; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.tabs button:hover { color: var(--gray-800); }
.tabs button.on { color: var(--brand); border-color: var(--brand); }
.tabs button .n { background: var(--gray-100); color: var(--gray-600); font-size: 11px; padding: 1px 7px; border-radius: 999px; }

/* ---------- Kit detail ---------- */
.kit-head { display: grid; grid-template-columns: 1fr auto; gap: 20px; padding: 20px 22px; }
.kit-head .code { font: 700 12px ui-monospace, Consolas, monospace; color: var(--brand); background: var(--brand-50); padding: 4px 8px; border-radius: 6px; }
.kit-head h1 { font-size: 22px; font-weight: 700; margin: 8px 0 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 24px; margin-top: 16px; }
.meta-grid .m-l { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.meta-grid .m-v { font-weight: 500; margin-top: 2px; }
.qr-box { text-align: center; }
.qr-box img { width: 132px; height: 132px; border-radius: 10px; border: 1px solid var(--border); padding: 6px; background: #fff; }
.qr-box .btns { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }

.inv-item { display: flex; align-items: center; gap: 12px; }
.inv-item .nm { font-weight: 600; color: var(--gray-900); }
.stock-bar { width: 120px; height: 6px; border-radius: 999px; background: var(--gray-100); overflow: hidden; margin-top: 6px; }
.stock-bar span { display: block; height: 100%; border-radius: 999px; background: var(--green); }
.stock-bar.low span { background: #f59e0b; }
.stock-bar.zero span { background: var(--red); }
.batch-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bchip { font-size: 11.5px; border: 1px solid var(--border); border-radius: 7px; padding: 3px 7px; background: #fff; white-space: nowrap; }
.bchip.exp { border-color: #fecaca; background: var(--red-50); color: var(--red); }
.bchip.soon { border-color: #fde68a; background: var(--amber-50); color: var(--amber); }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 200; display: none; }
.modal-root.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.45); animation: fade .15s; }
.modal { position: absolute; left: 50%; top: 6vh; transform: translateX(-50%); width: min(640px, calc(100vw - 24px)); max-height: 88vh; display: flex; flex-direction: column; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
.modal.wide { width: min(920px, calc(100vw - 24px)); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--gray-100); }
.modal-h h3 { font-size: 17px; font-weight: 700; }
.modal-h p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.modal-b { padding: 20px 22px; overflow-y: auto; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 8px; background: var(--gray-25); border-radius: 0 0 16px 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.section-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 6px 0 -4px; grid-column: 1 / -1; }

.line-editor { display: grid; gap: 8px; }
.line { display: grid; grid-template-columns: 1fr 90px 130px 150px 36px; gap: 8px; align-items: center; }
.line.simple { grid-template-columns: 1fr 100px 36px; }
.line.tpl { grid-template-columns: 1fr 90px 90px 110px 36px; }
.line-head { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
@media (max-width: 640px) { .line, .line.tpl { grid-template-columns: 1fr 1fr; } }

.sig-pad { border: 1.5px dashed var(--gray-300); border-radius: 12px; background: var(--gray-50); width: 100%; height: 150px; touch-action: none; cursor: crosshair; }
.checklist { display: grid; gap: 8px; }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.checklist label:hover { background: var(--gray-50); }
.checklist input { width: 18px; height: 18px; accent-color: var(--brand); }
.result-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-pick label { border: 1.5px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; cursor: pointer; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.result-pick input { display: none; }
.result-pick label:has(input:checked) { border-color: var(--brand); background: var(--brand-50); color: var(--brand-700); }

pre.json { background: #0b1220; color: #d1e7ff; border-radius: 12px; padding: 14px 16px; font-size: 12px; overflow: auto; max-height: 460px; margin: 0; line-height: 1.55; }
pre.json .k { color: #7dd3fc; } pre.json .s { color: #a7f3d0; } pre.json .n { color: #fcd34d; } pre.json .b { color: #f9a8d4; }

.ep-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.ep-top { display: flex; align-items: flex-start; gap: 12px; }
.ep-logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex-shrink: 0; }
.ep-logo.SAP { background: linear-gradient(135deg, #0ea5e9, #1d4ed8); }
.ep-logo.Oracle { background: linear-gradient(135deg, #f87171, #b91c1c); }
.ep-logo.Dynamics { background: linear-gradient(135deg, #a78bfa, #6d28d9); }
.ep-logo.Generic { background: linear-gradient(135deg, #64748b, #334155); }
.ep-url { font: 12px ui-monospace, Consolas, monospace; color: var(--muted); word-break: break-all; }
.ep-stats { display: flex; gap: 18px; font-size: 12.5px; }
.ep-stats b { font-size: 16px; display: block; }
.ep-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--gray-100); color: var(--gray-700); }
.ep-actions { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--gray-100); padding-top: 12px; }

.hash { font: 11px ui-monospace, Consolas, monospace; color: var(--gray-400); }
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-700); font-size: 13px; }
.callout.warn { background: var(--amber-50); border-color: #fde68a; color: #92400e; }
.callout.bad { background: var(--red-50); border-color: #fecaca; color: #991b1b; }
.callout svg.lucide { margin-top: 1px; }
.report-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.report-card .r-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--tone-bg); color: var(--tone); }
.report-card h3 { font-size: 15px; }
.report-card p { color: var(--muted); font-size: 13px; flex: 1; }
.report-card .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.nowrap { white-space: nowrap; }
