/* V0.10 Minimal SaaS Dashboard layer. Loaded last; only overrides what V0.10 changes. */
:root {
  --brand: #1F3A5F; --brand-soft: #EAF3FC; --sky: #4DA8DA; --action: #FF7A59;
  --surface: #FFFFFF; --surface-2: #F5F7FA; --line: #DFE6EF; --ink: #243447; --muted: #52667D;
  --income-ink: #175E8C; --income-bg: #E6F2FB; --expense-ink: #A33A22; --expense-bg: #FFF0EA;
  --neutral-ink: #4A5A6B; --neutral-bg: #EEF2F6; --warn-ink: #8A5A00; --warn-bg: #FFF5DB;
  --r-card: 16px; --r-ctl: 10px; --gap: 16px; --tap: 44px;
  --shadow-card: 0 1px 2px #1F3A5F0A, 0 4px 16px #1F3A5F08;
}
body { background: var(--surface-2); }

/* Shared card and control rhythm. */
.card { border-radius: var(--r-card); box-shadow: var(--shadow-card); }
button.primary, button.secondary, .segmented button { min-height: 40px; border-radius: var(--r-ctl); }
.pill.ok { background: var(--income-bg); color: var(--income-ink); }

/* Income / expense: text is always present; colour is only a secondary cue. */
.money-tag { display: inline-block; margin: 2px 0 4px; padding: 2px 10px; border-radius: 999px; font-weight: 650;
  font-variant-numeric: tabular-nums; background: var(--neutral-bg); color: var(--neutral-ink); }
.money-tag[data-direction="income"] { background: var(--income-bg); color: var(--income-ink); }
.money-tag[data-direction="expense"] { background: var(--expense-bg); color: var(--expense-ink); }
.money-tag[data-direction="unknown"] { background: var(--warn-bg); color: var(--warn-ink); }

/* Monthly trend. */
.month-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 6px; }
.month-toolbar .segmented { align-self: auto; }
.month-toolbar .segmented button { min-width: 64px; font-size: 13px; }
.month-group { cursor: pointer; outline: none; }
.month-group .month-hit { fill: transparent; transition: fill .15s; }
.month-group:hover .month-hit, .month-group:focus-visible .month-hit { fill: #F1F5FA; }
.month-group.chosen .month-hit { fill: var(--brand-soft); }
.month-group.future text { opacity: .45; }
.month-group .month-bar.in-progress { opacity: .7; }
.month-value { font-size: 13px; font-weight: 650; fill: var(--brand); }
.month-hint { margin-top: -4px; }
.month-detail { margin: 12px 0 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.month-detail h3 { margin: 0; font-size: 15px; }
.month-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 10px; }
.month-detail-grid small, .month-detail-grid strong { display: block; }
.month-detail-grid small { color: var(--muted); font-size: 12px; }
.month-detail-grid strong { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: no-preference) {
  .month-bar { transform-box: fill-box; transform-origin: bottom; animation: v10-grow .45s cubic-bezier(.2,.8,.2,1) both; }
}
@keyframes v10-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Pie / donut: slice tap selects; the highlighted legend row opens the details. */
.pie-legend button { min-height: var(--tap); border-radius: 10px; }
.pie-legend button.chart-selected { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.pie-legend button.chart-selected strong { color: var(--brand); }

/* Settings summary cards. */
.v10-hub { margin-bottom: 22px; }
.v10-hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--gap); }
.v10-hub-card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  padding: 18px 44px 18px 18px; border: 1px solid var(--line); background: var(--surface); min-height: 118px; }
.v10-hub-card:hover { border-color: #BFD3EA; }
.v10-hub-card:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.v10-hub-title { font-weight: 700; color: var(--brand); font-size: 15px; }
.v10-hub-desc { color: var(--muted); font-size: 13px; }
.v10-hub-status { margin-top: auto; font-size: 12px; color: var(--ink); background: var(--surface-2); border-radius: 999px; padding: 2px 10px; }
.v10-hub-go { position: absolute; right: 16px; top: 18px; color: var(--muted); }

/* LINE: link status and notification status are separate rows. */
.v10-status { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 6px 0; }
.v10-status div { display: contents; }
.v10-status dt { color: var(--muted); font-size: 13px; }
.v10-status dd { margin: 0; font-size: 13px; }
.v10-line .row { flex-wrap: wrap; gap: 8px; }

/* Desktop sidebar: continuous background, never a white block, never covering clickable content. */
@media (min-width: 901px) {
  #app .sidebar { background: var(--brand); height: 100vh; height: 100dvh; overflow-x: hidden; overscroll-behavior: contain; }
  #app .sidebar::after { content: ""; position: fixed; inset: 0 auto 0 0; width: inherit; background: var(--brand); z-index: -1; }
  #app main { min-height: 100vh; transition: margin-left .2s ease; }
}
@media (min-width: 901px) and (prefers-reduced-motion: reduce) { #app main, #app .sidebar { transition: none; } }

/* Mobile: single-column forms, no horizontal overflow, comfortable touch targets. */
@media (max-width: 650px) {
  html, body { overflow-x: hidden; }
  .form-grid, .settings-grid { grid-template-columns: 1fr !important; }
  input, select, textarea { max-width: 100%; min-height: var(--tap); font-size: 16px; }
  .mobile-nav button { min-height: 52px; }
  .record-actions button, .row > button { min-height: var(--tap); }
  .monthly-metrics { grid-template-columns: 1fr 1fr; }
  .month-toolbar { flex-direction: column; align-items: stretch; }
  .month-toolbar .segmented { display: grid; grid-template-columns: repeat(3, 1fr); }
  .pie-layout { grid-template-columns: 1fr !important; }
  .v10-hub-grid { grid-template-columns: 1fr; }
  .v10-hub-card { min-height: 0; }
}
.mobile-logout { display: block; width: 100%; margin-top: 18px; min-height: var(--tap); background: transparent;
  border: 1px solid var(--line); color: var(--muted); border-radius: var(--r-ctl); }
.mobile-logout:hover { color: var(--expense-ink); border-color: #E7C2B6; }

/* Settings sections: collapsible cards (advanced options start closed). */
.v10-section-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--tap); padding: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.v10-section-toggle:focus-visible { outline: 3px solid var(--sky); outline-offset: 4px; border-radius: 8px; }
.v10-chevron { width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .2s; margin-right: 4px; }
.v10-collapsed .v10-chevron { transform: rotate(-45deg); }
.card.v10-collapsed { padding-bottom: 14px; }
.card.v10-collapsed > h2 { margin-bottom: 0; }

/* Editing and record details open as a side drawer (desktop) or bottom sheet (mobile), not a centred modal.
   Delete / unlink / approval confirmations keep the small centred confirm dialog. */
dialog#editor-dialog, dialog#detail-dialog, dialog#workspace-dialog {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: min(580px, 100vw); max-width: none;
  height: 100vh; height: 100dvh; max-height: none; border-radius: 18px 0 0 18px; border: 0; border-left: 1px solid var(--line);
  padding: 24px 26px; box-shadow: -18px 0 50px #1F3A5F26; overflow: auto; }
dialog#editor-dialog::backdrop, dialog#detail-dialog::backdrop, dialog#workspace-dialog::backdrop { background: #1F3A5F33; }
dialog#editor-dialog .dialog-heading, dialog#detail-dialog .detail-sticky { position: sticky; top: -24px; z-index: 2; background: var(--surface); padding-top: 4px; }
@media (prefers-reduced-motion: no-preference) {
  dialog#editor-dialog[open], dialog#detail-dialog[open], dialog#workspace-dialog[open] { animation: v10-drawer .24s cubic-bezier(.2,.8,.2,1); }
}
@keyframes v10-drawer { from { transform: translateX(32px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (max-width: 650px) {
  dialog#editor-dialog, dialog#detail-dialog, dialog#workspace-dialog {
    inset: auto 0 0 0; width: 100vw; height: auto; max-height: 92dvh; border-radius: 18px 18px 0 0; border-left: 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -18px 50px #1F3A5F26; }
  @media (prefers-reduced-motion: no-preference) {
    dialog#editor-dialog[open], dialog#detail-dialog[open], dialog#workspace-dialog[open] { animation: v10-sheet .26s cubic-bezier(.2,.8,.2,1); }
  }
}
@keyframes v10-sheet { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* Skeleton loading: the existing loading text stays for screen readers; a skeleton shows the shape. */
.chart-loading { position: relative; min-height: 120px; padding-top: 86px; color: var(--muted); font-size: 12px; }
.chart-loading::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 72px; border-radius: 12px;
  background: linear-gradient(90deg, #EEF2F6 25%, #F7F9FC 50%, #EEF2F6 75%); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) { .chart-loading::before { animation: v10-shimmer 1.2s linear infinite; } }
@keyframes v10-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
/* Drawer footer sits flush with the drawer edge so scrolled content never shows beneath it. */
dialog#editor-dialog { padding-bottom: 0; }
dialog#editor-dialog #editor-form .dialog-footer { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
@media (max-width: 650px) { dialog#editor-dialog { padding-bottom: 0; } }
