/* Presentation layer shared by desktop and mobile.
   Business components, route visibility and device-specific settings stay in styles.css. */
:root {
  --background: #f4f5f1;
  --surface: #fff;
  --surface-secondary: #f6f7f3;
  --surface-tertiary: #e9ede6;
  --ink: #202e27;
  --ink-soft: #47594e;
  --muted: #748076;
  --muted-light: #889289;
  --brand-950: #172d26;
  --brand-900: #204638;
  --brand-800: #2a5042;
  --brand: #246653;
  --brand-deep: #194c3d;
  --brand-bright: #b5c997;
  --brand-soft: #dfebdf;
  --brand-pale: #edf3eb;
  --accent: var(--brand);
  --border: #e0e5dc;
  --border-subtle: #edf0e9;
  --border-strong: #bac9ba;
  --shadow-xs: 0 2px 6px rgba(30, 50, 35, .025);
  --shadow-sm: 0 10px 30px rgba(30, 50, 35, .06);
  --radius: 10px;
  --radius-lg: 20px;
}

body { line-height: 1.5; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:is(button, a, input, select, textarea):focus-visible { outline: 3px solid #7da88b; outline-offset: 3px; }
.skip-link { position: fixed; top: -80px; left: 20px; z-index: 100; padding: 12px 20px; border-radius: 10px; color: white; background: var(--brand); }
.skip-link:focus { top: 16px; }

/* Desktop workspace */
.sidebar { width: 228px; background: var(--brand-950); border: 0; }
.sidebar-inner { padding: 38px 20px 24px; overflow-y: auto; }
.brand { gap: 13px; padding: 0 7px 48px; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; color: #d5e2bf; border-color: #52694f; background: #263f31; }
.brand-copy strong { font-size: 23px; letter-spacing: .14em; }
.brand-copy small { margin-top: 8px; color: #a6b9a8; font-size: 8px; letter-spacing: .17em; }
.nav-label { padding: 0 15px 14px; font-size: 10px; color: #8da395; letter-spacing: .12em; }
.side-nav { gap: 9px; }
.side-nav a { min-height: 52px; padding: 0 16px; border-radius: 12px; color: #b4c6b9; font-size: 14px; }
.side-nav a svg { color: #a0b6a7; }
.side-nav a:hover { background: #253f32; }
.side-nav a.active { color: #e8f0d8; background: #344e3a; box-shadow: none; }
.side-nav a.active svg { color: #cee0ab; }
.side-nav a.active::before { left: -20px; height: 24px; background: #d0ddb1; border-radius: 0 3px 3px 0; }
.security-note { padding: 16px 12px; border-color: #395044; background: #20372c; border-radius: 14px; }
.security-note strong { color: #d2e0d1; }
.security-note p, .sidebar-foot { color: #9fb2a4; }
.status-dot { background: #b4ca91; box-shadow: 0 0 0 4px #334937; }
.sidebar-foot { padding: 18px 0 0; border-color: #395044; }
.sidebar-foot b { color: #c0d0c2; }
.main { width: calc(100% - 228px); max-width: none; margin-left: 228px; padding: 38px clamp(24px, 3.3vw, 64px) 56px; }
.topbar, .main > .view, .main > #alert-area, .main > .view.settings-page { max-width: 1440px; }
.topbar { margin-bottom: 30px; }
.workspace-eyebrow { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; color: var(--brand); font-size: 10px; font-weight: 600; letter-spacing: .16em; }
.workspace-eyebrow span { padding-left: 12px; border-left: 1px solid #c5cec1; color: var(--muted); font-size: 11px; font-weight: 400; letter-spacing: .04em; }
.topbar h1, body.credit-cards-route .topbar h1 { margin: 0; font-size: 30px; font-weight: 600; letter-spacing: -.04em; line-height: 1.35; }
.page-description { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

/* Overview: net worth and recurring costs, followed by allocation. */
.view[data-view="dashboard"]:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(270px, 1fr); gap: 22px; align-items: stretch; }
.hero-grid { display: block; min-width: 0; margin: 0; }
.net-worth-card { height: 100%; min-height: 304px; padding: 28px 32px; border: 1px solid #31513b; border-radius: 22px; background: #244936; box-shadow: 0 12px 28px rgba(34, 64, 44, .09); }
.net-worth-card::before { width: 420px; height: 420px; right: -215px; bottom: -178px; border: 1px solid rgba(211, 225, 174, .2); }
.net-worth-card::after { width: 310px; height: 310px; right: -160px; bottom: -123px; border: 1px solid rgba(211, 225, 174, .17); box-shadow: 0 0 0 54px rgba(211, 225, 174, .025); }
.card-label { color: #eef4e7; font-size: 14px; font-weight: 500; gap: 12px; }
.card-label small { color: #b4c6a6; font-size: 10px; letter-spacing: .13em; }
.net-worth-card .refresh-button { height: 34px; min-height: 34px; color: #e4edda; border: 1px solid #587352; background: rgba(255,255,255,.035); border-radius: 9px; }
.net-worth-card .refresh-button:hover:not(:disabled) { color: white; background: #3c5d41; }
.net-amount-row { gap: 10px; margin: 23px 0 10px; }
.net-amount-row .net-amount { font-size: clamp(32px, 3.6vw, 56px); font-weight: 500; letter-spacing: -.045em; line-height: 1.15; }
.net-worth-card .visibility-toggle { flex: none; width: 38px; height: 38px; min-height: 38px; padding: 0; color: #c6d6b9; background: transparent; border: 0; }
.net-worth-card .visibility-toggle:hover { color: white; background: #3c5d41; }
.net-currency-note { position: relative; z-index: 1; margin: 0; color: #b4c6a6; font-size: 11px; }
.net-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; margin-top: 25px; padding-top: 20px; border-top: 1px solid #4a6548; }
.net-split > div { min-width: 0; }
.net-split small { color: #bdceb2; font-size: 11px; margin-bottom: 6px; }
.net-split strong { display: block; color: #eff4e8; font-size: clamp(16px, 1.6vw, 24px); font-weight: 500; overflow-wrap: anywhere; }
.subscription-dashboard-panel { margin: 0; padding: 24px; border-radius: 22px; background: #fff; }
.section-eyebrow { display: block; margin-bottom: 6px; color: var(--muted); font-size: 9px; letter-spacing: .16em; }
.dashboard-grid .chart-panel .panel-head, .subscription-dashboard-panel .panel-head { padding: 0 0 18px; border: 0; }
.dashboard-grid .chart-panel .panel-head h2, .subscription-dashboard-panel .panel-head h2 { margin: 0; padding: 0; font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.dashboard-grid .chart-panel .panel-head h2::before, .subscription-dashboard-panel .panel-head h2::before { content: none; }
.panel-link { color: var(--brand); font-size: 11px; white-space: nowrap; }
.subscription-dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; border: 0; border-radius: 0; background: transparent; gap: 18px 12px; }
.subscription-dashboard-metrics > div { padding: 0; }
.subscription-dashboard-metrics > div + div { border: 0; }
.subscription-dashboard-metrics > div:first-child { grid-column: 1 / -1; padding: 0 0 17px; border-bottom: 1px solid var(--border); }
.subscription-dashboard-metrics span { color: var(--muted); font-size: 11px; }
.subscription-dashboard-metrics strong { margin-top: 6px; font-size: 19px; font-weight: 500; overflow-wrap: anywhere; }
.subscription-dashboard-metrics > div:first-child strong { color: var(--brand); font-size: 38px; line-height: 1.15; }
.dashboard-grid { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; margin: 0; }
.dashboard-grid .chart-panel { min-width: 0; padding: 25px 26px; border-color: var(--border); background: white; }
.distribution-panel, .category-panel { grid-column: auto; }
.dashboard-grid .distribution-body, .dashboard-grid .bars, .dashboard-grid .region-bars { margin-top: 0; padding: 14px 0 0; border: 0; border-radius: 0; background: transparent; }
.dashboard-grid .distribution-body { gap: 24px; justify-content: space-between; min-height: 205px; }
.donut { width: 164px; height: 164px; }
.donut::after { width: 128px; height: 128px; border: 0; }
.donut strong { font-size: 18px; }
.donut span { font-size: 10px; }
.legend { flex: 1; gap: 15px; }
.legend-item { font-size: 12px; }
.legend-item strong { font-size: 11px; }
.legend-item i { border-radius: 50%; }
.dashboard-grid .bars { gap: 20px; }
.bar-meta { margin-bottom: 10px; font-size: 12px; }
.bar-meta strong { font-size: 12px; }
.bar-label .ui-icon { width: 25px; height: 25px; padding: 5px; }
.bar-track { height: 6px; border-radius: 10px; }
.bar-fill { border-radius: 10px; }
.region-panel { grid-column: 1 / -1; }
.region-bar { padding: 18px 20px; background: var(--surface-secondary); border: 0; border-radius: 12px; }

/* Accounts, subscriptions and settings share the same control rhythm. */
.button { border-radius: 10px; }
.button-primary { box-shadow: 0 3px 8px rgba(36,102,83,.1); }
.account-mode-tabs { display: inline-flex; gap: 4px; padding: 5px; margin-bottom: 22px; border: 1px solid var(--border); border-radius: 12px; background: #e9ede5; }
.account-mode-tabs button { min-height: 39px; padding: 0 24px; font-size: 13px; border-radius: 8px; }
.account-mode-tabs button.active { color: var(--brand-deep); background: white; box-shadow: 0 2px 5px rgba(30,50,35,.06); }
.account-mode-tabs button::after { content: none; }
.account-panel-control-bar { justify-content: flex-start; }
.account-controls { gap: 12px; padding-bottom: 0; }
.account-controls .search-box, .credit-card-controls .search-box { width: 320px; }
.search-box, .settings-search { box-shadow: none; border-color: var(--border); border-radius: 11px; }
.search-box { height: 44px; }
.search-box input, .settings-search input { font-size: 13px; }
.select-wrap select { height: 44px; font-size: 12px; border-color: var(--border); border-radius: 11px; background-color: white; }
.search-box:focus-within, .settings-search:focus-within { border-color: #729a7e; box-shadow: 0 0 0 3px rgba(70,120,85,.09); }
.account-grid, #credit-card-list.credit-card-list, .subscription-list { gap: 14px; }
.account-card.account-overview-card, .credit-card-issuer-card, .subscriptions-page .subscription-group-card { border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-xs); }
.account-card:hover, .rate-card:hover { transform: none; }
.account-overview-card.is-expanded, .credit-card-issuer-card.is-expanded, .subscriptions-page .subscription-group-card.is-expanded { border-color: #c6d3c0; box-shadow: var(--shadow-sm); }
.account-overview-card .institution-toggle { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "logo heading summary"; min-height: 102px; gap: 18px; padding: 20px 10px 20px 24px; }
.account-overview-card .institution-logo { width: 54px; height: 54px; border-radius: 16px; }
.account-overview-card .account-card-head h3 { font-size: 17px; font-weight: 600; }
.account-overview-card .institution-summary strong { font-size: 24px; font-weight: 500; }
.credit-card-issuer-card .credit-card-group-summary > strong { color: var(--muted); font-size: 12px; }
.account-overview-card .sub-list, .credit-card-issuer-card .sub-list.credit-card-group-list { border-top-color: var(--border-subtle); }
.sub-row:hover, .credit-card-row:hover { background: var(--surface-secondary); }
.more-btn, .close-btn { border-radius: 10px; }
.account-list-add { min-height: 58px; background: #eef2e9; border-color: #bdcdb7; border-radius: 15px; }
.sub-account-add { border-color: var(--border); background: var(--surface-secondary); }
.subscription-control-bar { gap: 20px; padding-bottom: 14px; }
.subscription-tabs { gap: 22px; }
.subscription-tabs button { font-size: 13px; }
.settings-shell { grid-template-columns: 210px minmax(0, 1fr); gap: 24px; }
.settings-nav { padding: 16px 10px; border: 1px solid var(--border); border-radius: 16px; background: #fff; }
.settings-section { border-color: var(--border); border-radius: 18px; box-shadow: var(--shadow-xs); }
.settings-section-head { background: var(--surface-secondary); }
.rate-card { border-radius: 13px; }
#entity-dialog, .image-library-dialog, .credit-card-detail-dialog { border-color: var(--border); box-shadow: 0 30px 90px rgba(18,40,27,.22); }
dialog::backdrop { background: rgba(20,38,28,.38); backdrop-filter: blur(4px); }
.field input, .field select, .field textarea { border-radius: 10px; }

@media (min-width: 721px) and (max-width: 1100px) {
  .view[data-view="dashboard"]:not([hidden]) { grid-template-columns: minmax(0, 1.55fr) minmax(240px, 1fr); gap: 18px; }
  .net-worth-card { padding: 25px; }
  .subscription-dashboard-panel { padding: 22px; }
  .subscription-dashboard-metrics strong { font-size: 16px; }
  .dashboard-grid { gap: 18px; }
  .dashboard-grid .distribution-body { flex-direction: column; gap: 20px; }
  .legend { width: 100%; }
  .subscription-control-bar { align-items: stretch; flex-direction: column; gap: 10px; }
}

@media (min-width: 721px) and (max-width: 960px) {
  .sidebar { width: 80px; }
  .sidebar-inner { padding: 30px 12px; }
  .brand { padding: 0 0 32px; }
  .side-nav a { padding: 0; }
  .side-nav a span { display: none; }
  .side-nav a.active::before { left: -12px; }
  .security-note { padding: 12px; }
  .security-note > div { display: none; }
  .security-note .status-dot { margin: 0; }
  .main { width: calc(100% - 80px); margin-left: 80px; padding: 28px 24px 40px; }
  .settings-shell { grid-template-columns: 1fr; }
  .settings-nav { position: static; }
}

/* Phone entrance: readable header, compact cards and anchored navigation. */
@media (max-width: 720px) {
  body { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .main { width: 100%; margin-left: 0; padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
  .topbar { display: flex; margin-bottom: 24px; }
  .workspace-eyebrow { margin-bottom: 9px; font-size: 9px; letter-spacing: .13em; }
  .workspace-eyebrow span { font-size: 10px; }
  .topbar h1, body.credit-cards-route .topbar h1 { font-size: 26px; }
  .page-description { margin-top: 7px; font-size: 12px; line-height: 1.65; }
  .view[data-view="dashboard"]:not([hidden]) { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .net-worth-card { min-height: 260px; padding: 22px; border-radius: 20px; }
  .card-label { font-size: 13px; }
  .card-label small { font-size: 9px; }
  .net-worth-card .refresh-button { width: 36px; min-width: 36px; padding: 0; }
  .net-worth-card .refresh-button span { display: none; }
  .net-amount-row { margin-top: 20px; gap: 5px; }
  .net-amount-row .net-amount { font-size: clamp(27px, 8.3vw, 40px); }
  .net-currency-note { font-size: 10px; }
  .net-split { margin-top: 23px; padding-top: 18px; gap: 16px; }
  .net-split small { font-size: 11px; }
  .net-split strong { font-size: clamp(14px, 4.2vw, 20px); }
  .subscription-dashboard-panel { padding: 19px 20px; border-radius: 18px; }
  .subscription-dashboard-panel .panel-head { padding-bottom: 16px; }
  .subscription-dashboard-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
  .subscription-dashboard-metrics > div:first-child { grid-column: auto; padding: 0; border: 0; }
  .subscription-dashboard-metrics strong, .subscription-dashboard-metrics > div:first-child strong { margin-top: 7px; font-size: clamp(14px, 4vw, 19px); line-height: 1.4; }
  .subscription-dashboard-metrics span { font-size: 10px; }
  .section-eyebrow { margin-bottom: 5px; font-size: 8px; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; margin: 0; }
  .dashboard-grid .chart-panel { min-height: 0; padding: 21px 20px; border-radius: 18px; }
  .dashboard-grid .chart-panel .panel-head { padding: 0 0 14px; }
  .dashboard-grid .chart-panel .panel-head h2, .subscription-dashboard-panel .panel-head h2 { font-size: 16px; }
  .dashboard-grid .distribution-body { min-height: 170px; gap: 20px; padding: 8px 0 0; }
  .donut { width: 136px; height: 136px; }
  .donut::after { width: 104px; height: 104px; }
  .donut strong { font-size: 15px; }
  .legend { gap: 13px; }
  .legend-item { gap: 6px; font-size: 11px; }
  .legend-item strong { font-size: 10px; }
  .dashboard-grid .bars { padding: 4px 0 0; gap: 18px; }
  .dashboard-grid .region-bars { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 10px; }
  .region-bar { padding: 16px; }
  .account-mode-tabs { display: flex; margin-bottom: 16px; }
  .account-mode-tabs button { min-height: 42px; padding: 0 12px; }
  .account-controls { padding-top: 0; }
  .account-controls .search-box, .credit-card-controls .search-box { width: 100%; }
  .search-box { height: 48px; }
  .search-box input, .settings-search input, .field input, .field select, .field textarea { font-size: 16px; }
  .account-panel-control-bar { margin-bottom: 16px; }
  .account-grid, #credit-card-list.credit-card-list, .subscription-list { gap: 12px; }
  .account-overview-card .institution-toggle { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "logo heading" "logo summary"; gap: 5px 12px; min-height: 96px; padding: 17px 8px 17px 16px; }
  .account-overview-card .institution-logo { width: 48px; height: 48px; border-radius: 14px; }
  .account-overview-card .account-card-head h3 { font-size: 16px; }
  .account-overview-card .institution-summary strong { font-size: 20px; }
  .account-overview-card .institution-summary { text-align: left; justify-content: flex-start; }
  .account-overview-card .sub-list { padding: 8px 12px 12px; }
  .credit-card-issuer-card .institution-toggle { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "logo heading" "logo summary"; gap: 5px 12px; }
  .credit-card-issuer-card .credit-card-group-summary > strong { font-size: 11px; }
  .subscription-group-card .institution-summary strong { font-size: 16px; }
  .subscription-control-bar { padding-bottom: 0; }
  .subscription-tabs { margin-bottom: 14px; gap: 20px; }
  .settings-shell { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .settings-nav { padding: 8px; border-radius: 12px; }
  .settings-section { border-radius: 16px; }
  .more-btn, .close-btn { min-width: 44px; min-height: 44px; }
  .mobile-nav { min-height: 66px; width: min(440px, calc(100% - 32px)); padding: 6px; border: 1px solid #d7e0d0; border-radius: 22px; background: rgba(252,253,249,.96); box-shadow: 0 8px 30px rgba(28,51,31,.13); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
  .mobile-nav::before { content: none; }
  .mobile-nav a, .mobile-nav .mobile-nav-more-toggle { min-height: 52px; color: #69786b; border-radius: 16px; font-size: 11px; }
  .mobile-nav a.active, .mobile-nav .mobile-nav-more-toggle.active { color: #244c37; background: #e4ecd9; box-shadow: none; }
  .mobile-nav a svg { width: 21px; height: 21px; }
  .mobile-more-menu:not([hidden]) { border-color: var(--border); background: #fcfdf9; }
  .toast { bottom: calc(98px + env(safe-area-inset-bottom)); }
}

@media (max-width: 360px) {
  .net-worth-card { padding: 19px; }
  .dashboard-grid .distribution-body { flex-direction: column; gap: 20px; }
  .legend { width: 100%; }
  .subscription-dashboard-panel { padding: 18px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
