/* AtlasQuant Accounting: the approved navy-and-gold design, applied through these shared tokens and classes only.
   Class names are kept from the earlier interface so every module renders through the same rules. */
:root {
  --navy: #0e1d3a; --navy-2: #173158; --navy-3: #22406f;
  --gold: #d4a53c; --gold-2: #b98a25; --gold-soft: #fbf4e2; --gold-ink: #6f4e0c;
  --ink: #15223b; --muted: #66728a; --line: #e3e8f1; --panel: #ffffff; --bg: #f4f6fb; --field: #fbfcfe;
  --link: #1e4d9b; --ok: #11764a; --ok-bg: #e2f5ec; --bad: #b42318; --bad-bg: #fde8e6;
  --warn: #8a5a00; --warn-bg: #fdf1d6; --neutral-bg: #eceff5;
  --radius: 12px; --shadow: 0 1px 2px rgba(14, 29, 58, .05), 0 6px 18px rgba(14, 29, 58, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink);
       background: var(--bg); font-size: 15px; line-height: 1.45; min-height: 100vh; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; margin: 0 0 4px; color: var(--navy); font-weight: 750; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; color: var(--navy); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- shell: grouped navy sidebar, header, content ---- */
.app { min-height: 100vh; }
.app.has-side { display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.side { background: linear-gradient(180deg, var(--navy) 0%, #0b1832 100%); color: #c7d2e5; padding: 18px 14px 28px;
        position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.side-brand:hover { text-decoration: none; }
.side-logo { width: 44px; height: 44px; border-radius: 8px; }
.side-name { display: flex; flex-direction: column; font-weight: 700; font-size: 1.05rem; line-height: 1.1; letter-spacing: .02em; }
.side-name small { font-size: .6rem; font-weight: 600; letter-spacing: .34em; color: var(--gold); margin-top: 3px; }
.nav-wrap > summary { list-style: none; }
.nav-wrap > summary::-webkit-details-marker { display: none; }
.nav-group { font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: #8ea0bf; font-weight: 600;
             padding: 14px 10px 6px; }
.nav-item { display: block; position: relative; padding: 7px 12px 7px 14px; margin: 1px 0; border-radius: 8px;
            color: #dbe4f3; font-size: .9rem; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(212, 165, 60, .24), rgba(212, 165, 60, .06)); color: #f6d98a; font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 4px; bottom: 4px; width: 3px;
                           border-radius: 0 3px 3px 0; background: var(--gold); }
.nav-wrap > summary { color: #dbe4f3; padding: 8px 10px; border: 1px solid #2a4370; border-radius: 8px; cursor: pointer; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 24px; background: #fff;
          border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); font-weight: 700; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-size: .58rem; letter-spacing: .32em; color: var(--gold-2); font-weight: 600; }
.spacer { flex: 1; }
.who { font-weight: 600; font-size: .9rem; }
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.menu { position: absolute; top: calc(100% + 8px); right: 0; min-width: 240px; background: #fff; border: 1px solid var(--line);
        border-radius: 12px; box-shadow: 0 12px 32px rgba(14, 29, 58, .14); padding: 8px; z-index: 30; }
.menu.wide { width: 340px; max-width: calc(100vw - 32px); }
.menu a { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.menu a:hover { background: var(--bg); text-decoration: none; }
.menu a small { color: var(--muted); font-size: .78rem; }
.menu-head { padding: 6px 10px 8px; font-weight: 700; color: var(--navy); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.menu-foot { border-top: 1px solid var(--line); margin-top: 4px; }
.menu-empty { margin: 0; padding: 10px; color: var(--muted); }
.menu-form { margin: 0; }
.menu-button { width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px;
               font: inherit; color: var(--ink); cursor: pointer; }
.menu-button:hover { background: var(--bg); }
.note { border-bottom: 1px solid var(--line); }
.note strong { font-size: .92rem; }
.company-switch > summary { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 360px; padding: 7px 12px;
                            border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.cs-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cs-label { font-size: .72rem; color: var(--muted); }
.cs-name { font-weight: 650; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { flex: 1 1 280px; max-width: 560px; display: flex; align-items: center; gap: 8px; padding: 0 12px;
          border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: var(--muted); }
.search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 165, 60, .18); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 9px 0; font: inherit; color: var(--ink); outline: none; }
.notify > summary, .user-menu > summary { position: relative; display: inline-flex; align-items: center; gap: 8px; }
.notify > summary { width: 42px; height: 42px; justify-content: center; border: 1px solid var(--line); border-radius: 10px; color: var(--navy); }
.badge { position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
         background: var(--gold); color: var(--navy); font-size: .7rem; font-weight: 700; display: grid; place-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: var(--navy); font-weight: 700;
          font-size: .8rem; display: grid; place-items: center; }
.user-menu > summary { padding: 4px 6px; border-radius: 10px; }
.user-menu .menu { min-width: 210px; }
.demo-banner { background: var(--warn-bg); color: var(--gold-ink); padding: 8px 24px; font-size: .85rem; border-bottom: 1px solid #f0dca4; }
main { width: 100%; max-width: 1280px; padding: 24px 28px 36px; }
.foot { padding: 0 28px 20px; font-size: .78rem; color: var(--muted); }

/* ---- page heads and cards ---- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.page-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.page-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.period-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.period-form label { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; color: var(--muted); }
.period-form input { padding: 7px 9px; border: 1px solid #cfd8e6; border-radius: 8px; font: inherit; color: var(--ink); background: #fff; }
.crumbs { font-size: .84rem; color: var(--muted); margin-bottom: 4px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
        padding: 18px 20px; margin-bottom: 18px; min-width: 0; }
.card.narrow { max-width: 480px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.card-head p { margin: 2px 0 0; font-size: .85rem; }
.card-head h2 { margin: 0; }
section.card h2 { margin-top: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 18px; }
.kpi { display: flex; align-items: center; gap: 14px; margin-bottom: 0; }
.kpi-ico { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.kpi-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.kpi-ico.rev { background: #e4edfb; color: var(--navy-3); }
.kpi-ico.exp { background: #fbe5e3; color: var(--bad); }
.kpi-ico.profit { background: #dff4e9; color: var(--ok); }
.kpi-ico.bank { background: var(--gold-soft); color: var(--gold-2); }
.kpi-body { min-width: 0; }
.kpi .label { font-size: .85rem; font-weight: 600; color: var(--navy); }
.kpi .value { font-size: 1.6rem; font-weight: 750; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .value.bad { color: var(--bad); }
.kpi .muted { font-size: .8rem; }
.split { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); margin-bottom: 18px; }
.split > .card { margin-bottom: 0; }
.stat .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .value { font-size: 1.5rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: .85rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.sw.rev { background: var(--navy); }
.sw.exp { background: var(--gold); }

/* chart: bars are scaled to the largest month in the six shown, so heights are proportional */
.chart { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 6px; }
.axis { display: flex; flex-direction: column; justify-content: space-between; height: 230px; font-size: .75rem; color: var(--muted);
        text-align: right; font-variant-numeric: tabular-nums; padding-bottom: 26px; }
.plot { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; height: 230px; position: relative;
        border-bottom: 1px solid #d5dcea; }
.plot::before, .plot::after { content: ""; position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed #e4e9f2; pointer-events: none; }
.plot::before { top: calc((100% - 26px) / 2); }
.plot::after { top: 0; }
.month { display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: calc(230px - 26px); }
.bar { width: 30%; max-width: 26px; min-height: 2px; border-radius: 4px 4px 0 0; }
.bar.rev { background: var(--navy); }
.bar.exp { background: var(--gold); }
.month-label { text-align: center; font-size: .76rem; color: var(--muted); height: 26px; padding-top: 6px; white-space: nowrap; }

/* attention and tax lists */
.attention, .tax-list { list-style: none; margin: 0; padding: 0; }
.attention li, .tax-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.attention li:last-child, .tax-list li:last-child { border-bottom: 0; }
.att-count { min-width: 40px; height: 40px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-weight: 750;
             display: grid; place-items: center; font-variant-numeric: tabular-nums; flex: none; }
.att-count.zero { background: var(--neutral-bg); color: var(--muted); }
.att-text { flex: 1; min-width: 180px; display: flex; flex-direction: column; }
.att-text small { font-size: .82rem; }
.ar-ap { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.ar-ap .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ar-ap .value { font-size: 1.4rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; margin-bottom: 6px; }
table.compact td { padding: .35rem .4rem; border-bottom: 1px solid var(--line); }
table.compact tr:last-child td { border-bottom: 0; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .65rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: #f7f9fc; }
tfoot td { font-weight: 700; border-top: 2px solid var(--navy); border-bottom: 0; }
tr.section td { font-weight: 700; color: var(--navy); background: #f7f9fc; }
.table-wrap { overflow-x: auto; }
table.invoices td, table.invoices th { white-space: nowrap; }

/* ---- buttons ---- */
.btn { display: inline-block; background: linear-gradient(180deg, #dcb15a, var(--gold-2)); color: var(--navy); border: 1px solid #a9791d;
       border-radius: 9px; padding: .55rem 1rem; font: inherit; font-weight: 650; cursor: pointer; line-height: 1.2; }
.btn:hover { filter: brightness(1.04); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--navy-2); border-color: #c3cde0; }
.btn.secondary:hover { background: var(--bg); }
.btn.sm { padding: .4rem .75rem; font-size: .88rem; white-space: nowrap; }
.btn.danger { background: var(--bad); color: #fff; border-color: #8f1d15; }
.btn.danger:hover { background: #8f1d15; }
.btn.block { display: block; width: 100%; text-align: center; }
.linkbtn { background: none; border: 0; color: var(--link); cursor: pointer; font: inherit; padding: 0; }

/* ---- forms ---- */
input, select, textarea { font: inherit; color: var(--ink); }
form.stack label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .75rem; }
form.stack label > input, form.stack label > select, form.stack label > textarea { display: block; width: 100%; margin-top: .3rem;
  padding: .55rem .65rem; border: 1px solid #cbd5e3; border-radius: 8px; background: #fff; }
form.stack label.shrink { display: flex; align-items: center; gap: 8px; }
form.stack label.shrink > input { width: auto; margin: 0; }
form.stack input:focus, form.stack select:focus, form.grid input:focus, form.grid select:focus, .search-page input:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 165, 60, .2); }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.row > * { flex: 1 1 180px; min-width: 0; }
.row > .shrink { flex: 0 0 auto; }
.form-line td input, .form-line td select { width: 100%; padding: .45rem .5rem; border: 1px solid #cbd5e3; border-radius: 7px; background: #fff; }
.form-line td.num input { text-align: right; }
form.grid label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); min-width: 0; }
form.grid label > input, form.grid label > select { width: 100%; min-width: 0; padding: .5rem .6rem; border: 1px solid #cbd5e3; border-radius: 8px; background: #fff; }
form.grid > button, form.grid > .btn { align-self: end; justify-self: start; }
form.grid fieldset.line { border: 0; padding: 0; margin: 0; min-width: 0; }
form.grid fieldset.line legend { display: none; }
.search-page { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.search-page label { flex: 1 1 360px; display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.search-page input { padding: .6rem .75rem; border: 1px solid #cbd5e3; border-radius: 9px; background: #fff; }
.inline-form { margin: 0; display: inline; }
.w-account { width: 34%; }
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0 0 12px; }
dl.facts dt { color: var(--muted); font-size: .88rem; }
dl.facts dd { margin: 0; }

/* ---- messages and status pills ---- */
.alert { border-radius: 9px; padding: .75rem 1rem; margin-bottom: 16px; font-size: .94rem; border: 1px solid transparent; }
.alert.error { background: var(--bad-bg); color: var(--bad); border-color: #f5c2bd; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: #b9e6cf; }
.alert.notice { background: var(--warn-bg); color: var(--gold-ink); border-color: #f0dca4; }
.pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 650; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--gold-ink); }
.pill.neutral { background: var(--neutral-bg); color: #3b4a66; }

/* ---- sign-in ---- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
        background: radial-gradient(circle at 20% 10%, #1d3a6b 0%, var(--navy) 55%, #07122a 100%); }
.auth .card { width: 100%; max-width: 400px; margin: 0; padding: 30px 28px; text-align: left; }
.auth .brand-mark { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.auth .brand-mark img { width: 56px; height: 56px; border-radius: 10px; }
.auth h1 { font-size: 1.4rem; }

/* ---- responsive: the sidebar becomes a collapsible menu above the content below 900px ---- */
@media (min-width: 900px) {
  .nav-wrap > summary { display: none; }
}
@media (max-width: 899px) {
  .app.has-side { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 12px 16px; }
  .side-brand { padding-bottom: 10px; }
  .nav-wrap > summary { display: block; }
  .side-nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); column-gap: 10px; padding-top: 6px; }
  .nav-group { grid-column: 1 / -1; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 10px 16px; gap: 10px; }
  .company-switch > summary { min-width: 0; max-width: none; flex: 1 1 200px; }
  .search { flex-basis: 100%; order: 3; }
  main { padding: 18px 16px 28px; }
  h1 { font-size: 1.4rem; }
  .card { padding: 14px; }
  .kpi .value { font-size: 1.35rem; }
  .axis { width: 46px; }
  .chart { grid-template-columns: 46px minmax(0, 1fr); }
  .period-form { width: 100%; }
  th, td { padding: .45rem .4rem; font-size: .9rem; }
  .foot { padding: 0 16px 16px; }
}
@media print {
  .side, .topbar, .noprint, form { display: none !important; }
  .app.has-side { display: block; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

/* SVG chart: bars are drawn in chart units (the plot is 200 units tall), so their heights are exact. */
.chart-svg { display: block; width: 100%; height: auto; max-height: 280px; font-size: 12px; fill: #66728a; }
.chart-svg .grid line { stroke: #e4e9f2; stroke-width: 1; stroke-dasharray: 4 4; }
.chart-svg .grid line.base { stroke: #cfd7e6; stroke-dasharray: none; }
.chart-svg .bar-rev { fill: var(--navy); }
.chart-svg .bar-exp { fill: var(--gold); }
.chart-svg .month-label { font-size: 12px; }

/* Base form controls for pages that are not built from the .stack or .grid forms (point of sale, tax, setup). */
input[type=text], input[type=search], input[type=date], input[type=number], input[type=password], input[type=email],
input:not([type]), select, textarea {
  border: 1px solid #cbd5e3; border-radius: 8px; padding: .45rem .55rem; background: #fff; color: var(--ink);
  font: inherit; max-width: 100%; }
input[type=checkbox] { accent-color: var(--navy-2); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 12px 16px 14px;
           margin: 0 0 16px; min-width: 0; }
legend { font-weight: 650; color: var(--navy); padding: 0 6px; font-size: .98rem; }
fieldset legend { max-width: 100%; }
button:not(.btn):not(.linkbtn):not(.menu-button):not(.badge) {
  background: linear-gradient(180deg, #dcb15a, var(--gold-2)); color: var(--navy); border: 1px solid #a9791d;
  border-radius: 9px; padding: .45rem .9rem; font: inherit; font-weight: 650; cursor: pointer; line-height: 1.2; }
button:not(.btn):not(.linkbtn):not(.menu-button):not(.badge):hover { filter: brightness(1.04); }
button:not(.btn):not(.linkbtn):not(.menu-button):not(.badge):disabled { opacity: .55; cursor: default; }
label { line-height: 1.35; }

/* ---- hidden panels (tabs in app.js) ---- */
[hidden] { display: none !important; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 2px solid var(--line); margin: 0 0 1rem; }
.tabs a { padding: .55rem .9rem; border-radius: 8px 8px 0 0; color: var(--navy); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a:hover { background: var(--gold-soft); }
.tabs a[aria-current="page"] { border-bottom-color: var(--gold); color: var(--navy); background: var(--gold-soft); }
.tab-panel { min-width: 0; }
/* Test site: center the layout */
main { margin: 0 auto; }
.card.narrow { margin-left: auto; margin-right: auto; }
