/* PT Accounts web redesign — shared component structure.
   Every option sets the tokens below in its own stylesheet and adds its shell. */
:root {
  --bg: #fafafa; --surface: #fff; --raised: #f4f4f5; --line: rgba(23, 23, 23, .08); --line-2: rgba(23, 23, 23, .14);
  --ink: #171717; --ink-2: #525252; --ink-3: #737373;
  --accent: #171717; --accent-ink: #fff; --accent-text: #171717; --accent-soft: rgba(23, 23, 23, .06);
  --pos: #16794a; --neg: #c2362f; --warn: #a15c07;
  --c1: #171717; --c2: #a3a3a3; --grid: rgba(23, 23, 23, .07);
  --r-ctl: 10px; --r-card: 16px; --r-chip: 6px;
  --font: system-ui, sans-serif; --font-num: var(--font); --font-display: var(--font);
  --pad: 24px; --row: 52px; --ctl: 40px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { flex: none; display: block; }
.mono { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.nowrap { white-space: nowrap; }
.strong { font-weight: 500; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* view entrance */
#view.enter { animation: rise .36s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* page head */
.ph { margin-bottom: 24px; }
.ph-crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); font-size: 13px; margin-bottom: 8px; transition: color .15s var(--ease); }
.ph-crumb:hover { color: var(--ink); }
.ph-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ph-title { font: 500 30px/1.15 var(--font-display); letter-spacing: -.01em; }
.ph-sub { color: var(--ink-2); margin-top: 4px; font-size: 14px; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--ctl); padding: 0 16px; border-radius: var(--r-ctl); border: 1px solid transparent; font-size: 14px; font-weight: 500; white-space: nowrap; transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .12s var(--ease); background: none; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { background: var(--raised); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* stats */
.stats { display: grid; gap: 16px; margin-bottom: 16px; }
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stats-4 { grid-template-columns: repeat(4, 1fr); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px var(--pad); }
.stat-l { font-size: 13px; color: var(--ink-2); }
.stat-v { font: 500 26px/1.2 var(--font-num); font-variant-numeric: tabular-nums; margin-top: 8px; letter-spacing: -.01em; }
.stat-v small { font-size: 14px; color: var(--ink-3); font-weight: 400; }
.stat-n { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.money-c { font-size: .58em; color: var(--ink-3); margin-right: 4px; font-weight: 400; letter-spacing: 0; }
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }
.bal { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 500; display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.stat .bal { align-items: flex-start; }
.bal-tag { font: 400 12px/1.3 var(--font); color: var(--ink-3); }
.bal-recv { color: var(--pos); }
.bal-pay { color: var(--ink); }
.bal-zero { color: var(--ink-3); font-weight: 400; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--pad); margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.panel-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.panel-h h2 { font: 500 16px/1.3 var(--font); }
.panel-h-2 { margin-top: 24px; }
.panel-meta { font-size: 13px; color: var(--ink-3); }
.panel-foot { font-size: 13px; color: var(--ink-3); margin-top: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.split-even { grid-template-columns: 1fr 1fr; }

/* toolbar & filters */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 240px; max-width: 360px; display: flex; align-items: center; }
.search .i { position: absolute; left: 12px; color: var(--ink-3); }
.search input { width: 100%; height: var(--ctl); padding: 0 12px 0 36px; border-radius: var(--r-ctl); border: 1px solid var(--line-2); background: var(--raised); outline: none; transition: border-color .15s var(--ease), background-color .15s var(--ease); }
.search input:focus { border-color: var(--accent-text); background: var(--surface); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-ctl); background: var(--raised); border: 1px solid var(--line); }
.seg-b { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 0; border-radius: calc(var(--r-ctl) - 3px); background: none; color: var(--ink-2); font-size: 13px; font-weight: 500; transition: background-color .15s var(--ease), color .15s var(--ease); cursor: pointer; }
.seg-b:hover { color: var(--ink); }
.seg-b.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg-b input { display: none; }
.sel { position: relative; display: inline-flex; align-items: center; }
.sel select { appearance: none; height: var(--ctl); padding: 0 36px 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--line-2); background: var(--surface); font-size: 14px; cursor: pointer; }
.sel .i { position: absolute; right: 12px; pointer-events: none; color: var(--ink-3); }

/* tables */
.tbl-wrap, .tbl-scroll { overflow-x: auto; margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-3); padding: 0 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); height: var(--row); vertical-align: middle; }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl td.mono { white-space: nowrap; }
.tbl .num { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tbody tr { transition: background-color .12s var(--ease); }
.tbl tbody tr[data-href] { cursor: pointer; }
.tbl tbody tr[data-href]:hover { background: var(--accent-soft); }
.tbl tfoot td { font-weight: 500; border-bottom: 0; border-top: 1px solid var(--line-2); }
.tbl .total { font-weight: 600; }
.tbl-empty { text-align: center; color: var(--ink-3); padding: 40px 0 !important; }
.tbl-meta { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; font-size: 13px; color: var(--ink-3); }
.show-sm { display: none; }
.cell-party { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.cell-party > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.cell-party-n { font-weight: 500; white-space: nowrap; }
.cell-party-s { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.cell-item { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; }
.tbl-statement .row-payment_in td, .tbl-statement .row-payment_out td { color: var(--ink-2); }

/* chips & avatars */
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: var(--r-chip); font-size: 12px; font-weight: 500; background: var(--raised); color: var(--ink-2); white-space: nowrap; }
.chip-in { background: color-mix(in srgb, var(--pos) 12%, transparent); color: var(--pos); }
.chip-out { background: var(--raised); color: var(--ink-2); }
.chip-warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.chip-client { background: var(--accent-soft); color: var(--accent-text); }
.av { flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-size: 12px; font-weight: 500; background: var(--raised); color: var(--ink-2); letter-spacing: 0; }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); background: var(--ink-3); }

/* charts */
.ch { position: relative; }
.ch svg { width: 100%; height: 280px; display: block; overflow: visible; }
.ch-bars svg { height: 200px; }
.ch-grid { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ch-ax { fill: var(--ink-3); font: 11px var(--font-num); }
.ch-line { fill: none; stroke-width: 2.25; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.ch-line.is-dash { stroke-dasharray: 4 5; stroke-width: 1.5; }
.ch-line.s1 { stroke: var(--c1); }
.ch-line.s2 { stroke: var(--c2); }
.ch-area { stroke: none; opacity: .1; }
.ch-area.s1 { fill: var(--c1); }
.ch-cursor { stroke: var(--ink-3); stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; transition: opacity .15s; }
.ch-hit { fill: transparent; }
.ch-bar { fill: var(--c2); }
.ch-bar.is-lead { fill: var(--c1); }
.ch-tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--ink); color: var(--bg); border-radius: 10px; padding: 8px 12px; font-size: 12px; pointer-events: none; min-width: 168px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14); z-index: 2; }
.ch-tip-h { opacity: .7; margin-bottom: 4px; }
.ch-tip-r { display: flex; align-items: center; gap: 6px; }
.ch-tip-r b { margin-left: auto; font-weight: 500; font-family: var(--font-num); font-variant-numeric: tabular-nums; padding-left: 12px; }
.ch-tip-r i, .ch-key i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ch-tip-r.s1 i, .ch-key.s1 i { background: var(--c1); }
.ch-tip-r.s2 i, .ch-key.s2 i { background: var(--c2); }
.ch-legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); }
.ch-key { display: inline-flex; align-items: center; gap: 6px; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.rank-i { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; }
.rank-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.rank-n:hover { text-decoration: underline; text-underline-offset: 3px; }
.rank-v { font-family: var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.rank-bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--raised); overflow: hidden; }
.rank-bar i { display: block; height: 100%; background: var(--c2); border-radius: 2px; }
.rank-i.is-lead .rank-bar i { background: var(--c1); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list-i { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list-i:last-child { border-bottom: 0; }
.list-i > span:first-child { display: flex; align-items: center; gap: 12px; min-width: 0; }
.list-i > span:first-child > .i { color: var(--ink-3); }
.list-i > span:first-child > span:not(.av) { display: flex; flex-direction: column; }
.list-t { font-weight: 500; }
.list-s { font-size: 13px; color: var(--ink-3); }

/* forms */
.form { max-width: 820px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-l { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field-h { font-size: 12px; color: var(--ink-3); min-height: 16px; }
.field input, .field select, .field textarea { width: 100%; min-height: var(--ctl); padding: 8px 12px; border-radius: var(--r-ctl); border: 1px solid var(--line-2); background: var(--surface); outline: none; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; }
.seg-form { display: flex; }
.seg-form .seg-b { flex: 1; justify-content: center; }
.form-sub { border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 16px 20px 20px; margin: 20px 0 0; }
.form-sub legend { padding: 0 8px; margin-left: -8px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 500; }
.form-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-total span { color: var(--ink-2); }
.form-total output { font: 500 28px/1 var(--font-num); font-variant-numeric: tabular-nums; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.if-discount { display: none; }
.form.is-discount .if-discount { display: flex; }

/* invoice */
.invoice { max-width: 820px; background: #fff; color: #1b1b1b; border: 1px solid var(--line); border-radius: var(--r-card); padding: 48px; box-shadow: 0 8px 24px rgba(0, 0, 0, .06); --line: rgba(0, 0, 0, .1); --line-2: rgba(0, 0, 0, .2); --ink-3: #6b6b6b; }
.inv-h { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 24px; border-bottom: 1px solid rgba(0, 0, 0, .12); }
.inv-biz { font: 600 22px/1.2 var(--font-display); }
.inv-tag { color: #555; font-size: 13px; margin-top: 4px; }
.inv-meta { color: #6b6b6b; font-size: 13px; margin-top: 8px; }
.inv-title { font: 500 28px/1 var(--font-display); color: #6b6b6b; }
.inv-parties { display: flex; justify-content: space-between; gap: 24px; padding: 24px 0; }
.inv-right { text-align: right; }
.inv-k { font-size: 12px; color: #6b6b6b; margin-top: 8px; }
.inv-k:first-child { margin-top: 0; }
.inv-v { font-weight: 500; font-size: 15px; }
.inv-tbl th { color: #6b6b6b; }
.inv-tbl tfoot td { font-size: 16px; }
.inv-note { margin-top: 16px; font-size: 13px; color: #6b6b6b; }
.inv-f { margin-top: 40px; text-align: center; font-size: 13px; color: #6b6b6b; }

/* reports & settings */
.tbl-pl td { height: 44px; }
.tbl-pl .sub td { color: var(--ink-2); }
.tbl-pl .rule td { border-top: 1px solid var(--line-2); }
.exports { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.export { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); text-align: left; font-size: 14px; font-weight: 500; transition: background-color .15s var(--ease), border-color .15s var(--ease); }
.export:hover { background: var(--raised); border-color: var(--line-2); }
.export span { flex: 1; }
.export .i { color: var(--ink-3); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
.settings > .panel:first-child { grid-column: 1 / -1; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 40px 32px; box-shadow: 0 8px 24px rgba(0, 0, 0, .06); }
.login-brand { margin-bottom: 16px; }
.login-title { font: 500 28px/1.15 var(--font-display); }
.login-sub { color: var(--ink-2); margin-top: -8px; }
.login-recover summary { cursor: pointer; font-size: 14px; color: var(--ink-2); }
.login-recover[open] { display: flex; flex-direction: column; gap: 12px; }
.login-back { display: inline-flex; gap: 4px; align-items: center; color: var(--ink-3); font-size: 13px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); opacity: 0; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; transition: opacity .2s var(--ease), transform .2s var(--ease); pointer-events: none; z-index: 100; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* responsive */
@media (max-width: 1100px) {
  .split, .split-even { grid-template-columns: 1fr; }
  .stats-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  :root { --pad: 16px; }
  .stats-3, .stats-4 { grid-template-columns: 1fr; }
  .form-grid, .settings { grid-template-columns: 1fr; }
  .exports { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .show-sm { display: table-cell; }
  .ph-title { font-size: 26px; }
  .invoice { padding: 24px; }
  .inv-h, .inv-parties { flex-direction: column; }
  .inv-right { text-align: left; }
  .search { max-width: none; }
}

/* print: only the content */
@media print {
  body { background: #fff; }
  .shell-side, .shell-top, .ph-actions, .ph-crumb, .toolbar, .tbl-meta, .toast { display: none !important; }
  .panel, .invoice { box-shadow: none; border: 0; }
}
