/* Anniekart ERP — admin UI. Navy + orange brand, productivity-first, no heavy animation. */
[hidden] { display: none !important; }
:root {
  --navy: #0f1c33; --navy-2: #172a4a; --navy-3: #22385f;
  --orange: #f5821f; --orange-d: #d96c0c; --orange-l: #fff3e8;
  --bg: #f3f5f9; --card: #ffffff; --line: #e3e7ef; --line-2: #d3d9e4;
  --text: #182033; --muted: #66708a; --faint: #98a1b5;
  --green: #12805c; --green-l: #e5f5ee; --red: #c53030; --red-l: #fdecec; --amber: #a86400; --amber-l: #fff4dc;
  --blue: #2457c5; --blue-l: #e8effd; --purple: #6b3fb5; --purple-l: #f1eafd; --grey-l: #eef0f4;
  --radius: 8px; --shadow: 0 1px 2px rgba(16, 28, 51, .06), 0 1px 1px rgba(16, 28, 51, .04);
  --font: -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 650; }
.muted { color: var(--muted); } .small { font-size: 12px; } .faint { color: var(--faint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }

/* ---------- shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--navy); color: #c9d3e6; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 16px 16px 12px; color: #fff; text-decoration: none !important; }
.brand img { height: 40px; border-radius: 4px; }
.brand span { font-size: 11px; letter-spacing: .14em; color: var(--orange); font-weight: 700; }
.sidebar nav { padding: 4px 8px; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #7f8db0; padding: 14px 10px 4px; font-weight: 650; }
.nav-top, .nav-item { display: flex; align-items: center; justify-content: space-between; color: #d3dbea; padding: 6px 10px; border-radius: 6px; font-size: 13.5px; text-decoration: none !important; }
.nav-top { font-weight: 600; margin-top: 6px; }
.nav-top:hover, .nav-item:hover { background: var(--navy-2); color: #fff; }
.nav-top.active, .nav-item.active { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--orange); }
.nav-count { background: var(--orange); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 700; line-height: 18px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.global-search { flex: 1; max-width: 520px; }
.global-search input { width: 100%; border: 1px solid var(--line-2); background: var(--bg); border-radius: 8px; padding: 8px 12px; font-size: 13.5px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--orange); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.user-menu .menu { position: absolute; right: 0; top: 40px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 200px; padding: 6px 0; }
.user-menu .menu a, .user-menu .menu button { display: block; width: 100%; text-align: left; padding: 8px 12px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--bg); text-decoration: none; }
.content { padding: 22px 24px 48px; max-width: 1440px; width: 100%; }
.icon-btn { border: 1px solid var(--line-2); background: #fff; border-radius: 6px; padding: 4px 9px; font-size: 18px; cursor: pointer; }
.only-mobile { display: none; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 3px; font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }

/* ---------- cards / grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.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-side { grid-template-columns: minmax(0, 1fr) 340px; }
.stack > * + * { margin-top: 10px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none !important; color: var(--text); display: block; box-shadow: var(--shadow); }
.kpi:hover { border-color: var(--line-2); }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 21px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.kpi.attn { border-left: 3px solid var(--orange); }
.kpi.bad { border-left: 3px solid var(--red); }

.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.quick a, .quick button { display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); font-weight: 600; font-size: 13px; text-decoration: none !important; cursor: pointer; font-family: inherit; width: 100%; min-height: 46px; }
.quick a:hover, .quick button:hover { border-color: var(--orange); background: var(--orange-l); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: #fafbfd; }
table.t .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t.compact td, table.t.compact th { padding: 6px 10px; }
table.kv td { padding: 5px 0; vertical-align: top; } table.kv td:first-child { color: var(--muted); width: 42%; padding-right: 10px; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.badge-green { background: var(--green-l); color: var(--green); } .badge-red { background: var(--red-l); color: var(--red); }
.badge-amber { background: var(--amber-l); color: var(--amber); } .badge-blue { background: var(--blue-l); color: var(--blue); }
.badge-purple { background: var(--purple-l); color: var(--purple); } .badge-grey { background: var(--grey-l); color: #4b5470; }
.badge-orange { background: var(--orange-l); color: var(--orange-d); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; justify-content: center; border: 1px solid var(--line-2); background: #fff; color: var(--text); padding: 7px 13px; border-radius: 7px; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none !important; font-family: inherit; line-height: 1.25; white-space: nowrap; }
.btn:hover { border-color: #b8c1d3; background: #fafbfd; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-d); border-color: var(--orange-d); }
.btn-dark { background: var(--navy); border-color: var(--navy); color: #fff; } .btn-dark:hover { background: var(--navy-2); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; } .btn-success:hover { filter: brightness(.95); background: var(--green); }
.btn-danger { color: var(--red); border-color: #efc4c4; } .btn-danger:hover { background: var(--red-l); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; } .btn-lg { padding: 10px 18px; font-size: 15px; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-link { background: none; border: 0; color: var(--blue); padding: 0; cursor: pointer; font: inherit; }
form.inline { display: inline; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: #3a435a; margin-bottom: 4px; }
.field input, .field select, .field textarea, .input { width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 7px; font: inherit; font-size: 13.5px; background: #fff; color: var(--text); }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus, .lines-edit input:focus, .lines-edit select:focus { outline: 2px solid rgba(245, 130, 31, .35); border-color: var(--orange); }
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.field.has-error input, .field.has-error select { border-color: var(--red); }
.field-error { color: var(--red); font-size: 12px; margin-top: 3px; }
.req { color: var(--red); }
.tip { display: inline-flex; width: 15px; height: 15px; border-radius: 50%; background: var(--grey-l); color: var(--muted); font-size: 10px; align-items: center; justify-content: center; cursor: help; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13.5px; cursor: pointer; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 6px; flex-wrap: wrap; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px 4px; margin: 0 0 14px; }
legend { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 0 6px; }

/* filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; padding: 12px 18px; border-bottom: 1px solid var(--line); background: #fbfcfe; }
.filters .input, .filters select, .filters input { width: auto; min-width: 140px; padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 7px; font: inherit; font-size: 13px; background: #fff; }
.filters input[type=search] { min-width: 240px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs a { padding: 10px 12px; color: var(--muted); font-weight: 600; font-size: 13.5px; border-bottom: 2px solid transparent; text-decoration: none !important; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--orange); }
.tabs a .nav-count { margin-left: 6px; }
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.subnav a { padding: 6px 12px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none !important; }
.subnav a.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* alerts */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid; }
.alert ul { margin: 6px 0 0 18px; padding: 0; }
.alert-success { background: var(--green-l); border-color: #b9e3d1; color: #0b5c41; }
.alert-error { background: var(--red-l); border-color: #f2c2c2; color: #8f1f1f; }
.alert-warning { background: var(--amber-l); border-color: #f1d9a3; color: #7a4a00; }
.alert-info { background: var(--blue-l); border-color: #c6d6f7; color: #1d4296; }
.alert.floating { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 100; }

/* pager & empty */
.pager { display: flex; gap: 4px; align-items: center; padding: 10px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager .muted { margin-right: auto; font-size: 12.5px; }
.pager a, .pager .current { min-width: 30px; text-align: center; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); font-size: 13px; }
.pager .current { background: var(--navy); color: #fff; border-color: var(--navy); }
.empty { text-align: center; padding: 38px 20px; color: var(--muted); }
.empty h3 { color: var(--text); font-size: 15px; }

/* checklist */
.checklist { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.checklist li { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .ic { width: 18px; flex-shrink: 0; font-weight: 800; text-align: center; }
.checklist .ok .ic { color: var(--green); } .checklist .fail .ic { color: var(--red); } .checklist .warn .ic { color: var(--amber); }
.checklist .fail { color: #8f1f1f; }

/* format picker */
.formats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.format-opt { position: relative; border: 2px solid var(--line); border-radius: 10px; padding: 12px 12px 10px; cursor: pointer; background: #fff; display: block; }
.format-opt input { position: absolute; opacity: 0; }
.format-opt:has(input:checked) { border-color: var(--orange); background: var(--orange-l); }
.format-opt .fn { font-weight: 700; font-size: 13.5px; }
.format-opt .fd { font-size: 12px; color: var(--muted); margin-top: 3px; }
.format-opt .sugg { position: absolute; top: -9px; right: 8px; background: var(--green); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 8px; }
.warn-box { margin-top: 10px; }

/* invoice editor */
.lines-edit { width: 100%; min-width: 1180px; border-collapse: collapse; font-size: 13px; }
.lines-edit th { font-size: 11px; text-transform: uppercase; color: var(--muted); text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lines-edit td { padding: 4px; vertical-align: top; border-bottom: 1px solid var(--line); }
.lines-edit input, .lines-edit select { width: 100%; padding: 6px 7px; border: 1px solid var(--line-2); border-radius: 6px; font: inherit; font-size: 13px; background: #fff; }
.lines-edit .w-desc { min-width: 240px; } .lines-edit .w-s, .lines-edit .w-s input, .lines-edit .w-s select { min-width: 92px; } .lines-edit .w-xs, .lines-edit .w-xs input { min-width: 66px; } .lines-edit .w-m, .lines-edit .w-m input, .lines-edit .w-m select { min-width: 104px; }
.lines-edit .calc { padding-top: 10px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-del { border: 0; background: none; color: var(--red); font-size: 18px; cursor: pointer; padding: 4px 6px; }
.totals { width: 100%; font-size: 13.5px; }
.totals td { padding: 4px 0; } .totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.totals .grand td { font-size: 17px; font-weight: 800; border-top: 1px solid var(--line); padding-top: 8px; }
.sticky-side { position: sticky; top: 72px; }

/* autocomplete */
.ac-wrap { position: relative; }
.ac-list { position: absolute; z-index: 50; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line-2); border-radius: 7px; box-shadow: 0 8px 22px rgba(0,0,0,.12); max-height: 280px; overflow-y: auto; margin-top: 2px; min-width: 280px; }
.ac-list div { padding: 8px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--line); }
.ac-list div:last-child { border-bottom: 0; }
.ac-list div:hover, .ac-list div.on { background: var(--orange-l); }
.ac-list small { color: var(--muted); display: block; }

/* invoice preview frame */
.doc-frame { width: 100%; height: 1120px; border: 1px solid var(--line); border-radius: 8px; background: #e9ecf1; }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.status-line { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; background: var(--navy-3); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars .b:hover { background: var(--orange); }
.bars-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 4px; }

/* auth / blank */
body.blank { background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 60%, #2a2140 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.center-card { background: #fff; border-radius: 12px; padding: 30px; width: 100%; max-width: 420px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.center-card.wide { max-width: 760px; }
.auth-logo { height: 72px; display: block; margin: 0 auto 16px; border-radius: 4px; }
pre.debug { background: #111; color: #eee; font-size: 11px; padding: 10px; overflow: auto; max-height: 300px; border-radius: 6px; }

details.more summary { cursor: pointer; color: var(--blue); font-size: 13px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.pill { display: inline-block; padding: 2px 8px; background: var(--grey-l); border-radius: 6px; font-size: 12px; }
.code-box { background: #f6f8fb; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.perm-grid { columns: 3 220px; column-gap: 20px; }
.perm-grid .grp { break-inside: avoid; margin-bottom: 12px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g-main-side { grid-template-columns: 1fr; } .sticky-side { position: static; } }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; z-index: 40; transition: left .15s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.open { left: 0; }
  .only-mobile { display: inline-block; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 16px; }
  .hide-mobile { display: none; }
  .global-search input { font-size: 14px; }
  .doc-frame { height: 80vh; }
}
@media print { .sidebar, .topbar, .page-actions, .filters, .pager, .no-print { display: none !important; } .content { padding: 0; } .card { box-shadow: none; } }

/* stamp question dialog + small dropdown menus */
dialog.modal { border: 0; border-radius: 12px; padding: 22px 24px; max-width: 480px; width: calc(100% - 32px); box-shadow: 0 24px 60px rgba(0,0,0,.3); color: var(--text); }
dialog.modal::backdrop { background: rgba(15, 28, 51, .55); }
details.menu-btn { position: relative; display: inline-block; }
details.menu-btn > summary { list-style: none; }
details.menu-btn > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 40px; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 8px 0; min-width: 260px; }
.menu-pop > span { display: block; padding: 4px 14px 8px; }
.menu-pop a { display: block; padding: 7px 14px; color: var(--text); }
.menu-pop a:hover { background: var(--bg); text-decoration: none; }

.fmt-group { grid-column: 1 / -1; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 4px; }
