:root {
  --ink: #14213d;
  --ink-soft: #4a5878;
  --muted: #7a869c;
  --line: #e3e9f2;
  --bg: #f4f7fc;
  --navy: #0e2b45;
  --navy-2: #143b5c;
  --accent: #1f6feb;
  --accent-2: #0f9b8e;
  --violet: #6d5bd0;
  --amber: #b7791f;
  --red: #c0392b;
  --green: #1e7f4f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 34, 62, .05), 0 8px 24px -12px rgba(16, 34, 62, .18);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ------------------------------------------------------------- layout */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 254px;
  flex: 0 0 254px;
  background: linear-gradient(180deg, #0e2b45 0%, #103a5b 62%, #0d334f 100%);
  color: #d8e4f2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px 16px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 11px;
  background: #fff; display: grid; place-items: center; flex: 0 0 42px;
  padding: 5px; box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-name { font-weight: 700; font-size: 14px; color: #fff; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: #93b0cc; }

.nav { padding: 4px 10px 18px; display: flex; flex-direction: column; gap: 1px; }
.nav-group {
  font-size: 10px; text-transform: uppercase; letter-spacing: .09em;
  color: #7d9cba; padding: 16px 10px 6px; font-weight: 600;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px;
  color: #cadcec; font-size: 13px; font-weight: 500;
  text-decoration: none; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255, 255, 255, .14); color: #fff; box-shadow: inset 2px 0 0 #4da3ff; }
.nav-link .ico { opacity: .85; flex: 0 0 18px; }
.nav-badge {
  margin-left: auto; background: #4da3ff; color: #06223b;
  font-size: 10.5px; font-weight: 700; border-radius: 99px; padding: 1px 7px;
}
.nav-badge.alert { background: #ffb4a2; }
.sidebar-foot { margin-top: auto; padding: 14px 18px 20px; color: #7d9cba; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 6px 10px; font-size: 16px; cursor: pointer; }
.page-title h1 { font-size: 18px; }
.page-title p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top-chip { position: relative; color: var(--ink-soft); padding: 6px; border-radius: 9px; }
.top-chip:hover { background: #eef3fb; }
.top-chip .dot { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; background: #e0503a; border-radius: 50%; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 6px 5px 10px; background: #fff; border: 1px solid var(--line); border-radius: 99px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #1f6feb, #0f9b8e); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta strong { font-size: 12.5px; font-weight: 600; }
.user-meta span { font-size: 10.5px; color: var(--muted); }
.logout { color: var(--muted); padding: 4px; border-radius: 6px; }
.logout:hover { color: var(--red); }

.content { padding: 22px 26px 40px; max-width: 1520px; width: 100%; }
.foot { margin-top: auto; padding: 16px 26px 26px; color: var(--muted); font-size: 11.5px; }
.foot .copyright { margin-top: 3px; }
.foot .copyright a { color: var(--accent); }
.print-logo { height: 54px; width: auto; margin-bottom: 6px; }

/* -------------------------------------------------------------- cards */
.card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 14.5px; }
.card-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 16px 20px 0; }
.grid { display: grid; gap: 20px; }
.grid > .card { margin-bottom: 0; }
.grid > *, .split > * { min-width: 0; }
.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)); }
.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.split > .card { margin-bottom: 0; }

/* KPI */
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kpi .k-value { font-size: 25px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.kpi .k-note { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.kpi.accent { border-left: 3px solid var(--accent); }
.kpi.warn { border-left: 3px solid var(--amber); }
.kpi.danger { border-left: 3px solid var(--red); }
.kpi.ok { border-left: 3px solid var(--green); }

/* ------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 650; background: #f8fafd; white-space: nowrap;
  position: sticky; top: 0;
}
tbody tr:hover { background: #f9fbff; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-sm th, .table-sm td { padding: 7px 10px; font-size: 12.5px; }

/* -------------------------------------------------------------- forms */
label.fl { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=email],
input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d7e0ec; border-radius: 9px;
  font-family: inherit; font-size: 13px; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 111, 235, .12); }
input[type=file] { font-size: 12.5px; }
textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: span 3; }
.field-help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form > div { min-width: 130px; }
.combo-input {
  width: 100%; padding: 6px 10px; margin-bottom: 5px; border: 1px dashed #c7d4e6;
  border-radius: 8px; font-size: 12px; background: #f8fbff;
}
.combo-input:focus { outline: none; border-style: solid; border-color: var(--accent); background: #fff; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.check-row input { width: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: var(--accent); color: #fff; border: 1px solid transparent;
  padding: 9px 15px; border-radius: 9px; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit; line-height: 1.2;
}
.btn:hover { background: #1a5fcc; text-decoration: none; color: #fff; }
.btn.ghost { background: #fff; color: var(--ink-soft); border-color: #d7e0ec; }
.btn.ghost:hover { background: #f3f7fd; color: var(--ink); }
.btn.ok { background: var(--green); }
.btn.ok:hover { background: #186b42; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #a53125; }
.btn.grey { background: #eef2f8; color: var(--ink-soft); }
.btn.grey:hover { background: #e4ebf5; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ------------------------------------------------------------- badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 650; white-space: nowrap; letter-spacing: .01em;
}
.badge-green { background: #e4f6ec; color: #1a6b45; }
.badge-amber { background: #fdf0dc; color: #96610e; }
.badge-yellow { background: #fbf6dc; color: #857010; }
.badge-red { background: #fdeaea; color: #a5301f; }
.badge-blue { background: #e7f0fd; color: #1a55a8; }
.badge-violet { background: #efeafc; color: #5546ac; }
.badge-grey { background: #eef1f6; color: #5c6879; }

.flash { padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; border: 1px solid; }
.flash.success { background: #eaf7f0; border-color: #b8e3cb; color: #1a6b45; }
.flash.error { background: #fdeeee; border-color: #f2c8c2; color: #9e3021; }
.flash.info { background: #eaf1fd; border-color: #c6d9f7; color: #1a55a8; }

.empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; font-size: 13px; color: var(--ink-soft); border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
.tabs a:hover { text-decoration: none; color: var(--accent); }

.chip { display: inline-block; padding: 3px 9px; border-radius: 7px; background: #f0f4fa; font-size: 11.5px; color: var(--ink-soft); }
.list-tight { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fcfdff; }
.list-item .li-body { flex: 1; min-width: 0; }
.list-item strong { font-size: 13px; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding-bottom: 14px; }
.tl-dot { width: 11px; height: 11px; border-radius: 50%; background: #cbd7e8; margin-top: 5px; justify-self: center; }
.tl-item.done .tl-dot { background: var(--green); }
.tl-item.pending .tl-dot { background: var(--amber); }
.tl-line { border-left: 2px solid var(--line); margin-left: 10px; }
.notice { padding: 11px 14px; border-radius: 10px; background: #fff8e8; border: 1px solid #f2e0b6; color: #7a5a12; font-size: 12.5px; }
.notice.danger { background: #fdeeee; border-color: #f2c8c2; color: #9e3021; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* -------------------------------------------------------------- login */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #dce9fb 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 0%, #d9f2ee 0%, transparent 50%),
              linear-gradient(160deg, #eef4fc 0%, #f7fafd 100%);
}
.login-card { width: 100%; max-width: 940px; display: grid; grid-template-columns: 1.05fr 1fr; background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 24px 60px -30px rgba(13, 43, 69, .45); border: 1px solid #e6edf6; }
.login-side { background: linear-gradient(160deg, #0e2b45, #12496b 60%, #0f6a68); color: #e6f0f8; padding: 34px 32px; display: flex; flex-direction: column; gap: 14px; }
.login-side h2 { font-size: 20px; color: #fff; }
.login-side ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.8px; color: #c9dcec; line-height: 1.7; }
.login-form { padding: 34px 32px; }
.login-form h1 { font-size: 20px; margin-bottom: 4px; }
.demo-users { margin-top: 16px; display: grid; gap: 6px; }
.demo-user { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 7px 10px; background: #f6f9fd; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.demo-user:hover { background: #eef4fc; }

/* -------------------------------------------------------- print/labels */
.label-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.qr-label { border: 1px dashed #b9c6d8; border-radius: 10px; padding: 10px; background: #fff; display: flex; gap: 10px; align-items: center; page-break-inside: avoid; }
.qr-label .qr-holder { width: 84px; height: 84px; flex: 0 0 84px; display: grid; place-items: center; }
.qr-label .qr-holder img, .qr-label .qr-holder canvas { width: 84px; height: 84px; }
.qr-label .qr-info { font-size: 10.5px; line-height: 1.35; min-width: 0; }
.qr-label .qr-info b { display: block; font-size: 11.5px; margin-bottom: 2px; }

.print-head { border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 16px; text-align: center; }
.print-head h2 { font-size: 16px; letter-spacing: .02em; }
.print-head p { margin: 3px 0; font-size: 12px; color: var(--ink-soft); }
@media print {
  .sidebar, .topbar, .foot, .no-print, .btn, .btn-row, .flash, .tabs { display: none !important; }
  body { background: #fff; font-size: 11.5px; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: none; padding: 0; margin-bottom: 12px; }
  .print-head { display: block; text-align: center; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 14px; }
  .print-head h2 { font-size: 15px; }
  .print-head p { margin: 2px 0; font-size: 11px; }
  th { background: #f1f4f8 !important; color: #000; position: static; }
  table { font-size: 10.5px; }
  th, td { padding: 5px 6px; border-color: #999; }
  .qr-label { border: 1px solid #999; }
  a { color: #000; text-decoration: none; }
}

/* --------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span3 { grid-column: span 2; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -270px; z-index: 60; transition: left .2s; height: 100dvh; }
  .sidebar.open { left: 0; box-shadow: 0 0 0 100vmax rgba(10, 24, 40, .45); }
  .menu-btn { display: inline-block; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid, .form-grid .span2, .form-grid .span3 { grid-template-columns: 1fr; grid-column: auto; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .user-meta { display: none; }
  .login-card { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .login-side { display: none; }
}
