/* Tabitech Compta — brand: Tabitech blue/red, Montserrat + Open Sans */
:root {
  --blue: #1a75c2;
  --blue-dark: #145892;
  --blue-soft: #e8f1f9;
  --red: #e00000;
  --ink: #1b2430;
  --muted: #6b7684;
  --line: #e2e6ec;
  --bg: #f5f7fa;
  --card: #ffffff;
  --green: #18804a;
  --amber: #b26a00;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { font-size: 14px; }
body { margin: 0; font-family: 'Open Sans', system-ui, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.45; }
h1, h2, h3, .brand-name, .kpi-val { font-family: 'Montserrat', 'Open Sans', sans-serif; }
h1 { font-size: 1.45rem; margin: 0 0 .6rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.big { font-size: 1.6rem; font-weight: 700; margin: .3rem 0; }
.center { text-align: center; }
.right { text-align: right; }
.neg { color: var(--red); }
.pos { color: var(--green); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; height: 56px; padding: 0 1rem; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.logo { height: 36px; width: auto; max-width: 120px; }
.brand-name { font-size: 1.05rem; font-weight: 600; letter-spacing: .01em; }
.brand-name b { color: var(--blue); }
.ctx { display: flex; gap: .4rem; }
.ctx select { min-width: 120px; max-width: 240px; }
.table-scroll { overflow-x: auto; margin-bottom: 1rem; }
.table-scroll .table { margin-bottom: 0; }
.table.dense th, .table.dense td { padding: .4rem .45rem; font-size: .9rem; }
.nowrap { white-space: nowrap; }
.top-right { margin-left: auto; display: flex; gap: 1rem; align-items: center; font-size: .9rem; }
.lang { font-weight: 700; border: 1px solid var(--line); border-radius: 4px; padding: .1rem .4rem; }
.user { color: var(--ink); }
.logout { color: var(--muted); }
.menu-btn { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; }

.shell { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 220px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line); padding: .8rem 0; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
.sidebar a { display: block; padding: .38rem 1.2rem; color: var(--ink); border-left: 3px solid transparent; }
.sidebar a:hover { background: var(--bg); text-decoration: none; }
.sidebar a.active { background: var(--blue-soft); border-left-color: var(--blue); color: var(--blue-dark); font-weight: 600; }
.nav-group { margin: 1rem 1.2rem .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.nav-foot { margin: 1.5rem 1.2rem .5rem; font-size: .75rem; color: var(--muted); }
.main { flex: 1; min-width: 0; padding: 1.4rem 1.8rem 3rem; max-width: 1400px; }

/* components */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .8rem 0; }
.page-head .actions { margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 0 0 1rem; }
.card > h2:first-child { margin-top: 0; }
.narrow { max-width: 640px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem 1rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem 1rem; }
.grid2.gap { gap: 1rem; align-items: start; }
.meta { margin-bottom: 1rem; }

.btn { display: inline-flex; align-items: center; gap: .3rem; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c4ccd6; text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { color: var(--red); border-color: #f0c4c4; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.block { width: 100%; justify-content: center; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 0 .3rem; }
.icon-btn:hover { color: var(--red); }
form.inline { display: inline; }

.form label { display: flex; flex-direction: column; gap: .25rem; font-size: .86rem; font-weight: 600; color: #3a4552; margin-bottom: .2rem; }
.form label.check { flex-direction: row; align-items: center; gap: .4rem; padding-top: 1.4rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .78rem; }
input, select, textarea { font: inherit; color: var(--ink); padding: .42rem .55rem; border: 1px solid #cfd6df; border-radius: 6px; background: #fff; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; flex: none; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
fieldset { border: 0; padding: 0; margin: 0; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; margin: .4rem 0 1rem; padding: .7rem .9rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.filters label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: .2rem; }
.filters input, .filters select { width: auto; min-width: 130px; }

.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.card .table { border: 0; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; font-weight: 700; }
.table th, .table td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tfoot td { background: #fafbfc; border-top: 2px solid var(--line); }
.table.compact td { padding: .25rem .5rem; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--blue-soft); }
.table.lines td { padding: .25rem .3rem; }
.table.lines input, .table.lines select { padding: .32rem .45rem; }
.table.lines input.num { text-align: right; }
.table.accounts tr.lvl1 td { font-weight: 700; background: #eef2f7; }
.table.accounts tr.lvl2 td { font-weight: 600; }
.table.accounts tr.lvl4 td:first-child { padding-left: 1.4rem; }
.table.ledger .acc-head td { background: var(--blue-soft); }
.table.ledger .subtotal td, .table .subtotal td { background: #fafbfc; font-weight: 600; }
.table.journal tr.entry-first td { border-top: 2px solid var(--line); }
.table.statement tr.total td { font-weight: 700; background: #f3f6fa; }
.table.statement tr.grand td { font-weight: 700; background: var(--blue); color: #fff; }
.table.statement tr.head td { background: #fafbfc; }
.statement-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 1rem; align-items: start; }

.alert { padding: .6rem .9rem; border-radius: 6px; margin: 0 0 .8rem; border: 1px solid; }
.alert.error { background: #fdecec; border-color: #f3c0c0; color: #8f1d1d; }
.alert.success { background: #e9f7ef; border-color: #b9e3c9; color: #14603a; }
.alert.warn { background: #fff6e5; border-color: #f5d9a3; color: #7a4d00; }
.alert.info { background: var(--blue-soft); border-color: #c4d6f1; color: var(--blue-dark); }
.badge { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge.grey { background: #edf0f3; color: #4e5965; }
.badge.blue { background: var(--blue-soft); color: var(--blue-dark); }
.badge.green { background: #e2f4ea; color: var(--green); }
.badge.amber { background: #fff1d6; color: var(--amber); }
.badge.red { background: #fdecec; color: var(--red); }
.table tr.cn-row td { color: #8f1d1d; }
.tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0 .6rem; }
.tabs a { padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: .85rem; }
.tabs a.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.pager { display: flex; gap: .3rem; flex-wrap: wrap; }
.pager a { padding: .2rem .6rem; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.pager a.active { background: var(--blue); color: #fff; }
details.card summary { cursor: pointer; }
details.card[open] summary { margin-bottom: .6rem; }
.help ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; margin: 1rem 0; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; border-top: 3px solid var(--blue); }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.kpi-val { font-size: 1.35rem; font-weight: 700; margin: .15rem 0; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .75rem; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: .5rem; height: 180px; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-pair { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.bar { width: 42%; max-width: 18px; border-radius: 3px 3px 0 0; min-height: 1px; }
.bar.rev, .sw.rev { background: var(--blue); }
.bar.exp, .sw.exp { background: var(--red); }
.bar-label { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.legend { font-size: .8rem; color: var(--muted); margin-top: .4rem; display: flex; align-items: center; gap: .4rem; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: .5rem; }

/* reports */
.report-head { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 0 1rem; border-bottom: 2px solid var(--blue); margin-bottom: 1rem; }
.rh-company { font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 1.05rem; }
.rh-title { text-align: right; }
.rh-title h1 { margin: 0; font-size: 1.2rem; }

/* auth */
body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; background: linear-gradient(135deg, var(--blue-soft), #fff 60%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.8rem; box-shadow: 0 10px 30px rgba(20, 80, 163, .08); }
.auth-card.wide { max-width: 760px; }
.brand-row { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.2rem; }
.brand-row .logo { height: 52px; width: auto; max-width: 140px; }
.auth-card .form label { margin-bottom: .7rem; }

/* invoice */
body.invoice-page { background: #e9edf2; padding: 1rem; }
.invoice { background: #fff; max-width: 820px; margin: 0 auto; padding: 2.2rem 2.4rem; border-radius: 6px; box-shadow: 0 2px 10px rgba(0, 0, 0, .06); }
.inv-head { display: flex; justify-content: space-between; gap: 2rem; border-bottom: 3px solid var(--blue); padding-bottom: 1rem; }
.inv-logo { max-height: 70px; max-width: 200px; margin-bottom: .4rem; }
.inv-company { font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 1.15rem; }
.inv-title { text-align: right; }
.inv-title h1 { color: var(--blue); letter-spacing: .06em; margin-bottom: .3rem; }
.inv-to { margin: 1.4rem 0; padding: .8rem 1rem; background: #f6f8fb; border-radius: 6px; max-width: 50%; margin-left: auto; }
.inv-lines { border: 0; }
.inv-totals { margin-left: auto; min-width: 300px; border-collapse: collapse; }
.inv-totals td { padding: .3rem .6rem; }
.inv-totals tr.grand td { background: var(--blue); color: #fff; font-weight: 700; }
.inv-foot { margin-top: 2rem; padding-top: .8rem; border-top: 1px solid var(--line); color: var(--muted); text-align: center; }


/* v1.2: inbox, attachments, simple mode */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(260px, 3fr); gap: 1rem; align-items: start; }
.inbox-preview { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
.preview-img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; display: block; }
.preview-pdf { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 6px; }
.att-list { list-style: none; padding: 0; margin: .3rem 0 .6rem; }
.att-list li { padding: .3rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.inline-upload { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-upload input[type=file] { width: auto; flex: 1; }
.nav-count { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 999px; background: var(--red); color: #fff; font-size: .72rem; text-align: center; font-weight: 700; margin-left: .3rem; }
.sidebar a.nav-toggle { margin: 1rem 1.2rem 0; padding: .35rem .6rem; border: 1px dashed var(--line); border-radius: 6px; font-size: .82rem; color: var(--muted); }
.btn.wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn.wa:hover { background: #178a45; }
code.copy { cursor: pointer; background: var(--blue-soft); padding: .15rem .4rem; border-radius: 4px; word-break: break-all; }
code.copy.big { font-size: .95rem; display: inline-block; padding: .4rem .6rem; }
code.copy.copied { background: #e2f4ea; }
.indent { margin: 0 0 .6rem 1.6rem; }
.form label.check { padding-top: .3rem; justify-content: flex-start; font-weight: 600; }
#process-form label.check { padding-top: .5rem; }
.big-input { font-size: 1.25rem; font-weight: 700; }
.kpi.link { color: var(--ink); text-decoration: none; }
.kpi.link:hover { border-color: var(--blue); }
.kpi.selected { background: var(--blue-soft); }
.sector-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; margin: 1rem 0; }
.sector-card { display: flex !important; flex-direction: column; gap: .3rem; padding: .9rem 1rem; background: #fff; border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer; font-weight: 400 !important; }
.sector-card input { width: auto; align-self: flex-start; }
.sector-card:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.big-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 1rem 0 1.5rem; }
.big-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; min-height: 130px; border-radius: 12px; color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; font-family: 'Montserrat', sans-serif; }
.big-btn span { font-size: 2.2rem; line-height: 1; }
.big-btn:hover { text-decoration: none; filter: brightness(1.05); }
.big-btn.exp { background: var(--red); } .big-btn.inc { background: var(--green); } .big-btn.doc { background: var(--blue); }
.share-card .actions { margin: .4rem 0 0; }
body.portal .file-drop input { padding: 1.2rem; border: 2px dashed var(--line); background: var(--bg); }

/* branding page */
.color-row { display: flex; gap: .5rem; align-items: center; }
.color-row input[type=color] { width: 46px; height: 36px; padding: 2px; flex: none; cursor: pointer; }
.brand-preview { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.pv-top { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: #fff; }
.pv-top .brand-name b { color: var(--pv1); }
.pv-body { display: flex; align-items: center; gap: 1rem; padding: 1rem; background: var(--bg); flex-wrap: wrap; }
.pv-btn { background: var(--pv1); color: #fff; padding: .45rem .9rem; border-radius: 6px; font-weight: 600; }
.pv-count { background: var(--pv2); color: #fff; border-radius: 999px; padding: 0 .5rem; font-weight: 700; font-size: .8rem; }
.pv-neg { color: var(--pv2); font-weight: 700; }
.pv-bar { display: flex; align-items: flex-end; gap: 4px; height: 50px; }
.pv-bar i, .pv-bar b { width: 12px; display: block; border-radius: 3px 3px 0 0; }
.pv-bar i { background: var(--pv1); } .pv-bar b { background: var(--pv2); }
.logo { object-fit: contain; }

@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } .inbox-preview { position: static; max-height: none; } }

@media (max-width: 1000px) {
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .statement-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .menu-btn { display: block; }
  .sidebar { position: fixed; left: -240px; top: 56px; z-index: 30; transition: left .2s; box-shadow: 2px 0 10px rgba(0, 0, 0, .1); }
  body.nav-open .sidebar { left: 0; }
  .ctx { display: none; }
  .topbar .brand-name { display: none; }
  .main { padding: 1rem; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
  .user { display: none; }
}
@media print {
  .no-print, .topbar, .sidebar, .filters, .actions, .tabs { display: none !important; }
  body, body.invoice-page { background: #fff; padding: 0; }
  .main { padding: 0; max-width: none; }
  .card, .table { border: 0; }
  .invoice { box-shadow: none; padding: 0; }
  .table th, .table td { padding: .25rem .4rem; }
  html { font-size: 11px; }
  a { color: inherit; }
  .table.statement tr.grand td, .inv-totals tr.grand td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
