:root {
  --black: #0d0d0d; --ink: #161616; --char: #1f1f1f; --char2: #2a2a2a;
  --g1: #f6f6f4; --g2: #ececea; --g3: #d9d9d6; --g4: #a3a3a0; --g5: #6e6e6b; --g6: #3d3d3b;
  --ball: #d4f23a; --ball-d: #b9d61f; --ball-soft: #f3fbcf;
  --red: #d64541; --red-soft: #fde8e7; --amber: #e8a317; --amber-soft: #fdf2dc; --green: #2e9e5b; --green-soft: #e3f4ea; --blue: #3a6fd8; --blue-soft: #e6eefc;
  --bg: var(--g1); --card: #fff; --text: var(--ink); --muted: var(--g5); --line: var(--g2);
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.boot { height: 100vh; display: grid; place-items: center; background: var(--black); }
.tball { width: 42px; height: 42px; border-radius: 50%; background: var(--ball); position: relative; animation: bounce .7s ease-in-out infinite alternate; }
.tball::before, .tball::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 3px solid #fff; border-color: transparent #fff transparent transparent; transform: translateX(-55%); }
.tball::after { transform: translateX(55%) rotate(180deg); }
@keyframes bounce { from { transform: translateY(-14px); } to { transform: translateY(14px); } }

/* Layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--black); color: #fff; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.logo .mk { width: 36px; height: 36px; border-radius: 50%; background: var(--ball); color: var(--black); display: grid; place-items: center; font-weight: 900; font-size: 18px; }
.logo b { display: block; font-size: 15px; letter-spacing: .02em; } .logo small { color: var(--g4); font-size: 11.5px; }
.nav { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #cfcfcc; text-decoration: none; font-weight: 500; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; }
.nav:hover { background: var(--char); color: #fff; }
.nav.on { background: var(--char2); color: #fff; box-shadow: inset 3px 0 0 var(--ball); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .badge { margin-left: auto; background: var(--ball); color: var(--black); border-radius: 999px; font-size: 11px; font-weight: 800; padding: 1px 8px; }
.side .spacer { flex: 1; }
.side .who { color: var(--g4); font-size: 12px; padding: 10px 12px; border-top: 1px solid var(--char2); margin-top: 8px; }
.main { min-width: 0; padding: 26px 32px 60px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.top h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; font-weight: 800; }
.top .sub { color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.mobile-bar { display: none; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--g3); background: #fff; padding: 9px 15px; border-radius: 10px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--g4); background: var(--g1); }
.btn.primary { background: var(--black); color: #fff; border-color: var(--black); }
.btn.primary:hover { background: var(--char2); }
.btn.ball { background: var(--ball); border-color: var(--ball); color: var(--black); }
.btn.ball:hover { background: var(--ball-d); }
.btn.danger { color: var(--red); } .btn.danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--g2); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--g6); }
.in, select.in, textarea.in { width: 100%; border: 1px solid var(--g3); border-radius: 10px; padding: 9px 12px; background: #fff; outline: none; font-size: 14px; font-weight: 400; color: var(--text); }
.in:focus { border-color: var(--black); box-shadow: 0 0 0 3px var(--ball-soft); }
textarea.in { resize: vertical; min-height: 40px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--black); }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.card .hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 0; }
.card .hd h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card .bd { padding: 16px 18px 18px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.cols.even { grid-template-columns: 1fr 1fr; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 18px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.kpi .v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi.dark { background: var(--black); color: #fff; border-color: var(--black); }
.kpi.dark .l, .kpi.dark .s { color: var(--g4); }
.kpi.dark .v { color: var(--ball); }
.kpi.dark::after { content: ""; position: absolute; right: -30px; bottom: -30px; width: 110px; height: 110px; border-radius: 50%; border: 10px solid rgba(212,242,58,.14); }

/* Tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fcfcfb; position: sticky; top: 0; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--g1); }
.tbl .nw { white-space: nowrap; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { font-weight: 800; border-bottom: 0; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .b { font-weight: 700; }
.mono { font-variant-numeric: tabular-nums; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.draft { background: var(--g2); color: var(--g6); }
.pill.sent { background: var(--blue-soft); color: var(--blue); }
.pill.overdue { background: var(--red-soft); color: var(--red); }
.pill.part { background: var(--amber-soft); color: #a06c00; }
.pill.paid { background: var(--green-soft); color: var(--green); }
.pill.void { background: var(--g2); color: var(--g4); text-decoration: line-through; }
.pill.unverified { background: var(--ball-soft); color: #5d6b00; }

/* Tabs */
.tabs { display: flex; gap: 4px; background: #fff; border: 1px solid var(--line); padding: 4px; border-radius: 12px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 7px 13px; border-radius: 8px; font-weight: 600; color: var(--g5); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); background: var(--g1); }
.tab.on { background: var(--black); color: #fff; }
.tab .n { opacity: .65; margin-left: 5px; font-weight: 500; }

/* Chart */
.chart { width: 100%; height: 230px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.ageing-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--g2); }
.ageing-bar span { display: block; height: 100%; }
.ageing-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-top: 14px; }
.ageing-list div { display: flex; justify-content: space-between; font-size: 13px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }

/* Lists */
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--g2); display: grid; place-items: center; font-weight: 800; font-size: 12.5px; color: var(--g6); flex: none; }
.avatar.ball { background: var(--ball); color: var(--black); }
.alert { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 12px; background: var(--ball-soft); border: 1px solid #e4f59a; }
.alert.dark { background: var(--black); color: #fff; border-color: var(--black); }
.alert.dark .muted { color: var(--g4); }

/* Invoice editor */
.lines-ed { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.lines-ed th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 0 6px; }
.lines-ed td { padding: 0 4px; vertical-align: top; }
.lines-ed .in { padding: 8px 10px; }
.lines-ed textarea.in { min-height: 38px; }
.tot-box { margin-left: auto; width: 320px; }
.tot-box div { display: flex; justify-content: space-between; padding: 7px 0; font-variant-numeric: tabular-nums; }
.tot-box .g { border-top: 2px solid var(--black); font-weight: 800; font-size: 18px; padding-top: 10px; }

/* Detail */
.doc-lines td { padding: 9px 10px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.big-amt { font-size: 32px; font-weight: 900; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* Modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(10,10,10,.45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal.wide { max-width: 760px; }
.modal .mh { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal .mh h3 { margin: 0; font-size: 17px; }
.modal .mb { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal .mf { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--black); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.3); display: flex; gap: 10px; align-items: center; animation: up .2s; max-width: calc(100vw - 32px); }
.toast::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ball); flex: none; }
.toast.err::before { background: var(--red); }
@keyframes fade { from { opacity: 0; } } @keyframes up { from { transform: translate(-50%, 10px); opacity: 0; } }
.err-box { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.share-box { display: flex; gap: 8px; } .share-box .in { font-size: 12.5px; color: var(--g5); }
iframe.preview { width: 100%; height: 760px; border: 1px solid var(--line); border-radius: 12px; background: #e9e9e6; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .art { background: var(--black); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .art h2 { font-size: 44px; line-height: 1.05; letter-spacing: -.03em; margin: 0; max-width: 460px; }
.login .art h2 em { font-style: normal; color: var(--ball); }
.court { position: absolute; right: -80px; bottom: -60px; width: 420px; height: 300px; border: 3px solid rgba(255,255,255,.12); border-radius: 6px; }
.court::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 3px solid rgba(255,255,255,.12); }
.court::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 3px solid rgba(255,255,255,.12); }
.login .bigball { position: absolute; right: 120px; top: 90px; width: 90px; height: 90px; border-radius: 50%; background: var(--ball); box-shadow: 0 20px 60px rgba(212,242,58,.35); }
.login form { align-self: center; justify-self: center; width: 100%; max-width: 380px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.login form h1 { margin: 0 0 4px; font-size: 26px; }

/* Responsive */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } .cols { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; background: var(--black); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 30; }
  .main { padding: 18px 16px 60px; }
  .grid2, .grid3, .grid4, .cols.even { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; } .login .art { min-height: 220px; padding: 28px; } .login .art h2 { font-size: 30px; }
  .hide-sm { display: none; } .tot-box { width: 100%; }
  .lines-ed, .lines-ed tbody, .lines-ed tr, .lines-ed td { display: block; width: 100%; }
  .lines-ed thead { display: none; }
  .lines-ed tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .lines-ed td.desc, .lines-ed td.dt { grid-column: 1 / -1; }
  .top h1 { font-size: 22px; }
}
.kpis.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .kpis.three { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr; } }
