/* Talaan · platform-aligned radius hierarchy
   Compact controls stay calm, content cards get more air, and the largest corners
   are reserved for surfaces that sit above the page. Structural joins may remain 0;
   pills, chips, badges, avatars, dots, swatches, and circular shapes keep their
   intentional geometry. */
:root {
  --talaan-control-radius: 12px;
  --talaan-card-radius: 14px;
  --talaan-section-radius: 16px;
  --talaan-dialog-radius: 20px;
  --talaan-popover-radius: 12px;
  --talaan-ui-radius: var(--talaan-card-radius);
  --radius: var(--talaan-card-radius);
  --desktop-panel-radius: var(--talaan-section-radius);
  --desktop-inner-radius: var(--talaan-card-radius);
  --liquid-glass-radius: var(--talaan-section-radius);
}

/* Phone corners follow the approved compact scale in both orientations. */
@media (max-width:700px), (pointer:coarse) and (max-width:932px) {
  :root {
    --talaan-control-radius:10px;
    --talaan-card-radius:12px;
    --talaan-section-radius:14px;
    --talaan-dialog-radius:16px;
    --talaan-popover-radius:10px;
  }
}

html body :where(
  .card,
  [class$="-card"],
  [class*="-card "],
  .overflow-menu,
  .context-menu,
  .menu-popover,
  [class$="-menu-panel"],
  [class*="-menu-panel "],
  .table-wrap,
  [class$="-table-wrap"],
  [class*="-table-wrap "],
  .dashboard-week-marquee,
  .finance-week-marquee,
  .work-week-marquee,
  .nav-icon,
  .legend-item,
  .summary-item,
  .month-comparison-item,
  .monthly-check-item,
  .ledger-summary-grid > div,
  .ledger-transfer-preview,
  .budget-preview,
  .account-setting-row,
  .cloud-pending-item,
  .cloud-v3-health-grid > div,
  .cloud-conflict-item,
  .productivity-search-result,
  .settings-disclosure,
  .settings-mobile-back,
  .toast,
  .snackbar
):not([class*="status-chip"]):not([class*="badge"]):not([class*="pill"]):not([class*="avatar"]):not([class*="dot"]):not([class*="swatch"]):not([class*="mascot"]):not(.finance-privacy-lock-card):not(.finance-device-lock-card) {
  border-radius: var(--talaan-ui-radius) !important;
}

/* Structural surfaces use the card tier, while larger workflow containers use the
   section tier. Component owners below retain control of attached joins. */
html body #money .period-card {
  border-radius: var(--talaan-card-radius) !important;
}

html body #money .period-card > .period-header {
  border-start-start-radius: var(--talaan-card-radius) !important;
  border-start-end-radius: var(--talaan-card-radius) !important;
  border-end-start-radius: 0 !important;
  border-end-end-radius: 0 !important;
}

html body #projects .finance-kanban-column,
html body #reports .report-section-nav,
html body .panel {
  border-radius: var(--talaan-section-radius) !important;
}

html body :is(.topbar-tools-panel,.record-more-panel,.project-dialog-more-panel,.report-export-menu-panel,.menu-popover,.context-menu,.popover) {
  border-radius: var(--talaan-popover-radius) !important;
}

/* Compact controls remain easy to scan and fit dense finance rows. */
html body :where(
  .button,
  button[class$="-button"],
  button[class*="-button "],
  .input,
  .select,
  .textarea,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
  select,
  textarea,
  [class$="-control"],
  [class*="-control "],
  .workspace-switcher,
  .workspace-switcher button,
  .nav-icon
):not([class*="status-chip"]):not([class*="badge"]):not([class*="pill"]):not([class*="avatar"]):not([class*="dot"]):not([class*="swatch"]):not([class*="mascot"]) {
  border-radius: var(--talaan-control-radius) !important;
}

html body :where(dialog,[role="dialog"],.modal,[class$="-dialog"],[class*="-dialog "]) {
  border-radius: var(--talaan-dialog-radius) !important;
}

/* Some floating controls expose dialog semantics for assistive technology but
   remain popovers visually; keep their compact surface tier. Lock cards are
   blocking dialog surfaces even though their class names end in `-card`. */
html body :is(
  .cloud-sync-toolbar-popover,
  .month-picker-popover,
  .topbar-tools-panel,
  .record-more-panel,
  .project-dialog-more-panel,
  .report-export-menu-panel,
  .menu-popover,
  .context-menu,
  .popover
) {
  border-radius: var(--talaan-popover-radius) !important;
}

html body :is(.finance-privacy-lock-card,.finance-device-lock-card) {
  border-radius: var(--talaan-dialog-radius) !important;
}

/* Canonical structural line contract. Internal dividers use the shared line token,
   reach the intended card edge, and avoid adjacent double seams. */
#reports > .report-savings-goals-card {
  margin-bottom: 10px !important;
}

@media (min-width: 851px) {
  html body #settings .cloud-config-card > .advanced-settings-disclosure {
    box-sizing: border-box;
    margin-inline: calc(-1 * var(--workspace-card-padding, 13px));
    padding-inline: var(--workspace-card-padding, 13px);
  }
}

/* Tablet Finance cards retain 13px content padding, so bleed the structural header
   through that padding while preserving the header content inset. */
@media (min-width: 701px) and (max-width: 850px) {
  html body #money .period-card > .period-header {
    box-sizing: border-box;
    margin-inline: -13px !important;
    padding-inline: 13px !important;
  }
}

/* Composite Finance period headers keep their structural join, but their visible
   outer corners follow the card tier. */
@media (max-width: 850px) {
  html body #money .period-card > .period-header {
    border-start-start-radius: var(--talaan-card-radius) !important;
    border-start-end-radius: var(--talaan-card-radius) !important;
    border-end-start-radius: 0 !important;
    border-end-end-radius: 0 !important;
    border-bottom: 1px solid var(--line) !important;
  }

  html body #money .period-card.is-collapsed > .period-header {
    border: 0 !important;
    border-radius: var(--talaan-card-radius) !important;
  }
}

/* Dashboard and Finance workspace navigation share the card tier. The tab group,
   tab buttons, marquee shell, and repeated day tiles are one visual family. */
html body #dashboard {
  --dashboard-card-radius: var(--talaan-card-radius);
}
html body :is(#dashboard .dashboard-view-tabs,#money .money-workspace-switcher,#income .money-workspace-switcher,#paid-expenses .money-workspace-switcher) {
  border-radius: var(--talaan-card-radius) !important;
}
html body :is(#dashboard .dashboard-view-tabs > .workspace-switcher-button,#money .money-workspace-switcher > .workspace-switcher-button,#income .money-workspace-switcher > .workspace-switcher-button,#paid-expenses .money-workspace-switcher > .workspace-switcher-button) {
  border-radius: var(--talaan-card-radius) !important;
}
html body :is(.dashboard-week-marquee,.finance-week-marquee,.work-week-marquee) {
  border-radius: var(--talaan-card-radius) !important;
}
html body :is(.dashboard-week-marquee,.finance-week-marquee,.work-week-marquee) .dashboard-week-day {
  border-radius: var(--talaan-card-radius) !important;
}
html body #dashboard :is(.button,.input,.select,.textarea,button[class$="-button"],button[class*="-button "]) {
  border-radius: var(--talaan-control-radius) !important;
}

/* Talaan V2.5.0 · canonical shadow hierarchy
   Level 0 is the default for content. Elevation is reserved for components that
   physically float above another surface. State rings/inset status indicators
   remain separate from this elevation system. */
:root {
  --shadow-level-0: none;
  --shadow-level-1: 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-level-2: 0 8px 24px rgba(15, 23, 42, .14);
  --shadow-level-3: 0 20px 56px rgba(15, 23, 42, .20);
  --shadow: var(--shadow-level-2);
  --workspace-soft-shadow: var(--shadow-level-0);
  --workspace-raised-shadow: var(--shadow-level-0);
  --liquid-glass-shadow-soft: var(--shadow-level-0);
  --liquid-glass-shadow: var(--shadow-level-2);
}

html[data-theme="dark"] {
  --shadow-level-1: 0 1px 3px rgba(0, 0, 0, .22);
  --shadow-level-2: 0 8px 24px rgba(0, 0, 0, .34);
  --shadow-level-3: 0 20px 56px rgba(0, 0, 0, .48);
  --shadow: var(--shadow-level-2);
}

/* Level 0 — normal content and navigation surfaces stay flat. */
html body :is(
  .card,
  .dashboard-card,
  .dashboard-detail-card,
  .summary-card,
  .settings-card,
  .finance-privacy-lock-card,
  .settings-search-panel,
  .workspace-switcher,
  .workspace-switcher-button,
  .dashboard-week-marquee,
  .finance-week-marquee,
  .work-week-marquee,
  .dashboard-week-day,
  .finance-kanban-card,
  .report-compact-group,
  .report-section-nav,
  .month-insights-card
) {
  box-shadow: var(--shadow-level-0) !important;
}

html body :is(.card,.dashboard-card,.dashboard-detail-card):hover {
  box-shadow: var(--shadow-level-0) !important;
}

html body #dashboard :is(.card,.dashboard-detail-card),
html body #dashboard :is(.card,.dashboard-detail-card):hover,
html body #reports :is(.card,.report-insights-card,.report-insight-panel),
html body #money .record-row[data-expense-row],
html body #projects .finance-kanban-card {
  box-shadow: var(--shadow-level-0) !important;
}

/* Avoid using a shadow as a duplicate separator where a border already exists. */
html body .topbar {
  box-shadow: none !important;
}

/* Normal glass/navigation controls keep material/background treatment but no
   decorative elevation. */
html body .topbar :is(
  .cloud-sync-toolbar-button,
  .month-nav-button,
  .month-display-button,
  .month-current-button,
  .topbar-history-button,
  .topbar-add-button,
  #customizeDashboardButton,
  .topbar-tools-trigger
),
html body .topbar :is(.month-navigator,.topbar-history-actions),
html body .sidebar :is(.sidebar-close-button,.nav-button),
html body .workspace-switcher button,
html body :is(.dashboard-week-marquee,.finance-week-marquee,.work-week-marquee) .dashboard-week-day {
  box-shadow: none !important;
}

html body .sidebar .nav-button.active,
html body .workspace-switcher button.active,
html body .workspace-switcher button[aria-selected="true"],
html body .workspace-switcher-button.active,
html body .workspace-switcher-button[aria-selected="true"] {
  box-shadow: none !important;
}

/* The sidebar edge is a structural divider, not elevation. A pseudo-element keeps
   the 1px line continuous without changing collapsed, expanded, pinned, or phone
   sidebar geometry. */
html body #sidebar.sidebar,
html body #sidebar.sidebar.desktop-open,
html body #sidebar.sidebar.sidebar-pinned {
  box-shadow: none !important;
}

html body #sidebar.sidebar::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  width: 1px;
  background: var(--line);
  pointer-events: none;
  z-index: 1;
}

/* Level 1 — reserved for a single floating primary action. */
html body .mobile-add-expense-fab {
  box-shadow: var(--shadow-level-1) !important;
}

/* Level 2 — menus, popovers, tooltips, toasts, transient floating UI. */
html body :is(
  .cloud-sync-toolbar-popover,
  .month-picker-popover,
  .topbar-tools-panel,
  .overflow-menu,
  .context-menu,
  .menu-popover,
  .popover,
  .record-more-panel,
  .project-dialog-more-panel,
  .report-export-menu-panel,
  .emoji-picker-panel,
  .record-icon-picker-controls.compact-icon-popover,
  .mobile-utility-panel,
  .toast,
  .snackbar,
  .structured-drag-toast,
  #pwaUpdateBanner
) {
  box-shadow: var(--shadow-level-2) !important;
}

/* Toasts stay flat and readable on every viewport and theme.  The surface
   layer is intentionally opaque so semantic messages cannot inherit a white
   foreground from the legacy dark toast palette. */
html body :is(#toast, #structuredDragToast, .toast, .snackbar) {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

html body :is(#toast, #structuredDragToast, .toast, .snackbar) :is(.toast-message, .snackbar-message) {
  color: inherit !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

html body :is(#toast, #structuredDragToast, .toast, .snackbar) .toast-icon {
  color: var(--text) !important;
  background: var(--surface-soft) !important;
}

html body .toast.toast-success { border-inline-start: 3px solid var(--green) !important; }
html body .toast.toast-info { border-inline-start: 3px solid var(--blue) !important; }
html body .toast.toast-warning { border-inline-start: 3px solid var(--orange) !important; }
html body .toast.toast-error { border-inline-start: 3px solid var(--red) !important; }

html body #sidebar.sidebar:not(.desktop-open):not(.sidebar-pinned) .nav-button::after,
html body #cloudSyncStatusButton[data-mobile-sync-feedback]::after {
  box-shadow: var(--shadow-level-2) !important;
}

/* Level 3 — dialogs and blocking overlays. */
html body :is(dialog,.modal,.dialog,.finance-device-lock-card) {
  box-shadow: var(--shadow-level-3) !important;
}

/* Modal chrome should not create a second elevation layer inside the dialog. */
html body :is(dialog,.modal,.dialog) :is(
  .modal-header,
  .dialog-header,
  .pc-dialog-header,
  .modal-footer,
  .dialog-footer,
  .modal-actions,
  .dialog-actions
) {
  box-shadow: none !important;
}

/* Functional state shadows remain intentional. These communicate selection,
   validation, timing, or drag/drop state rather than decorative elevation. */
html body :is(
  .appearance-choice[aria-checked="true"],
  #accountDialog .account-mode-button[aria-pressed="true"],
  .calendar-day.is-selected,
  .gym-day-grid input:checked + span,
  .filter-control-active,
  .record-icon-trigger:hover,
  .record-icon-trigger:focus-visible
) {
  /* Existing component rules retain their inset state ring. */
}

/* The segmented transaction view already has a border/background selected state;
   remove its additional raised ring. Higher specificity intentionally wins over
   the later summary compatibility layer. */
html body #money #transactionToolbar-expense .transaction-view-group .button.button[aria-pressed="true"] {
  box-shadow: none !important;
}

/* Dragging is one of the few interaction states where temporary elevation helps
   communicate that an item is detached from its original surface. */
html body :is(.is-structured-dragging,.dashboard-drag-preview,.dashboard-detail-card.is-dashboard-resizing) {
  box-shadow: var(--shadow-level-2) !important;
}

/* Drop targets use a ring, not a raised shadow. */
html body .is-structured-drop-target {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent) !important;
}

/* Semantic inset edges are kept because they encode status/position. */
html body :is(
  .record-row.due-soon-row,
  .record-row.overdue-row,
  .account-card.account-drop-before,
  .account-card.account-drop-after
) {
  /* Existing inset declarations remain authoritative. */
}

/* Final specificity bridge for legacy feature layers.  Several older feature
   sheets intentionally use high-specificity 7px declarations; keep the new
   hierarchy authoritative without requiring a broad refactor of those files. */
html body #projects .project-toolbar-compact,
html body #projects .project-toolbar-compact :is(.input,.select,.button),
html body .topbar-actions > :is(.cloud-sync-toolbar-button,.topbar-history-button,.topbar-add-button,.topbar-tools-trigger),
html body .topbar-actions .month-navigator > :is(.month-nav-button,.month-control,.month-current-button,.month-status-chip),
html body .topbar-actions .month-navigator > #previousMonthButton,
html body .topbar-actions .month-navigator > #nextMonthButton,
html body .topbar-actions #topbarToolsTrigger,
html body #sidebar.sidebar .nav-button,
html body .sidebar .nav-button,
html body .sidebar .nav-button.active,
html body .sidebar .nav-icon,
html body #money .period-card .collapse-toggle,
html body #money .period-card > .period-header > .collapse-actions > button.collapse-toggle,
html body #money #availableMoneySection [data-collapse-toggle="available-money"],
html body #money #availableMoneySection button.collapse-toggle,
html body #income #monthlyBudgetPlannerToggle,
html body #income #monthlyBudgetPlannerCard.is-planner-collapsed #monthlyBudgetPlannerToggle,
html body #income #monthlyBudgetPlannerCard:not(.is-planner-collapsed) #monthlyBudgetPlannerToggle,
html body #income [data-budget-panel-toggle],
html body #income #monthlyBudgetPlannerCard button[data-budget-panel-toggle],
html body #paid-expenses [data-collapse-toggle="paid-expenses"],
html body #paid-expenses #paidExpensesSection [data-collapse-toggle="paid-expenses"],
html body #paidExpensesSection button.collapse-toggle,
html body #reports .report-compact-chevron,
html body .budget-panel-collapse,
html body #monthlyBudgetPlannerCard #monthlySavingsTarget,
html body #monthlyBudgetPlannerCard #setMonthlySavingsTarget,
html body #monthlyBudgetPlannerCard .savings-check-row input {
  border-radius: var(--talaan-control-radius) !important;
}

html body #monthlyBudgetPlannerCard .savings-confirmation,
html body #monthlyBudgetPlannerCard .savings-projection-row,
html body #monthlyBudgetPlannerCard .savings-outlook-stat {
  border-radius: var(--talaan-card-radius) !important;
}

html body #monthlyBudgetPlannerCard .cash-forecast-panel {
  border-radius: var(--talaan-section-radius) !important;
}

@media print,
       (forced-colors: active) {
  html body :is(
    .card,
    dialog,
    .modal,
    .dialog,
    .popover,
    .toast,
    .snackbar,
    .sidebar
  ) {
    box-shadow: none !important;
  }
}
