/* Athena Accounting — application layout & components. */

/* --- Accessibility helpers --- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
:focus-visible { outline: none; box-shadow: var(--a-focus); border-radius: 6px; }
.skip-link {
  position: absolute; left: 8px; top: -60px; background: var(--a-teal);
  color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 100; transition: top .15s;
}
.skip-link:focus { top: 8px; }

/* --- App shell --- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.app.is-auth { grid-template-columns: 1fr; }

.sidebar {
  background: var(--a-surface); border-right: 1px solid var(--a-border);
  display: flex; flex-direction: column; gap: 4px; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand-mark { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand-dot {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--a-teal), var(--a-teal-600));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-name small { display: block; font-weight: 500; font-size: 11px; color: var(--a-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 10px; color: var(--a-text); text-decoration: none; font-weight: 500;
  font-size: 14px;
}
.nav a:hover { background: var(--a-surface-2); }
.nav a[aria-current="page"] { background: var(--a-teal-050); color: var(--a-teal-600); font-weight: 600; }
.nav a .ico { width: 18px; height: 18px; flex: none; color: currentColor; }
.nav-spacer { flex: 1; }

.sidebar-foot { border-top: 1px solid var(--a-border); padding-top: 12px; font-size: 13px; color: var(--a-muted); }
.sidebar-foot .who { color: var(--a-text); font-weight: 600; }

/* --- Topbar (mobile) --- */
.topbar {
  display: none; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--a-surface); border-bottom: 1px solid var(--a-border);
  position: sticky; top: 0; z-index: 20;
}
.hamburger {
  background: none; border: 1px solid var(--a-border); border-radius: 9px;
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--a-text);
}

/* --- Main --- */
.main { padding: 26px 30px 60px; max-width: 1160px; width: 100%; }
.page-head { margin: 0 0 20px; }
.page-head h1 { font-size: 22px; margin: 0 0 3px; }
.page-head p { margin: 0; color: var(--a-muted); font-size: 14px; }

/* --- Welcome banner --- */
.welcome {
  background: linear-gradient(120deg, var(--a-ink), var(--a-ink-700));
  color: #eaf3f2; border-radius: var(--a-radius); padding: 22px 24px; margin-bottom: 22px;
}
.welcome h2 { margin: 0 0 4px; font-size: 19px; font-weight: 650; }
.welcome p { margin: 0; color: #b9d1cf; font-size: 14px; }
.welcome .health { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px;
  background: rgba(255,255,255,.12); padding: 5px 12px; border-radius: 999px; font-size: 13px; }
.health-dot { width: 9px; height: 9px; border-radius: 50%; background: #7fe0b6; }
.health-dot.warn { background: #f2c14e; }
.health-dot.neg { background: #f19a8f; }

/* --- Cards grid --- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--a-surface); border: 1px solid var(--a-border); border-radius: var(--a-radius);
  padding: 18px; box-shadow: var(--a-shadow); display: flex; flex-direction: column; gap: 4px;
}
.card .label { font-size: 13px; color: var(--a-muted); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.card .amount { font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.card .amount.na { font-size: 18px; color: var(--a-muted-2); font-weight: 600; }
.card .delta { font-size: 13px; display: inline-flex; align-items: center; gap: 6px; margin-top: 2px; }
.card .explain { font-size: 12.5px; color: var(--a-muted); margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip.pos { background: var(--a-positive-bg); color: var(--a-positive); }
.chip.neg { background: var(--a-negative-bg); color: var(--a-negative); }
.chip.flat { background: var(--a-surface-2); color: var(--a-muted); }
.chip.warn { background: var(--a-warn-bg); color: var(--a-warn); }

/* --- Section blocks --- */
.section { background: var(--a-surface); border: 1px solid var(--a-border); border-radius: var(--a-radius);
  box-shadow: var(--a-shadow); padding: 20px 22px; margin-bottom: 22px; }
.section > h3 { margin: 0 0 3px; font-size: 16px; }
.section > .sub { margin: 0 0 16px; color: var(--a-muted); font-size: 13px; }
.two-col { display: grid; grid-template-columns: 1.35fr 1fr; gap: 22px; align-items: start; }

/* --- Financial position bars --- */
.fp-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--a-border); }
.fp-row:last-child { border-bottom: 0; }
.fp-row .fp-label { font-weight: 600; }
.fp-row .fp-label small { display: block; color: var(--a-muted); font-weight: 500; font-size: 12px; }
.fp-row .fp-amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.fp-note { margin-top: 12px; font-size: 12.5px; color: var(--a-muted); }

/* --- Activity list --- */
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--a-border); }
.activity li:last-child { border-bottom: 0; }
.activity .act-ico { width: 34px; height: 34px; border-radius: 9px; background: var(--a-teal-050); color: var(--a-teal-600);
  display: inline-flex; align-items: center; justify-content: center; flex: none; }
.activity .act-main { flex: 1; min-width: 0; }
.activity .act-title { font-weight: 600; font-size: 14px; }
.activity .act-meta { font-size: 12.5px; color: var(--a-muted); }
.activity .act-amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.activity a.act-link { color: var(--a-teal-600); text-decoration: none; font-size: 12.5px; }
.activity a.act-link:hover { text-decoration: underline; }

/* --- Attention list --- */
.attention { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.attention li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 11px;
  border: 1px solid var(--a-border); background: var(--a-surface-2); }
.attention li.warn { background: var(--a-warn-bg); border-color: #f0dcbc; }
.attention .att-ico { flex: none; }
.attention .att-body { flex: 1; }
.attention .att-body b { display: block; font-size: 14px; }
.attention .att-body span { font-size: 12.5px; color: var(--a-muted); }
.attention a { color: var(--a-teal-600); text-decoration: none; font-weight: 600; font-size: 13px; }
.all-clear { display: flex; align-items: center; gap: 10px; color: var(--a-positive); font-weight: 600; }

/* --- Chart --- */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-legend { display: flex; gap: 18px; margin: 4px 0 14px; font-size: 13px; color: var(--a-muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
svg.trend { width: 100%; height: auto; display: block; }
svg.trend .axis { stroke: var(--a-border); }
svg.trend .tick { fill: var(--a-muted); font-size: 11px; }
svg.trend text.val { fill: var(--a-muted); font-size: 10px; }

/* --- Reports index --- */
.report-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.report-card { display: block; text-decoration: none; color: inherit; background: var(--a-surface);
  border: 1px solid var(--a-border); border-radius: var(--a-radius); padding: 20px; box-shadow: var(--a-shadow); }
.report-card:hover { border-color: var(--a-teal-100); }
.report-card h3 { margin: 0 0 6px; font-size: 16px; color: var(--a-teal-600); }
.report-card p { margin: 0; color: var(--a-muted); font-size: 13.5px; }

/* --- Toolbar / filters --- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--a-muted); font-weight: 600; }
.field input, .field select {
  padding: 9px 11px; border: 1px solid var(--a-border); border-radius: 9px; font-size: 14px; background: #fff; min-width: 150px;
}
.btn { padding: 9px 15px; border-radius: 9px; border: 0; font-weight: 600; font-size: 14px; cursor: pointer;
  background: var(--a-teal); color: #fff; }
.btn:hover { background: var(--a-teal-600); }
.btn.ghost { background: transparent; color: var(--a-teal-600); border: 1px solid var(--a-border); }
.btn.ghost:hover { background: var(--a-surface-2); }

/* --- Tables --- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--a-border); border-radius: var(--a-radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--a-border); white-space: nowrap; }
table.data thead th { background: var(--a-surface-2); color: var(--a-muted); font-weight: 600; position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--a-teal-050); }
table.data tfoot td { font-weight: 700; background: var(--a-surface-2); border-top: 2px solid var(--a-border); }
th .hint, .with-hint { border-bottom: 1px dotted var(--a-muted-2); cursor: help; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-POSTED { background: var(--a-positive-bg); color: var(--a-positive); }
.status-REVERSED { background: var(--a-warn-bg); color: var(--a-warn); }
.status-DRAFT { background: var(--a-surface-2); color: var(--a-muted); }
.status-APPROVED { background: var(--a-teal-050); color: var(--a-teal-600); }
.status-REJECTED { background: var(--a-negative-bg); color: var(--a-negative); }
.status-CANCELLED { background: var(--a-surface-2); color: var(--a-negative); }
.status-CONVERTED { background: var(--a-positive-bg); color: var(--a-positive); }
/* Inline link-style action buttons (used in tables). */
.linkbtn { background: none; border: none; padding: 0; color: var(--a-teal-600); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
/* MyInvois submission statuses (Milestone 4B) */
.status-READY { background: var(--a-surface-2); color: var(--a-muted); }
.status-SUBMITTED { background: var(--a-teal-050); color: var(--a-teal-600); }
.status-VALIDATED { background: var(--a-positive-bg); color: var(--a-positive); }
.status-INVALID { background: var(--a-negative-bg); color: var(--a-negative); }
.line-editor input, .line-editor select { padding: 7px 8px; border: 1px solid var(--a-border); border-radius: 7px; font: inherit; width: 100%; }
.line-editor td { padding: 6px 6px; }
.line-editor .ln-remove { padding: 5px 10px; }
.doc-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.totals-box { margin-top: 14px; display: grid; grid-template-columns: auto auto; gap: 4px 18px; justify-content: end; font-size: 14px; }
.totals-box .lbl { color: var(--a-muted); text-align: right; }
.totals-box .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals-box .grand { font-size: 16px; }

/* --- States --- */
.state { text-align: center; padding: 42px 20px; color: var(--a-muted); }
.state .state-ico { font-size: 30px; margin-bottom: 8px; }
.state.error { color: var(--a-negative); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--a-teal-100); border-top-color: var(--a-teal); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--a-surface-2), #e9f0ef, var(--a-surface-2)); background-size: 200% 100%;
  animation: sk 1.2s ease-in-out infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .spinner, .skeleton { animation: none; } }

/* --- Login --- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--a-surface); border: 1px solid var(--a-border);
  border-radius: var(--a-radius); box-shadow: var(--a-shadow); padding: 28px; }
.login-card h1 { font-size: 20px; margin: 14px 0 4px; }
.login-card .sub { color: var(--a-muted); font-size: 13.5px; margin: 0 0 18px; }
.login-card .field { margin-bottom: 14px; }
.login-card .field input { width: 100%; }
.login-card .btn { width: 100%; margin-top: 6px; }
.err { color: var(--a-negative); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* --- Settings --- */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--a-muted); }
.kv dd { margin: 0; font-weight: 600; }

/* --- Backdrop (mobile menu) --- */
.backdrop { display: none; position: fixed; inset: 0; background: rgba(18,48,58,.4); z-index: 25; }

/* --- Responsive --- */
@media (max-width: 1000px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 30; width: 260px; height: 100vh;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .app.menu-open .sidebar { transform: translateX(0); }
  .app.menu-open .backdrop { display: block; }
  .main { padding: 18px 16px 60px; }
  .cards { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .field input, .field select { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* --- Executive Command Centre (Milestone 4H) --- */
.cc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: start; }
.cc-widget { margin: 0; }
.cc-widget.cc-full { grid-column: 1 / -1; }
.cc-head { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.cc-head h3 { margin: 0; font-size: 15px; }
.cc-ctrl { margin-left: auto; display: inline-flex; gap: 2px; }
.cc-ctrl .linkbtn { padding: 2px 6px; }
.cc-arrow.cc-pos { color: var(--a-positive); }
.cc-arrow.cc-neg { color: var(--a-negative); }
.cc-arrow { color: var(--a-muted); font-size: 15px; }
.cc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cc-list { margin: 4px 0 12px; padding-left: 18px; font-size: 13.5px; }
.cc-list li { margin: 3px 0; }
.cc-widget .cards { grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 12px; }
.cc-widget.cc-full .cards { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .cc-grid { grid-template-columns: 1fr; } .cc-widget.cc-full .cards, .cc-widget .cards { grid-template-columns: 1fr 1fr; } }
