:root {
  --navy: #0a1c43; --navy-2: #082a68; --navy-3: #12357e; --y: #ffbd0b; --y-d: #e6a800;
  --bg: #f2f5fa; --card: #fff; --line: #e3e8f1; --text: #14203a; --mute: #66728a;
  --ok: #16865a; --ok-bg: #e4f5ec; --warn: #a96500; --warn-bg: #fff3d6; --bad: #c42c2c; --bad-bg: #fde7e7; --info: #1f5bd1; --info-bg: #e6eeff;
  --r: 12px; --sh: 0 1px 2px rgba(10,28,67,.06), 0 6px 20px rgba(10,28,67,.06);
}
* { box-sizing: border-box; }
body { margin: 0; font: 400 14.5px/1.5 Inter, system-ui, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: #fff; padding: 9px 15px; border-radius: 9px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .2s, border-color .2s, transform .1s; }
.btn:hover { border-color: #c9d2e3; background: #f8fafd; }
.btn:active { transform: scale(.98); }
.btn-y { background: var(--y); border-color: var(--y); color: var(--navy); }
.btn-y:hover { background: #ffc934; border-color: #ffc934; }
.btn-n { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-n:hover { background: var(--navy-2); border-color: var(--navy-2); }
.btn-g { background: #1faa59; border-color: #1faa59; color: #fff; }
.btn-g:hover { background: #18934c; border-color: #18934c; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; padding: 13px; }
.btn svg { width: 16px; height: 16px; }
.link { background: none; border: 0; color: var(--mute); cursor: pointer; padding: 0; font-size: 13px; text-decoration: underline; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 80% -10%, #12357e 0%, transparent 60%), var(--navy); }
.login-card { width: min(400px, 100%); background: #fff; border-radius: 18px; padding: 34px 30px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-logo { width: 100%; max-width: 300px; display: block; margin: 0 auto 18px; }
.login-card h1 { font-size: 24px; text-align: center; color: var(--navy); }
.login-card > p { text-align: center; color: var(--mute); margin: 6px 0 22px; }
.login-note { display: block; text-align: center; margin-top: 14px; color: var(--mute); font-size: 12.5px; }
.fld { display: block; margin-bottom: 14px; }
.fld span { display: block; font-size: 12.5px; font-weight: 600; color: var(--mute); margin-bottom: 5px; }
.fld input, .fld select, .fld textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: #fff; outline: none; transition: border-color .2s, box-shadow .2s; }
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--navy-3); box-shadow: 0 0 0 3px rgba(18,53,126,.12); }

/* layout */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #c9d4ea; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-logo { margin: 16px; background: #fff; border-radius: 12px; padding: 10px 12px; }
.side-logo img { width: 100%; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; font-weight: 500; transition: background .2s, color .2s; }
.nav a svg { width: 19px; height: 19px; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: var(--y); color: var(--navy); font-weight: 700; }
.side-foot { margin-top: auto; padding: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.me { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.me > b { width: 36px; height: 36px; border-radius: 50%; background: var(--y); color: var(--navy); display: grid; place-items: center; font-size: 13px; }
.me strong { display: block; color: #fff; font-size: 13.5px; }
.me small { color: #93a3c4; }
.side .link { color: #93a3c4; }

.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 14px 28px; background: rgba(242,245,250,.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.search svg { width: 17px; height: 17px; color: var(--mute); flex: none; }
.search input { border: 0; outline: none; padding: 10px 0; width: 100%; background: none; }
.top-r { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill-demo { font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-bg); padding: 4px 10px; border-radius: 20px; }
.newmenu { position: absolute; right: 28px; top: 62px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh); padding: 6px; display: flex; flex-direction: column; min-width: 180px; }
.newmenu button { text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.newmenu button:hover { background: var(--bg); }

.view { padding: 26px 28px 60px; max-width: 1280px; }
.hd { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.hd h2 { font-size: 26px; color: var(--navy); }
.hd p { color: var(--mute); margin-top: 2px; }
.hd-act { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--mute); font-weight: 500; margin-bottom: 8px; cursor: pointer; }
.back:hover { color: var(--navy); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-h h3 { font-size: 15.5px; color: var(--navy); }
.card-b { padding: 18px; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 18px; position: relative; overflow: hidden; cursor: pointer; transition: transform .2s, box-shadow .2s; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(10,28,67,.1); }
.kpi small { color: var(--mute); font-weight: 600; font-size: 12.5px; }
.kpi b { display: block; font-size: 26px; font-weight: 800; color: var(--navy); margin-top: 6px; letter-spacing: -.02em; }
.kpi span { font-size: 12.5px; color: var(--mute); }
.kpi::after { content: ""; position: absolute; right: -20px; top: -20px; width: 70px; height: 70px; border-radius: 50%; background: var(--k, var(--y)); opacity: .14; }
.kpi.k1 { background: var(--navy); border-color: var(--navy); }
.kpi.k1 small, .kpi.k1 span { color: #a9b8d8; }
.kpi.k1 b { color: var(--y); }
.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; margin-bottom: 14px; }
.chart { width: 100%; height: 230px; display: block; }
.chart text { font-size: 11px; fill: var(--mute); font-family: Inter, sans-serif; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--mute); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.feed li:last-child { border-bottom: 0; }
.feed li:hover { background: #fafbfe; }
.feed .dot { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--bg); color: var(--navy); }
.feed .dot svg { width: 16px; height: 16px; }
.feed b { font-weight: 600; }
.feed small { display: block; color: var(--mute); font-size: 12.5px; }
.feed .amt { margin-left: auto; font-weight: 700; white-space: nowrap; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; padding: 11px 16px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .15s; }
tbody tr:hover { background: #f8fafd; }
tbody tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
td .sub { display: block; color: var(--mute); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.empty { padding: 40px; text-align: center; color: var(--mute); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { border: 1px solid var(--line); background: #fff; padding: 7px 13px; border-radius: 30px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--mute); }
.tab b { font-weight: 700; margin-left: 4px; color: var(--text); }
.tab.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.tab.on b { color: var(--y); }

.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-paid, .st-accepted, .st-delivered { color: var(--ok); background: var(--ok-bg); }
.st-unpaid, .st-sent, .st-booked { color: var(--info); background: var(--info-bg); }
.st-overdue, .st-declined { color: var(--bad); background: var(--bad-bg); }
.st-draft, .st-quoted { color: #555f73; background: #eef1f6; }
.st-workshop, .st-part { color: var(--warn); background: var(--warn-bg); }
.st-ready { color: #6d3fc0; background: #efe7ff; }

/* jobs board */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #e9eef6; border-radius: 12px; padding: 10px; min-height: 300px; }
.col-h { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; font-weight: 700; font-size: 13px; color: var(--navy); }
.col-h span { background: #fff; border-radius: 20px; padding: 1px 9px; font-size: 12px; }
.col.drop { outline: 2px dashed var(--navy-3); outline-offset: -2px; }
.jc { background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(10,28,67,.08); cursor: grab; border-left: 3px solid var(--c, var(--y)); transition: box-shadow .2s, transform .2s; }
.jc:hover { box-shadow: 0 8px 20px rgba(10,28,67,.12); }
.jc.dragging { opacity: .5; }
.jc small { color: var(--mute); font-size: 12px; font-weight: 600; }
.jc h4 { margin: 3px 0 4px; font-size: 14px; line-height: 1.3; }
.jc p { margin: 0; color: var(--mute); font-size: 12.5px; }
.jc-f { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; color: var(--mute); }
.jc-f .due-late { color: var(--bad); font-weight: 600; }
.jc-move { display: none; }

/* documents / editor */
.doc-grid { display: grid; grid-template-columns: 1fr 320px; gap: 14px; align-items: start; }
.lines { width: 100%; }
.lines th, .lines td { padding: 8px 6px; }
.lines td input, .lines td select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px; outline: none; background: #fff; }
.lines td input:focus { border-color: var(--navy-3); }
.lines .x { background: none; border: 0; color: var(--mute); cursor: pointer; font-size: 20px; line-height: 1; padding: 4px 8px; }
.lines .x:hover { color: var(--bad); }
.lines tbody tr { cursor: default; }
.lines tbody tr:hover { background: none; }
.totals { margin-left: auto; width: min(320px, 100%); margin-top: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .grand { border-top: 2px solid var(--navy); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 800; color: var(--navy); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.quick button { border: 1px dashed #b9c4da; background: #fafbfe; border-radius: 20px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; color: var(--navy); font-weight: 500; }
.quick button:hover { border-style: solid; background: #fff; }
.side-card .fld { margin-bottom: 12px; }
.meta { list-style: none; margin: 0; padding: 0; }
.meta li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.meta li:last-child { border: 0; }
.meta span { color: var(--mute); }
.meta b { font-weight: 600; text-align: right; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.pay-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 6px 0; }

/* customer */
.cust-top { display: flex; gap: 16px; align-items: center; }
.avatar { width: 54px; height: 54px; border-radius: 14px; background: var(--navy); color: var(--y); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.mini-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.mini-kpis div { background: var(--bg); border-radius: 10px; padding: 12px; }
.mini-kpis small { color: var(--mute); font-size: 12px; font-weight: 600; }
.mini-kpis b { display: block; font-size: 18px; color: var(--navy); }

/* modal */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(10,28,67,.5); display: grid; place-items: center; padding: 20px; animation: fade .2s; }
.modal-box { background: #fff; border-radius: 16px; width: min(520px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.3); animation: pop .25s cubic-bezier(.2,.8,.2,1); }
.modal-box.wide { width: min(860px, 100%); background: #e9edf4; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 1; gap: 8px; flex-wrap: wrap; }
.modal-h h3 { color: var(--navy); }
.modal-b { padding: 20px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* printable document */
.paper { background: #fff; margin: 20px; padding: 44px 46px; border-radius: 4px; box-shadow: 0 10px 40px rgba(10,28,67,.15); color: #14203a; font-size: 13px; }
.p-top { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 3px solid var(--navy); padding-bottom: 18px; }
.p-top img { width: 250px; }
.p-co { text-align: right; font-size: 12px; color: #4b5670; line-height: 1.55; }
.p-title { display: flex; justify-content: space-between; align-items: flex-end; margin: 24px 0 18px; gap: 20px; }
.p-title h1 { font-size: 30px; color: var(--navy); letter-spacing: .02em; }
.p-title .p-no { text-align: right; font-size: 12.5px; line-height: 1.7; }
.p-title .p-no b { font-size: 15px; color: var(--navy); }
.p-to { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.p-to h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8590a6; }
.p-to p { margin: 0; line-height: 1.55; }
.p-lines { width: 100%; border-collapse: collapse; }
.p-lines th { background: var(--navy); color: #fff; text-transform: none; letter-spacing: 0; font-size: 12px; padding: 9px 10px; }
.p-lines td { padding: 9px 10px; border-bottom: 1px solid #e6eaf2; font-size: 12.5px; cursor: default; }
.p-lines tr:nth-child(even) td { background: #f7f9fc; }
.p-tot { width: 280px; margin: 16px 0 0 auto; }
.p-tot div { display: flex; justify-content: space-between; padding: 5px 10px; }
.p-tot .grand { background: var(--y); font-weight: 800; font-size: 15px; color: var(--navy); border-radius: 4px; margin-top: 4px; padding: 9px 10px; }
.p-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 30px; padding-top: 16px; border-top: 1px solid #e6eaf2; font-size: 12px; color: #4b5670; line-height: 1.6; }
.p-foot h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--navy); }
.p-stamp { display: inline-block; border: 3px solid var(--ok); color: var(--ok); font-weight: 800; font-size: 20px; padding: 4px 16px; border-radius: 6px; transform: rotate(-8deg); letter-spacing: .1em; }
.print { display: none; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 80; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast b { color: var(--y); }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid2, .doc-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 40; flex-direction: row; padding-bottom: env(safe-area-inset-bottom); }
  .side-logo, .side-foot { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; padding: 6px; }
  .nav a { flex-direction: column; gap: 3px; padding: 7px 4px; font-size: 10.5px; flex: 1; text-align: center; }
  .nav a[data-r="prices"] { display: none; }
  .top { padding: 10px 14px; flex-wrap: wrap; }
  .top::before { content: ""; width: 100%; height: 34px; background: url(img/logo.webp) left center / contain no-repeat; order: -1; }
  .search { order: 2; max-width: none; flex-basis: 100%; }
  .top-r { position: absolute; right: 14px; top: 10px; }
  .newmenu { right: 14px; top: 52px; }
  .view { padding: 18px 14px 110px; }
  .hd h2 { font-size: 22px; }
  .kpi b { font-size: 21px; }
  .board { display: flex; flex-direction: column; overflow: visible; }
  .col { min-height: 0; }
  .jc-move { display: block; width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 12.5px; background: #fafbfe; }
  .hide-m { display: none; }
  td, th { padding: 11px 10px; }
  .paper { margin: 10px; padding: 22px 18px; }
  .p-top { flex-direction: column; }
  .p-top img { width: 200px; }
  .p-co { text-align: left; }
  .p-to, .p-foot, .row2 { grid-template-columns: 1fr; }
  .lines thead { display: none; }
  .lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .lines td { padding: 0; border: 0; }
  .lines td:first-child { grid-column: 1 / -1; }
  .modal { padding: 0; align-items: end; }
  .modal-box { border-radius: 16px 16px 0 0; max-height: 92vh; }
  .mini-kpis { grid-template-columns: 1fr 1fr 1fr; }
  .mini-kpis b { font-size: 15px; }
}
@media print {
  body > *:not(.print) { display: none !important; }
  .print { display: block !important; }
  .print .paper { margin: 0; box-shadow: none; padding: 0; }
  @page { size: A4; margin: 14mm; }
}

.num, .lt, .p-lines td.r, .totals b, .feed .amt { white-space: nowrap; }
@media (max-width: 820px) { .p-lines th, .p-lines td { padding: 7px 5px; font-size: 11.5px; } }
