:root {
  --bg: #f4f6fa; --card: #fff; --text: #1d2433; --muted: #6b7486; --line: #e3e7ee;
  --primary: #1f5fbf; --primary-d: #184b97; --side: #14213d; --side-t: #c9d3e6;
  --green: #1d8a4e; --amber: #b7791f; --red: #c0392b; --blue: #1f5fbf; --gray: #6b7486;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 12px; } h2 { font-size: 18px; } h3 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); } .small, small { font-size: 12px; }
.err { color: var(--red); } .right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
code { background: #eef2f8; padding: 2px 6px; border-radius: 4px; } code.big { font-size: 18px; letter-spacing: 1px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--side); color: var(--side-t); display: flex; flex-direction: column; padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 18px; padding: 4px 10px 16px; }
.brand:hover { text-decoration: none; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a, .sidebar nav .disabled { color: var(--side-t); padding: 8px 10px; border-radius: 8px; display: flex; gap: 8px; align-items: center; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav a.sub { padding-left: 38px; font-size: 13px; }
.sidebar nav .disabled { opacity: .45; cursor: default; }
.sidebar nav .disabled em { font-size: 10px; font-style: normal; border: 1px solid; border-radius: 4px; padding: 0 4px; margin-left: auto; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 16px 10px 6px; }
.me { border-top: 1px solid rgba(255,255,255,.12); padding: 12px 10px 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.me b { color: #fff; } .me a, .me .link { color: var(--side-t); }
.link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; text-align: left; }
.content { flex: 1; padding: 24px 28px; min-width: 0; }
.burger { display: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card.narrow { max-width: 560px; }
details.card summary { cursor: pointer; } details.card[open] summary { margin-bottom: 12px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head h1, .head h3 { margin-bottom: 8px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } .two-col > .card { margin-bottom: 0; }
.two-col + * { margin-top: 16px; }

.btn { display: inline-flex; align-items: center; gap: 4px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); cursor: pointer; font: inherit; font-weight: 500; white-space: nowrap; }
.btn:hover { background: #f0f3f8; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; } .btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--red); border-color: #f0c8c3; } .btn.danger:hover { background: #fdf0ee; }
.btn.small { padding: 4px 10px; font-size: 12px; } .btn.wide { width: 100%; justify-content: center; }
.btn.right { margin-left: auto; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }

input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid #cfd6e2; border-radius: 8px; background: #fff; width: 100%; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9cff0; border-color: var(--primary); }
input[type=checkbox] { width: auto; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; } .field i { color: var(--red); font-style: normal; }
.field.check { flex-direction: row; align-items: center; gap: 8px; } .field.check > span { font-size: 14px; color: var(--text); font-weight: 400; }
.field.has-error input, .field.has-error select { border-color: var(--red); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[name=q] { max-width: 320px; } .filters select { width: auto; max-width: 240px; } .filters input[type=date] { width: auto; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; min-width: 140px; }
.actions-card { display: flex; flex-direction: column; gap: 12px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 8px; white-space: nowrap; }
.table td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
.table tbody tr:hover { background: #f8fafd; } .table tfoot td { border-bottom: 0; }
.table.access select { min-width: 200px; }
.muted-row td { opacity: .55; } .row-error { background: #fdf0ee; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef1f6; color: var(--gray); white-space: nowrap; }
.badge.blue { background: #e6eefb; color: var(--blue); } .badge.green { background: #e3f4ea; color: var(--green); }
.badge.amber { background: #fbf1df; color: var(--amber); } .badge.red { background: #fbe9e7; color: var(--red); }
.lvl { font-size: 12px; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.lvl.l0 { color: #b0b6c2; } .lvl.l1 { background: #eef1f6; } .lvl.l2 { background: #e6eefb; color: var(--blue); } .lvl.l3 { background: #e3f4ea; color: var(--green); }

.messages { margin-bottom: 14px; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: #e6eefb; border: 1px solid #c7d8f3; }
.msg.success { background: #e3f4ea; border-color: #bfe3cd; } .msg.error { background: #fbe9e7; border-color: #f2c4bd; }
.msg.warning { background: #fbf1df; border-color: #f0dcb3; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; color: var(--text); }
a.stat:hover { border-color: var(--primary); text-decoration: none; }
.stat b { font-size: 22px; } .stat small { color: var(--muted); } .stat.warn b { color: var(--amber); }
.stats.small .stat b { font-size: 17px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.tile:hover { border-color: var(--primary); text-decoration: none; } .tile b { font-size: 16px; } .tile small { color: var(--muted); }
.steps li { margin-bottom: 6px; } .legend { padding-left: 18px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 10px 0; }
.creds .table th { width: 90px; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #14213d, #1f5fbf); }
.login-box { background: #fff; border-radius: 16px; padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-box .brand { color: var(--text); padding: 0 0 4px; } .brand.big { font-size: 24px; }
.login-box h2 { margin: 18px 0 12px; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; z-index: 10; transition: left .2s; }
  .sidebar.open { left: 0; }
  .burger { display: inline-block; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; font-size: 18px; }
  .content { padding: 14px; } .two-col { grid-template-columns: 1fr; }
}

.total-preview { margin-top: 6px; padding: 10px 14px; background: #f3f7fd; border-radius: 8px; min-height: 20px; }
.total-preview:empty { display: none; }
.field.big input, .field.big select { font-size: 16px; padding: 10px 12px; }
.main-req { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
details summary { cursor: pointer; margin: 10px 0; }
.primary-stat { background: var(--primary); color: #fff; border-color: var(--primary); } .primary-stat small { color: #dbe6f7; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 6px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: 13px; }
.chip b { margin-left: 4px; } .chip:hover { text-decoration: none; border-color: var(--primary); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.warn b { color: var(--amber); } .chip.danger b { color: var(--red); } .chip.on b { color: #fff; }
.bulk-bar { position: sticky; bottom: 0; display: none; gap: 8px; align-items: center; flex-wrap: wrap; background: #14213d; color: #fff;
  padding: 10px 14px; border-radius: 10px; margin: 8px 0; box-shadow: 0 -4px 16px rgba(0,0,0,.15); }
.bulk-bar.show { display: flex; } .bulk-bar select, .bulk-bar input { width: auto; padding: 6px 8px; }
.timeline { list-style: none; padding: 0 0 0 18px; margin: 0 0 14px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 12px 10px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--gray); border: 2px solid #fff; }
.timeline li.k-loaded::before { background: var(--blue); } .timeline li.k-unloaded::before { background: var(--amber); }
.timeline li.k-delivered::before { background: var(--green); }
form.inline { display: inline; }
