/* Bizarre ERP */
:root {
  --navy: #14213d; --navy-2: #1d2d50; --accent: #e07a2c; --accent-d: #c4651c;
  --bg: #f5f4f0; --card: #ffffff; --line: #e3e1da; --line-2: #eeece6;
  --ink: #1c1c1e; --ink-2: #55534e; --ink-3: #8a877f;
  --good: #1f7a4d; --good-bg: #e3f3ea; --warn: #9a6200; --warn-bg: #fdf1d8; --bad: #b42318; --bad-bg: #fde7e4; --info: #1d5fb4; --info-bg: #e5eefb;
  --series-1: #2a78d6; --radius: 10px; --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 2px 8px rgba(20, 33, 61, .04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.45; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .2rem; font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1.02rem; margin: 0 0 .7rem; font-weight: 620; }
.muted { color: var(--ink-3); } .pad { padding: .6rem 0; } .bad-text { color: var(--bad); }
.loading { padding: 2rem; color: var(--ink-3); }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--ink-3); }
.note { background: var(--warn-bg); color: var(--warn); padding: .5rem .8rem; border-radius: 8px; margin: .5rem 0; display: inline-block; }
.help { color: var(--ink-2); margin: .2rem 0 0; max-width: 72ch; font-size: .92rem; }

/* shell */
#shell { display: flex; min-height: 100vh; }
#side { width: 248px; background: var(--navy); color: #cfd6e6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.1rem; font-weight: 650; color: #fff; font-size: 1.02rem; }
.brand.big { font-size: 1.35rem; color: var(--navy); justify-content: center; margin-bottom: 1rem; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
#nav { overflow-y: auto; flex: 1; padding: 0 .55rem 1rem; }
.nav-sec { margin-top: .7rem; }
.nav-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7f8bab; padding: .3rem .6rem; }
#nav a { display: block; color: #d8deeb; padding: .38rem .6rem; border-radius: 7px; font-size: .92rem; }
#nav a:hover { background: var(--navy-2); text-decoration: none; }
#nav a.active { background: var(--accent); color: #fff; }
.side-foot { border-top: 1px solid #2a3a60; padding: .8rem 1rem; font-size: .82rem; display: flex; flex-wrap: wrap; gap: .3rem .8rem; align-items: center; }
.side-foot span { flex-basis: 100%; color: #aab4cc; }
.link { background: none; border: 0; color: #fff; cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
#main { flex: 1; min-width: 0; }
#top { display: none; }
#view { padding: 1.4rem 1.8rem 4rem; max-width: 1400px; outline: none; }
#scrim { display: none; }

/* page */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.back { font-size: .85rem; display: inline-block; margin-bottom: .3rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.cols > .card { margin-bottom: 0; }
.child-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; gap: .5rem; }
.child-head h2 { margin: 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: .5rem .9rem; border-radius: 8px;
  font: inherit; font-size: .9rem; font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 38px; }
.btn:hover { background: #f8f7f4; text-decoration: none; border-color: #d3d0c7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); } .btn.danger.primary { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.small { padding: .25rem .6rem; min-height: 30px; font-size: .84rem; }
.btn.big { padding: .7rem 1.3rem; font-size: 1rem; } .btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: wait; }
.icon-btn { background: none; border: 0; font-size: 1.25rem; line-height: 1; cursor: pointer; color: var(--ink-3); padding: .25rem .45rem; border-radius: 6px; min-width: 32px; min-height: 32px; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

/* forms */
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .85rem 1.1rem; }
.grid-form.one { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: .28rem; font-size: .84rem; color: var(--ink-2); border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { font-weight: 550; }
.field.wide, .grid-form .wide { grid-column: 1 / -1; }
.field.check { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: .55rem; padding-top: 1.4rem; }
.field small { color: var(--ink-3); font-size: .78rem; }
input, select, textarea { font: inherit; font-size: .94rem; color: var(--ink); background: #fff; border: 1px solid #d6d3ca; border-radius: 7px; padding: .48rem .6rem; width: 100%; min-height: 38px; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { background: #f6f5f1; color: var(--ink-2); border-color: var(--line-2); }
input.num { text-align: right; }
input.invalid, select.invalid { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
textarea { resize: vertical; }
.form-foot { display: flex; gap: .6rem; align-items: center; margin: .2rem 0 1rem; flex-wrap: wrap; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .45rem 1rem; }
.check-row { display: flex; gap: .55rem; align-items: center; font-size: .92rem; color: var(--ink); }
.error { color: var(--bad); min-height: 1.2em; }

/* filters & tables */
.filters { display: flex; gap: .55rem; flex-wrap: wrap; margin-bottom: .8rem; align-items: center; }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; }
.inline { display: inline-flex; gap: .4rem; align-items: center; font-size: .85rem; color: var(--ink-2); white-space: nowrap; }
.inline input[type=date] { width: auto; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { border: 0; box-shadow: none; border-radius: 0; margin: 0 -.2rem; }
table { border-collapse: collapse; width: 100%; }
table.list th, table.grid th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; padding: .6rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfaf8; }
table.list td { padding: .55rem .75rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.list tbody tr[data-id] { cursor: pointer; }
table.list tbody tr[data-id]:hover, table.list tbody tr[data-id]:focus { background: #faf6f1; outline: none; }
table.list tfoot td, table.grid tfoot td { padding: .6rem .75rem; font-weight: 650; border-top: 1px solid var(--line); }
table.compact td { padding: .35rem .6rem; font-size: .88rem; }
tr.low td { background: var(--warn-bg); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
th.chk, td.chk { width: 36px; }
table.grid td { padding: .3rem .35rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.grid td input:not([type=checkbox]), table.grid td select, table.grid td textarea { min-width: 90px; padding: .38rem .45rem; min-height: 34px; }
table.grid td select[data-ref] { min-width: 220px; }
.child { padding-bottom: .6rem; }
.pager { display: flex; gap: .7rem; align-items: center; justify-content: flex-end; padding: .7rem 0; color: var(--ink-3); font-size: .88rem; }
.bulkbar { display: flex; gap: .6rem; align-items: center; background: var(--info-bg); padding: .5rem .8rem; border-radius: 8px; margin-bottom: .6rem; }
.history { margin-top: .6rem; color: var(--ink-2); font-size: .9rem; }
.history summary { cursor: pointer; padding: .3rem 0; }

/* badges */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: .14rem .55rem; border-radius: 99px; text-transform: capitalize; white-space: nowrap; letter-spacing: .01em; vertical-align: middle; }
.badge.good { background: var(--good-bg); color: var(--good); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--info-bg); color: var(--info); }
.badge.muted { background: #efede8; color: var(--ink-2); }

/* dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.tiles.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .15rem; color: var(--ink); box-shadow: var(--shadow); }
a.tile[href]:hover { border-color: var(--accent); text-decoration: none; }
.tile-label { font-size: .8rem; color: var(--ink-2); font-weight: 550; }
.tile-value { font-size: 1.5rem; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile-sub { font-size: .8rem; color: var(--ink-3); }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: .42rem 0; border-bottom: 1px solid var(--line-2); font-size: .9rem; }
ul.plain li:last-child { border-bottom: 0; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; max-height: 260px; }
.chart .gridline { stroke: var(--line-2); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font-size: 11px; }
.chart .barfill { fill: var(--series-1); }
.chart .bar:hover .barfill { fill: #1f62b3; }
.tip { position: absolute; background: var(--ink); color: #fff; font-size: .8rem; padding: .35rem .55rem; border-radius: 6px; pointer-events: none; white-space: nowrap; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.report-card { color: var(--ink); margin: 0; } .report-card:hover { border-color: var(--accent); text-decoration: none; }
.report-card p { margin: 0; }

/* sign-in */
.center-card { max-width: 400px; margin: 9vh auto; background: #fff; padding: 2rem; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.center-card.wide { max-width: 760px; }
.center-card form { display: flex; flex-direction: column; gap: .9rem; }
.center-card form.grid-form { display: grid; }

/* modal & toasts */
.modal-wrap { position: fixed; inset: 0; background: rgba(20, 33, 61, .38); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal { background: #fff; border-radius: 12px; width: min(480px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .2); }
.modal.wide { width: min(800px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem .4rem; }
.modal-head h2 { margin: 0; }
.modal-body { padding: .5rem 1.2rem 1rem; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1.2rem; border-top: 1px solid var(--line-2); }
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 60; max-width: min(420px, calc(100vw - 2rem)); }
.toast { background: var(--navy); color: #fff; padding: .7rem 1rem; border-radius: 9px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font-size: .9rem; transition: opacity .4s, transform .4s; white-space: pre-line; }
.toast.error { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* documents */
.doc-bar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.doc { background: #fff; max-width: 210mm; margin: 0 auto; padding: 14mm 14mm; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 12.5px; color: #111; }
.doc h2 { font-size: 13px; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .05em; color: #444; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--navy); padding-bottom: 10px; margin-bottom: 14px; }
.doc-co { font-size: 19px; font-weight: 700; color: var(--navy); }
.doc-title { text-align: right; } .doc-title h1 { font-size: 20px; justify-content: flex-end; text-transform: uppercase; letter-spacing: .06em; color: var(--navy); }
.doc-small { font-size: 11px; color: #555; }
.doc-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: #666; margin-bottom: 3px; font-weight: 600; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 14px; }
.doc-kv { width: auto; margin-left: auto; } .doc-parties .doc-kv { margin-left: 0; width: 100%; }
.doc-kv th { text-align: left; font-weight: 600; color: #555; padding: 2px 12px 2px 0; white-space: nowrap; vertical-align: top; }
.doc-kv td { padding: 2px 0; }
.doc-kv.totals { margin: 10px 0 10px auto; min-width: 280px; } .doc-kv.totals td { padding-left: 20px; }
.doc-lines { margin: 6px 0 10px; }
.doc-lines th { background: #f1f0ec; text-align: left; padding: 6px; font-size: 11px; border-bottom: 1px solid #ccc; }
.doc-lines td { padding: 5px 6px; border-bottom: 1px solid #e6e6e6; vertical-align: top; }
.doc-lines tfoot td { border-bottom: 0; padding: 4px 6px; }
.doc .grand td, .doc .grand th { font-weight: 700; font-size: 13.5px; border-top: 2px solid #333; }
.doc-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 12px; }
.doc-sign { margin-top: 40px; display: flex; justify-content: flex-end; }
.doc-sign div { border-top: 1px solid #333; padding-top: 4px; min-width: 200px; text-align: center; font-size: 11px; }
.doc-sign.two { justify-content: space-between; }
.payslip { page-break-after: always; margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px dashed #bbb; }
.payslip:last-child { page-break-after: auto; border-bottom: 0; }

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  #side, #top, .no-print, .page-head .head-actions, .filters, .toast, .back, .history, .form-foot { display: none !important; }
  #view { padding: 0; max-width: none; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .card, .table-wrap, .tile { box-shadow: none; }
}

@media (max-width: 860px) {
  #side { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .nav-open #side { transform: none; }
  .nav-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 30; }
  #top { display: flex; align-items: center; gap: .5rem; background: var(--navy); color: #fff; padding: .5rem .7rem; position: sticky; top: 0; z-index: 20; }
  #top .icon-btn { color: #fff; font-size: 1.4rem; }
  #top .icon-btn:hover, #top .icon-btn:focus { background: rgba(255,255,255,.14); color: #fff; }
  .tiles, .tiles.small { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .top-title { font-weight: 600; }
  #view { padding: 1rem .8rem 4rem; }
  h1 { font-size: 1.25rem; }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .doc-parties, .doc-foot { grid-template-columns: 1fr; }
  .doc { padding: 6mm; }
}
@media (max-width: 520px) {
  .grid-form { grid-template-columns: 1fr; }
  .filters input[type=search] { max-width: none; }
  .tile-value { font-size: 1.25rem; }
  .field.check { padding-top: 0; }
}

/* accounting */
.good-text { color: var(--good); }
.group-title { margin: 1.2rem 0 .6rem; color: var(--ink-2); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.wide-select { width: auto; max-width: 340px; }
.statement table { width: 100%; }
.statement td { padding: .4rem .5rem; border-bottom: 1px solid var(--line-2); }
.statement tr.sec td { font-weight: 650; padding-top: .9rem; border-bottom: 1px solid var(--line); text-transform: uppercase; font-size: .8rem; letter-spacing: .05em; color: var(--ink-2); }
.statement tr.grp td { font-weight: 600; color: var(--ink-2); padding-left: .8rem; }
.statement td.indent { padding-left: 1.4rem; }
.statement tr.sub td { font-weight: 600; border-top: 1px solid var(--line); }
.statement tr.grand td { font-weight: 700; font-size: 1.02rem; border-top: 2px solid var(--ink); border-bottom: 0; background: #fbfaf8; }

.table-wrap + .cols, .table-wrap + p, .table-wrap + section, .tiles + .table-wrap { margin-top: 1rem; }

/* TNA, matrix, carton labels, trace */
table.tna td input { min-width: 110px; padding: .35rem .45rem; min-height: 32px; }
table.tna td:first-child input { min-width: 220px; }
table.tna tr.late td { background: var(--bad-bg); }
table.matrix th, table.matrix td { text-align: center; }
table.matrix input { width: 80px; min-width: 0; }
.trace-mat { font-size: .92rem; margin: 1rem 0 .4rem; }
.carton-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; }
.carton { border: 2px solid #000; padding: 4mm; page-break-inside: avoid; font-size: 12px; }
.carton .c-top { display: flex; justify-content: space-between; border-bottom: 1px solid #000; padding-bottom: 2mm; margin-bottom: 2mm; font-size: 13px; }
.carton .c-row { display: flex; justify-content: space-between; padding: 1mm 0; }
.carton .c-row span { color: #444; }
.carton .c-big { font-size: 20px; font-weight: 800; text-align: center; margin: 3mm 0 2mm; letter-spacing: .04em; }
.carton .c-foot { text-align: center; font-size: 10px; letter-spacing: .06em; }

.perm-grid th.c, .perm-grid td.c { text-align: center; } .perm-grid input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
