/* ChicShop Compta — v2 theme, built from the shop's logo: blush pink, ink black, rose gold */
@font-face { font-family: 'Jakarta'; src: url('/fonts/jakarta-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('/fonts/jakarta-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('/fonts/jakarta-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('/fonts/jakarta-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('/fonts/jakarta-800.woff2') format('woff2'); font-weight: 800; font-style: normal; font-display: swap; }

:root {
  --bg: #fcf4f5;
  --surface: #ffffff;
  --surface-2: #fdf0f2;
  --ink: #1f1418;
  --ink-2: #5d4950;
  --ink-3: #9b858c;
  --line: #f0dfe3;
  --brand: #c43d71;
  --brand-ink: #ffffff;
  --brand-soft: #fbe4ec;
  --gold: #b07a5b;
  --gold-soft: #f6e9e1;
  --night: #1f1418;
  --pos: #1d7a50;
  --neg: #c23a32;
  --warn: #a96400;
  --warn-soft: #fdf1df;
  --neg-soft: #fbe9e7;
  --pos-soft: #e5f3ec;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(31, 20, 24, .04), 0 8px 24px rgba(196, 61, 113, .07);
  --nav-h: 66px;
  --font: "Jakarta", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: var(--font);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 500 15px/1.45 var(--font);
  font-feature-settings: "tnum" 1;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  -webkit-font-smoothing: antialiased;
}
.num, .amount, .big, .val { font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.topbar h1 { font-family: var(--font); font-weight: 800; font-size: 21px; margin: 0; flex: 1; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brandmark { width: 40px; height: 40px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px var(--line); object-fit: cover; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none;
}
.icon-btn:active { background: var(--brand-soft); }
.icon-btn svg { width: 22px; height: 22px; }

main { padding: 4px 16px 16px; max-width: 640px; margin: 0 auto; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--surface); border-top: 1px solid var(--line);
}
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--ink-3); padding: 6px 0; }
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--brand); font-weight: 700; }
.nav .plus {
  justify-self: center; width: 58px; height: 58px; margin-top: -24px; border-radius: 50%; border: 4px solid var(--bg);
  background: var(--brand); color: var(--brand-ink); display: grid; place-items: center;
  box-shadow: 0 8px 20px rgba(196, 61, 113, .35); cursor: pointer;
}
.nav .plus svg { width: 26px; height: 26px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; border: 1px solid var(--line); }
.card h2, .section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 12px; font-weight: 700; }
.section-title { margin: 22px 4px 10px; }
.card-title { font-size: 17px; font-weight: 800; letter-spacing: -.01em; margin: 0 0 4px; }
.card-sub { font-size: 13px; color: var(--ink-3); margin: 0 0 14px; line-height: 1.4; }

/* month switch */
.month { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 2px 0 14px; }
.month button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 18px; color: var(--ink-2); }
.month strong { min-width: 150px; text-align: center; font-size: 15px; text-transform: capitalize; }

/* hero: result of the month */
.hero { background: var(--night); color: #fff; border: 0; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(196, 61, 113, .45), transparent 70%); pointer-events: none; }
.hero .label { color: #f3c6d6; font-size: 13px; font-weight: 600; letter-spacing: .04em; }
.hero .big { font-size: 38px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 4px 0 2px; }
.hero .big.loss { color: #ff9c9c; }
.hero .big.gain { color: #9fe8c3; }
.hero .each { font-size: 13px; color: #d9c7cd; margin-bottom: 14px; }
.eq { width: 100%; border-collapse: collapse; font-size: 14px; position: relative; z-index: 1; }
.eq td { padding: 7px 0; border-top: 1px solid rgba(255, 255, 255, .1); }
.eq td:last-child { text-align: right; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.eq td small { display: block; color: #b9a5ac; font-size: 12px; }
.hero .note { margin-top: 12px; font-size: 12.5px; color: #e4d3d9; background: rgba(255, 255, 255, .07); border-radius: 12px; padding: 10px 12px; line-height: 1.4; position: relative; z-index: 1; }

/* money ledger (white card) */
.ledger { width: 100%; border-collapse: collapse; font-size: 15px; }
.ledger td { padding: 9px 0; }
.ledger td:last-child { text-align: right; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger tr.total td { border-top: 2px solid var(--ink); padding-top: 12px; font-size: 17px; }
.ledger tr.total td:last-child { font-size: 22px; }
.ledger a { color: var(--brand); font-weight: 600; }

/* partners */
.partner { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline; margin-bottom: 14px; }
.partner .name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.partner .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: var(--brand); }
.partner.p-B .dot { background: var(--gold); }
.partner .val { font-weight: 800; font-size: 18px; }
.partner .bar { grid-column: 1 / -1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.partner .bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.partner.p-B .bar i { background: var(--gold); }
.verdict { display: flex; gap: 10px; align-items: center; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; font-size: 14px; line-height: 1.4; }
.verdict .btn { flex: none; }

/* quick actions */
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.quick a { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); font-weight: 700; font-size: 14px; line-height: 1.25; }
.quick a:active { transform: scale(.98); }
.quick .ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 17px; flex: none; }

/* legacy stat tiles (other screens) */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--ink-3); display: block; }
.stat .val { font-size: 19px; font-weight: 800; margin-top: 2px; display: block; letter-spacing: -.01em; }
.stat .sub { font-size: 12px; color: var(--ink-3); }
.stat.warn .val { color: var(--warn); }
.stat.ok .val { color: var(--pos); }

.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--ink-3); } .warn-t { color: var(--warn); }

/* ---------- list rows ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); min-height: 62px; }
.row:last-child { border-bottom: 0; }
a.row:active { background: var(--surface-2); }
.row .ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 17px; font-weight: 700; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amount { font-weight: 800; white-space: nowrap; text-align: right; }
.row .amount small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-3); }
.ico.k-purchase { background: var(--neg-soft); color: var(--neg); }
.ico.k-payout, .ico.k-income { background: var(--pos-soft); color: var(--pos); }
.ico.k-supplier_payment { background: var(--warn-soft); color: var(--warn); }
.ico.k-withdrawal, .ico.k-contribution, .ico.k-transfer { background: var(--brand-soft); color: var(--brand); }
.day-head { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: capitalize; padding: 14px 4px 6px; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.badge.paid { background: var(--pos-soft); color: var(--pos); }
.badge.partial { background: var(--warn-soft); color: var(--warn); }
.badge.unpaid, .badge.late { background: var(--neg-soft); color: var(--neg); }
.badge.info { background: var(--brand-soft); color: var(--brand); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field > label, .lbl { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.field .hint, .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
input, select, textarea {
  width: 100%; font: inherit; font-weight: 500; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 12px; outline: none; appearance: none; -webkit-appearance: none; min-height: 48px;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; padding: 0; border-radius: 6px; flex: none; position: relative; cursor: pointer; }
input[type=checkbox]:checked { background: var(--brand); border-color: var(--brand); }
input[type=checkbox]:checked::after { content: ''; position: absolute; left: 7px; top: 3px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
textarea { min-height: 70px; resize: vertical; }
.money { position: relative; }
.money input { padding-right: 44px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.money::after { content: 'DT'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 14px; pointer-events: none; }
.money.big input { font-size: 26px; min-height: 60px; }
.inline { display: flex; gap: 10px; }
.inline > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 3px; gap: 3px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 10px 6px; border-radius: 11px; font-size: 14px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border: 0; border-radius: 999px; font-weight: 800; font-size: 16px; cursor: pointer; background: var(--brand); color: var(--brand-ink); }
.btn:active { opacity: .85; }
.btn:disabled { opacity: .45; }
.btn.ghost { background: var(--surface); color: var(--brand); border: 1px solid var(--line); }
.btn.danger { background: var(--surface); color: var(--neg); border: 1px solid var(--line); }
.btn.dark { background: var(--night); color: #fff; }
.btn.small { min-height: 38px; font-size: 14px; width: auto; padding: 0 16px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.sticky-save { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); padding-top: 8px; z-index: 5; }

.lines .line { display: grid; grid-template-columns: 1fr 64px 1fr 32px; gap: 6px; align-items: center; margin-bottom: 8px; }
.lines .line input { min-height: 44px; padding: 9px 8px; }
.lines .line .money input { padding-right: 8px; }
.lines .line .money::after { content: none; }
.lines .line .lt { grid-column: 1 / -1; font-size: 12px; color: var(--ink-3); margin-top: -4px; text-align: right; padding-right: 40px; }
.lines .head { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.rm { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--neg-soft); color: var(--neg); cursor: pointer; font-size: 18px; line-height: 1; }

.total-bar { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 800; }
.total-bar .amount { font-size: 20px; }

.calc { width: 100%; border-collapse: collapse; font-size: 14px; }
.calc td { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.calc td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc td.q { color: var(--ink-3); text-align: right; padding-right: 10px; white-space: nowrap; }
.calc tr.sum td { font-weight: 800; border-bottom: 0; padding-top: 10px; }
.calc tr.sep td { border-bottom: 1px solid var(--ink-3); }

.notice { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; line-height: 1.4; }
.notice.ok { background: var(--pos-soft); color: var(--pos); }
.notice.bad { background: var(--neg-soft); color: var(--neg); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--brand-soft); color: #8e2a52; }

.photo { display: flex; align-items: center; gap: 12px; }
.photo .thumb { width: 64px; height: 64px; border-radius: 14px; background: var(--surface-2) center/cover; border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; color: var(--ink-3); flex: none; }
.photo label.btn { width: auto; flex: 1; }
.photo input { display: none; }
.attach-view img { width: 100%; border-radius: var(--radius-sm); display: block; }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 15px; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.empty { text-align: center; color: var(--ink-3); padding: 28px 16px; font-size: 14px; }

/* ---------- sheet & toast ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(31, 20, 24, .45); z-index: 50; animation: fade .15s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--surface);
  border-radius: 26px 26px 0 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; animation: up .2s ease; max-height: 88dvh; overflow: auto;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 12px; font-size: 19px; font-weight: 800; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); text-align: left; cursor: pointer; }
.action .ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; font-weight: 700; }
.action b { font-size: 15px; }
.action span { font-size: 12px; color: var(--ink-3); line-height: 1.3; }
.action.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px); transform: translateX(-50%); background: var(--night); color: #fff; padding: 12px 18px; border-radius: 999px; z-index: 60; font-size: 14px; font-weight: 700; max-width: 90vw; animation: toastup .2s ease; }
.toast.err { background: var(--neg); }
@keyframes up { from { transform: translateY(16px); opacity: 0; } }
@keyframes toastup { from { transform: translate(-50%, 16px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- auth ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 32px) 20px 32px; text-align: center; }
.auth form, .auth .card { text-align: left; }
.auth .logo { width: 180px; height: 180px; border-radius: 50%; display: block; margin: 0 auto 10px; box-shadow: var(--shadow); }
.auth h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
.auth p { color: var(--ink-2); margin: 0 0 24px; }
body.no-nav { padding-bottom: 0; }

.tier { display: grid; grid-template-columns: 1fr 1fr 32px; gap: 6px; margin-bottom: 6px; align-items: center; }
.rule { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; background: var(--surface-2); }
.rule-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.rule-head input { flex: 1; font-weight: 700; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--gold); border-radius: 4px; }
.loading { padding: 40px; text-align: center; color: var(--ink-3); }
