:root {
  --navy: #13233A; --navy-2: #1C3352; --blue: #1F4E79; --blue-2: #2A6399; --orange: #E07A2E; --orange-d: #A94F0C;
  --bg: #F3F5F8; --card: #FFFFFF; --line: #DDE3EA; --line-2: #C5CED8; --text: #1B2430; --muted: #5A6676;
  --ok: #1E7A45; --ok-bg: #E6F4EA; --warn: #8A5300; --warn-bg: #FDF1DC; --bad: #A3261B; --bad-bg: #FCE9E7;
  --info: #0C447C; --info-bg: #E3EEF9; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-brand { background: var(--navy); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 360px; height: 360px; border-radius: 50%; border: 48px solid rgba(224,122,46,.25); }
.login-brand h1 { font-size: 34px; line-height: 1.15; margin: 24px 0 12px; }
.login-brand p { color: #C9D3DF; max-width: 420px; line-height: 1.6; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 22px; margin-bottom: 4px; }
.brand-logo { display: flex; align-items: center; gap: 12px; }
.logo-box { background: #fff; border-radius: 10px; padding: 8px 12px; display: inline-flex; align-items: center; min-height: 44px; }
.logo-box img { max-height: 36px; max-width: 160px; display: block; }
.logo-text { font-weight: 700; color: var(--navy); font-size: 18px; letter-spacing: .5px; }
.demo-box { margin-top: 20px; background: var(--info-bg); color: var(--info); border-radius: 8px; padding: 12px 14px; font-size: 13px; line-height: 1.6; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100%; }
.sidebar { width: 248px; flex: 0 0 248px; background: var(--navy); color: #D6E2EE; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .side-head { padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .portal-name { margin-top: 10px; font-weight: 600; color: #fff; font-size: 14px; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8FA3BA; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-decoration: none; color: #D6E2EE; padding: 9px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.on { background: var(--blue); color: #fff; }
.nav .badge { background: var(--orange); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 8px; min-width: 22px; text-align: center; }
.side-foot { margin-top: auto; padding: 14px 16px; font-size: 12px; color: #8FA3BA; border-top: 1px solid rgba(255,255,255,.08); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 12px 24px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 5; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .crumb { font-size: 12px; color: var(--muted); }
.userchip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--orange); color: #fff; font-weight: 700; display: grid; place-items: center; }
.userchip .who { line-height: 1.2; }
.userchip .who b { display: block; font-size: 13px; }
.userchip .who span { font-size: 12px; color: var(--muted); }
.menu-btn { display: none; }
.content { padding: 24px; max-width: 1320px; width: 100%; }
.demo-banner { background: var(--warn-bg); color: var(--warn); padding: 8px 24px; font-size: 13px; border-bottom: 1px solid #F2D9AE; }

/* ---------- building blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi .n { font-size: 30px; font-weight: 700; line-height: 1.1; margin-top: 6px; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi.alert { border-color: #F0B9B2; background: #FFF8F7; } .kpi.alert .n { color: var(--bad); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.bars .row { display: grid; grid-template-columns: 170px minmax(0,1fr) 40px; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 13px; }
.bars .track { background: #EEF1F4; border-radius: 4px; height: 12px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--blue); border-radius: 4px; }
.bars .num { text-align: right; font-weight: 600; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.on { color: var(--blue); border-bottom-color: var(--blue); }
.tab .badge { background: var(--orange); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 6px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--blue); background: var(--blue); color: #fff; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; text-decoration: none; min-height: 38px; }
.btn:hover { background: var(--blue-2); }
.btn.ghost { background: #fff; color: var(--blue); }
.btn.ghost:hover { background: var(--info-bg); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.bad { background: #fff; color: var(--bad); border-color: #E4A5A0; }
.btn.bad:hover { background: var(--bad-bg); }
.btn.sm { padding: 5px 10px; min-height: 30px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.link { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .lbl { font-size: 12px; font-weight: 600; color: #3D4A5C; }
.req { color: var(--bad); }
.tag-auto { font-size: 10px; font-weight: 700; color: var(--info); background: var(--info-bg); border-radius: 4px; padding: 1px 6px; margin-left: 6px; }
input, select, textarea { border: 1px solid var(--line-2); border-radius: 7px; padding: 8px 10px; background: #fff; color: var(--text); min-height: 38px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9BC0E6; outline-offset: 0; border-color: var(--blue); }
input[readonly], input:disabled, select:disabled, textarea:disabled { background: #F0F2F5; color: var(--muted); }
textarea { min-height: 70px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 12px; cursor: pointer; background: #fff; font-size: 13px; }
.chip input { width: auto; min-height: 0; margin: 0; }
.chip:has(input:checked) { background: var(--info-bg); border-color: var(--blue); color: var(--info); font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); }

.note { border-radius: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.5; margin: 12px 0; }
.note.info { background: var(--info-bg); color: var(--info); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.bad { background: var(--bad-bg); color: var(--bad); }

.product-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; background: #FBFCFD; }
.product-card h3 { margin: 0 0 12px; font-size: 14px; color: var(--blue); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; background: #fff; }
th { text-align: left; background: #F6F8FA; color: #3D4A5C; font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #EEF1F4; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FAFCFE; }
td.num, th.num { text-align: right; }
td .btn + .btn { margin-left: 6px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 200px; }

.st { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--info-bg); color: var(--info); }
.st.warn { background: var(--warn-bg); color: var(--warn); }
.st.ok { background: var(--ok-bg); color: var(--ok); }
.st.bad { background: var(--bad-bg); color: var(--bad); }
.st.grey { background: #EEF1F4; color: #4A5565; }
.age-hot { color: var(--bad); font-weight: 700; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(19,35,58,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 760px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 980px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 8px; max-width: 380px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 13px; }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 18px; }
.kv div b { display: block; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 6px 0 6px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { padding: 32px; }
  .sidebar { position: fixed; left: -260px; z-index: 40; transition: left .2s; }
  .sidebar.open { left: 0; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .userchip .who { display: none; }
  .bars .row { grid-template-columns: 120px minmax(0,1fr) 34px; }
}
@media print { .sidebar, .topbar, .demo-banner, .actions { display: none; } .content { padding: 0; } }
