/* KairosIQ styles (D-054): brand navy #0f2a4a and gold #e8b04b, light and dark themes.
   Only logical properties (inline-start/end), so a left-to-right page mirrors without new rules. */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/vazirmatn-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --navy: #0f2a4a;
  --gold: #e8b04b;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-alt: #f0f3f7;
  --text: #13202f;
  --muted: #5b6676;
  --line: #e1e6ee;
  --accent: var(--navy);       /* buttons, links */
  --on-accent: #ffffff;
  --link: var(--navy);
  --gold-text: #b07a1c;        /* gold as text on a light page */
  --side-bg: var(--navy);
  --side-text: #ffffff;
  --side-muted: rgba(255, 255, 255, 0.68);
  --side-line: rgba(255, 255, 255, 0.14);
  --side-active: rgba(232, 176, 75, 0.18);
  --up: #15803d;
  --down: #dc2626;
  --amber: #d97706;
  --alert-bg: #fde8e8; --alert-text: #9b1c1c;
  --notice-bg: #e7f6ec; --notice-text: #1e6b3a;
  --shadow: 0 1px 2px rgba(15, 42, 74, 0.06), 0 4px 16px rgba(15, 42, 74, 0.05);
  color-scheme: light;
}

/* The dark set, twice: when the device is dark and nothing else was chosen, and when dark was chosen. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #08121f; --surface: #0f1d31; --surface-alt: #13243c; --text: #e7ecf3; --muted: #97a4b8;
    --line: #1f3350; --accent: var(--gold); --on-accent: var(--navy); --link: var(--gold); --gold-text: var(--gold);
    --side-bg: #0b1828; --side-line: rgba(255, 255, 255, 0.08); --up: #34d399; --down: #f87171; --amber: #fbbf24;
    --alert-bg: #3b1717; --alert-text: #f5b5b5; --notice-bg: #12301e; --notice-text: #9fe0b5;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #08121f; --surface: #0f1d31; --surface-alt: #13243c; --text: #e7ecf3; --muted: #97a4b8;
  --line: #1f3350; --accent: var(--gold); --on-accent: var(--navy); --link: var(--gold); --gold-text: var(--gold);
  --side-bg: #0b1828; --side-line: rgba(255, 255, 255, 0.08); --up: #34d399; --down: #f87171; --amber: #fbbf24;
  --alert-bg: #3b1717; --alert-text: #f5b5b5; --notice-bg: #12301e; --notice-text: #9fe0b5;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", system-ui, sans-serif;
  line-height: 1.8;
}
a { color: var(--link); }
h1 { margin: 0 0 16px; font-size: 1.5rem; font-weight: 700; }
.icon { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; }

/* Wordmark: the K-mark is the first letter, then "airos" and a gold "IQ". */
.wordmark { display: inline-flex; align-items: baseline; font-weight: 800; letter-spacing: 0.2px; line-height: 1;
            color: inherit; text-decoration: none; white-space: nowrap; }
.wordmark-k { width: 0.62em; height: 0.74em; margin-inline-end: 0.02em; overflow: visible; }
.wordmark-k .k { stroke: currentColor; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.wordmark-k .dot { fill: var(--gold); }
.wordmark-iq { color: var(--gold); }
.wordmark.on-light .wordmark-iq { color: var(--gold-text); }

/* App frame: a sidebar on the inline-start side (right in Persian), the page beside it. */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; width: 248px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 4px; padding: 20px 14px;
  background: var(--side-bg); color: var(--side-text); overflow-y: auto;
}
.sidebar .wordmark { font-size: 1.6rem; padding: 4px 10px 22px; align-self: center; }
.side-close { display: none; }
.nav-link, .nav-group > summary, .side-button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border: 0; border-radius: 10px; background: none;
  color: var(--side-muted); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: start;
}
.nav-link:hover, .nav-group > summary:hover, .side-button:hover { color: var(--side-text); background: rgba(255, 255, 255, 0.06); }
.nav-link.active { color: var(--side-text); background: var(--side-active); box-shadow: inset 3px 0 0 var(--gold); }
[dir="rtl"] .nav-link.active { box-shadow: inset -3px 0 0 var(--gold); }
.nav-link.active .icon { color: var(--gold); }
.nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--side-line); }
.nav-group > summary { list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary .chevron { margin-inline-start: auto; width: 16px; height: 16px; transition: transform 0.15s; }
.nav-group[open] > summary .chevron { transform: rotate(180deg); }
.nav-group .nav-link { padding-inline-start: 22px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 16px; }
.side-rate { display: block; padding: 10px 12px; border: 1px solid var(--side-line); border-radius: 10px;
             color: var(--side-text); text-decoration: none; font-size: 0.85rem; line-height: 1.6; }
.side-rate strong { font-size: 1.05rem; }
.side-rate small { display: block; color: var(--side-muted); font-size: 0.75rem; }
.side-rate .set { color: var(--gold); font-size: 0.75rem; }
.side-rate.stale small { color: #fbbf24; }
.side-row { display: flex; gap: 6px; }
.side-row form { flex: 1; }
.side-row .side-button { justify-content: center; }
.theme-toggle { width: auto; flex-shrink: 0; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.backdrop { display: none; }

/* Phone and small tablet: the sidebar becomes a drawer from the inline-start side. */
@media (max-width: 899px) {
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20;
    padding: 10px 12px; background: var(--side-bg); color: var(--side-text);
  }
  .topbar .wordmark { font-size: 1.3rem; margin-inline-end: auto; }
  .icon-button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
                 border: 0; border-radius: 10px; background: none; color: inherit; cursor: pointer; }
  .icon-button:hover { background: rgba(255, 255, 255, 0.08); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; width: min(84vw, 300px);
             transform: translateX(100%); transition: transform 0.2s ease; visibility: hidden; }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .menu-open .sidebar { transform: none; visibility: visible; }
  .side-close { display: inline-flex; position: absolute; top: 14px; inset-inline-end: 10px; color: var(--side-muted); }
  .menu-open .backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(4, 10, 20, 0.5); }
  .menu-open { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* Pages without a session: a light top bar with the wordmark. */
.public-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; }
.public-top .wordmark { font-size: 1.5rem; color: var(--text); }
.public-top .actions { display: flex; align-items: center; gap: 8px; }
.public-top .icon-button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
                           border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
                           color: var(--muted); cursor: pointer; }
.nav { color: var(--link); text-decoration: none; font-weight: 600; }

footer { margin-top: auto; padding: 16px; border-top: 1px solid var(--line); text-align: center;
         font-size: 0.8rem; color: var(--muted); }
footer p { margin: 0; }

/* Landing page */
.hero { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
        padding: 48px 16px; max-width: 640px; margin: 0 auto; }
.hero .wordmark { font-size: 3rem; margin-bottom: 12px; color: var(--text); }
.lead { margin: 0 0 24px; color: var(--muted); }
.rate { margin: 0 0 24px; padding: 16px 24px; border: 1px solid var(--line); border-radius: 14px; min-width: 260px;
        background: var(--surface); box-shadow: var(--shadow); }
.rate p { margin: 0; }
.rate-label { color: var(--muted); font-size: 0.9rem; }
.rate-value { font-size: 1.8rem; font-weight: 800; }
.rate-value span { font-size: 1rem; font-weight: 600; color: var(--muted); }
.rate-meta { color: var(--muted); font-size: 0.8rem; }
.rate.stale .rate-meta { color: var(--amber); }
.soon { margin: 0; padding: 6px 18px; border: 1px solid var(--gold); border-radius: 999px; font-weight: 600;
        color: var(--gold-text); }

/* Content */
.panel { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 32px 20px; }
.panel.wide { max-width: 1040px; }
.panel h2 { font-size: 1.1rem; margin: 24px 0 8px; }
.hint { color: var(--muted); font-size: 0.85rem; }
.muted { color: var(--muted); font-size: 0.8rem; }
.identities { padding-inline-start: 20px; }
.card { margin: 16px 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
        box-shadow: var(--shadow); }
.card h2 { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.cards .card { margin: 0; }
.alert { padding: 8px 12px; border-radius: 10px; background: var(--alert-bg); color: var(--alert-text); }
.notice { padding: 8px 12px; border-radius: 10px; background: var(--notice-bg); color: var(--notice-text); }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 20px; border: 1px solid transparent; border-radius: 10px;
  background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.button:hover { filter: brightness(1.08); }
.button.secondary { background: transparent; color: var(--text); border-color: var(--line); }
.button.danger { background: var(--down); color: #fff; }
.button.secondary.danger { background: transparent; color: var(--down); border-color: var(--down); }
.link { background: none; border: 0; color: var(--down); font: inherit; cursor: pointer; padding: 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

input, select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(232, 176, 75, 0.25); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.grid .full { grid-column: 1 / -1; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
tbody tr:nth-child(even) { background: var(--surface-alt); }

.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head .lead, .profile-head .hint { margin: 0; }
.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.avatar.initial { display: inline-flex; align-items: center; justify-content: center; background: var(--navy);
                  color: #fff; font-size: 1.6rem; font-weight: 700; }

.stat p { margin: 0; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 1.4rem; font-weight: 800; }
.stat-value span { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.stat-sub { color: var(--muted); font-size: 0.85rem; }
.up { color: var(--up); }
.down { color: var(--down); }
.chart-card { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; justify-content: center; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 6px; }
.dot.green { background: var(--up); }
.dot.amber { background: var(--amber); }
.dot.red { background: var(--down); }

.code { font-size: 2.6rem; font-weight: 800; letter-spacing: 0.4rem; margin: 8px 0; color: var(--gold-text); }
.code-input { font-size: 1.6rem; width: 7rem; text-align: center; letter-spacing: 0.3rem; }

/* Login and sign-up: one card, two buttons of the same shape. */
.auth { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px 48px; }
.auth-card { width: 100%; max-width: 420px; padding: 32px 28px; border: 1px solid var(--line); border-radius: 18px;
             background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.auth-card .wordmark { font-size: 2.2rem; color: var(--text); margin-bottom: 18px; }
.auth-card h1 { font-size: 1.25rem; margin-bottom: 6px; }
.auth-card .lead { margin-bottom: 22px; font-size: 0.95rem; }
.auth-card .alert, .auth-card .notice { text-align: start; margin-bottom: 16px; }
.auth-buttons { display: flex; flex-direction: column; gap: 10px; }
.auth-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px 16px;
               border-radius: 12px; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.auth-button svg { width: 20px; height: 20px; flex-shrink: 0; }
.auth-button.telegram { background: var(--navy); color: #fff; border: 1px solid var(--navy); }
.auth-button.telegram svg { fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.auth-button.google { background: #fff; color: #1f1f1f; border: 1px solid #d5dbe3; }
:root[data-theme="dark"] .auth-button.telegram { border-color: var(--side-line); }
.auth-card .hint { margin: 18px 0 0; }
.auth-card form.grid { text-align: start; }

/* Shared bits (D-055) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.strong { font-weight: 700; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
         background: var(--surface-alt); color: var(--muted); }
.badge.buy, .badge.deposit { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up); }
.badge.sell, .badge.withdraw { background: color-mix(in srgb, var(--down) 14%, transparent); color: var(--down); }
.icon-action { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
               border: 1px solid transparent; border-radius: 9px; background: none; color: var(--muted); cursor: pointer; }
.icon-action .icon { width: 18px; height: 18px; }
.icon-action.danger:hover { color: var(--down); border-color: var(--down);
                            background: color-mix(in srgb, var(--down) 8%, transparent); }
.button.small { padding: 6px 14px; font-size: 0.85rem; }
.button .icon { width: 18px; height: 18px; }
.table-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.table-foot .hint { margin: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
td.note { white-space: normal; min-width: 8rem; }
td.row-actions { width: 1%; text-align: end; }

/* Wide tables become one card per row on narrow screens; each cell shows its column name (data-label). */
.table-cards { width: 100%; }
@media (min-width: 761px) { .card:has(> .table-cards) { overflow-x: auto; } }
@media (max-width: 760px) {
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; }
  .table-cards tr { position: relative; margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--line);
                    border-radius: 12px; background: var(--surface); }
  .table-cards tbody tr:nth-child(even) { background: var(--surface-alt); }
  .table-cards td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0;
                    white-space: normal; text-align: end; }
  .table-cards td::before { content: attr(data-label); color: var(--muted); font-size: 0.85rem; text-align: start; }
  .table-cards td[dir="ltr"] { flex-direction: row-reverse; }
  .table-cards td:empty, .table-cards td.note:empty { display: none; }
  .table-cards td.row-actions { justify-content: flex-end; width: auto; margin-top: 6px; padding-top: 8px;
                                border-top: 1px solid var(--line); }
  .table-cards td.row-actions::before { content: none; }
  .form-actions .button { flex: 1; }
}

/* Coin box (D-055) */
.combo { position: relative; }
.combo input { width: 100%; }
.combo-list { position: absolute; z-index: 15; inset-inline: 0; top: calc(100% + 4px); max-height: 280px; overflow-y: auto;
              margin: 0; padding: 6px; list-style: none; border: 1px solid var(--line); border-radius: 12px;
              background: var(--surface); box-shadow: 0 8px 24px rgba(8, 18, 31, 0.18); }
.combo-group { padding: 6px 8px 2px; color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.combo-option { padding: 6px 10px; border-radius: 8px; cursor: pointer; color: var(--text); direction: ltr; text-align: left; }
.combo-option:hover, .combo-option[aria-selected="true"] { background: var(--surface-alt); }
.combo-option[aria-selected="true"] { box-shadow: inset 0 0 0 1px var(--gold); }
.combo-empty { padding: 8px 10px; color: var(--muted); }

/* Calendar (D-055) */
.date-field { position: relative; display: flex; gap: 6px; }
.date-field input { flex: 1; min-width: 0; }
.date-button { display: inline-flex; align-items: center; justify-content: center; width: 42px; flex-shrink: 0;
               border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); cursor: pointer; }
.date-button:hover, .date-button[aria-expanded="true"] { color: var(--gold-text); border-color: var(--gold); }
.calendar { position: absolute; z-index: 15; top: calc(100% + 4px); inset-inline-end: 0; width: 300px; max-width: 86vw;
            padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
            box-shadow: 0 8px 24px rgba(8, 18, 31, 0.18); color: var(--text); }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.cal-head select { flex: 1; min-width: 0; padding: 4px 6px; font-weight: 700; }
.cal-nav { width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 1.3rem;
           line-height: 1; cursor: pointer; }
.cal-nav:hover { background: var(--surface-alt); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-wd { color: var(--muted); font-size: 0.75rem; padding: 4px 0; }
.cal-day { height: 34px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; cursor: pointer; }
.cal-day:hover { background: var(--surface-alt); }
.cal-day.today { box-shadow: inset 0 0 0 1px var(--gold); }
.cal-day.picked { background: var(--navy); color: #fff; }
:root[data-theme="dark"] .cal-day.picked { background: var(--gold); color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cal-day.picked { background: var(--gold); color: var(--navy); } }
.cal-day:disabled { color: var(--line); cursor: default; background: none; }
.cal-time { display: flex; gap: 10px; margin-top: 10px; }
.cal-time label { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.cal-time input { width: 100%; text-align: center; direction: ltr; }
.cal-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }
.cal-actions .button { flex: 1; padding: 6px 10px; }

/* Profile (D-056) */
.profile-card { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.profile-card p { margin: 0; }
.profile-id { display: flex; flex-direction: column; gap: 4px; }
.profile-name { font-size: 1.25rem; font-weight: 800; }
.avatar.large { width: 88px; height: 88px; font-size: 2.2rem; }
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar-menu { position: absolute; bottom: -2px; inset-inline-start: -2px; }
.avatar-edit { list-style: none; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
               border-radius: 50%; border: 2px solid var(--surface); background: var(--gold); color: var(--navy); cursor: pointer; }
.avatar-edit::-webkit-details-marker { display: none; }
.avatar-edit .icon { width: 17px; height: 17px; }
.menu-pop { position: absolute; z-index: 15; top: calc(100% + 6px); inset-inline-start: 0; min-width: 240px; padding: 6px;
            border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
            box-shadow: 0 8px 24px rgba(8, 18, 31, 0.18); }
.menu-pop form { margin: 0; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
             background: none; color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer; text-align: start; }
.menu-item:hover { background: var(--surface-alt); }
.menu-item.danger { color: var(--down); }
.badge.gold { background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--gold-text); }
[data-copied] { color: var(--up); }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 16px; align-items: start; }
.profile-grid > div > .card:first-child { margin-top: 0; }
.linked { list-style: none; margin: 0; padding: 0; }
.linked li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.linked li:last-child { border-bottom: 0; }
.linked-name { flex: 1; display: flex; flex-direction: column; font-weight: 700; line-height: 1.5; }
.linked-name small { color: var(--muted); font-weight: 400; text-align: start; }
.provider { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px;
            border: 1px solid var(--line); background: var(--surface-alt); }
.provider.telegram { background: var(--navy); border-color: var(--navy); color: var(--gold); }
.setting-label { margin: 14px 0 6px; color: var(--muted); font-size: 0.9rem; }
.card h2 + .setting-label { margin-top: 0; }
.segmented { display: inline-flex; padding: 3px; gap: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-alt); }
.segmented button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 16px; border: 0; border-radius: 9px;
                    background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.segmented button .icon { width: 17px; height: 17px; }
.segmented button[aria-checked="true"], .segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text);
                                                                               box-shadow: 0 0 0 1px var(--gold); }

/* Dashboard and report (D-057) */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-tools { display: flex; align-items: center; gap: 12px; }
.page-tools .hint { margin: 0; }
.tiles { margin-bottom: 4px; }
.tile-main { border-top: 3px solid var(--gold); }
.welcome { text-align: center; padding: 40px 20px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.more { color: var(--gold-text); font-size: 0.85rem; text-decoration: none; font-weight: 600; }
.dash-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr); gap: 0 16px; align-items: stretch; }
.dash-grid > .chart-card { flex-direction: column; justify-content: center; }  /* as tall as the holdings beside it */
@media (max-width: 899px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.donut { position: relative; width: 180px; height: 180px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
                line-height: 1.3; }
.donut-center strong { font-size: 1.2rem; }
.donut-center small { color: var(--muted); font-size: 0.75rem; }
.holdings { display: flex; flex-direction: column; }
.holding-head, .holding > summary { display: grid; grid-template-columns: 1fr 1.4fr 1.2fr 1.2fr; gap: 10px; align-items: center; }
.holding-head { padding: 0 10px 6px; color: var(--muted); font-size: 0.8rem; border-bottom: 1px solid var(--line); }
.holding { border-bottom: 1px solid var(--line); }
.holding:nth-child(odd) { background: var(--surface-alt); }
.holding > summary { list-style: none; padding: 10px; cursor: pointer; }
.holding > summary::-webkit-details-marker { display: none; }
.holding > summary:hover { background: color-mix(in srgb, var(--gold) 8%, transparent); }
.holding > summary > span { display: flex; flex-direction: column; line-height: 1.4; }
.holding small { color: var(--muted); font-size: 0.75rem; }
.holding .h-pl small { color: inherit; opacity: 0.85; }
.h-asset { font-weight: 800; }
.bar { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-bottom: 3px; }
.bar > span { display: block; height: 100%; border-radius: 3px; background: var(--navy); }
:root[data-theme="dark"] .bar > span { background: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bar > span { background: var(--gold); } }
.holding-more { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; margin: 0;
                padding: 4px 10px 12px; }
.holding-more div { display: flex; flex-direction: column; }
.holding-more dt { color: var(--muted); font-size: 0.75rem; }
.holding-more dd { margin: 0; font-weight: 600; text-align: start; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.recent li:last-child { border-bottom: 0; }
.recent-at { margin-inline-start: auto; }
.sticky-first th:first-child, .sticky-first td:first-child { position: sticky; inset-inline-start: 0; z-index: 1;
                                                             background: var(--surface); }
.sticky-first tbody tr:nth-child(even) td:first-child { background: var(--surface-alt); }
tfoot th, tfoot td { border-top: 2px solid var(--line); border-bottom: 0; }

/* Monitoring (D-058) */
.page-head .hint { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.page-head .hint .icon { width: 16px; height: 16px; }
.status-bar { margin: 0 0 4px; padding: 12px 16px; border-radius: 12px; font-weight: 700; }
.status-bar.green { background: var(--notice-bg); color: var(--notice-text); }
.status-bar.amber { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.status-bar.red { background: var(--alert-bg); color: var(--alert-text); }
.mon-tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.mon-tiles .bar { margin: 6px 0 2px; }
.services { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.services li { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line);
               border-radius: 10px; font-weight: 700; }
.services li small { width: 100%; color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.services li.bad { border-color: var(--down); }
.sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 16px; }
.source { border-inline-start: 4px solid var(--up); }
.source.amber { border-inline-start-color: var(--amber); }
.source.red { border-inline-start-color: var(--down); }
.source-head { display: flex; align-items: center; gap: 4px; }
.source .hint { margin: 4px 0 8px; }
.spark { display: block; width: 100%; height: 22px; }
.spark .m-green { fill: var(--up); }
.spark .m-amber { fill: var(--amber); }
.spark .m-red { fill: var(--down); }
.spark .m-none { fill: var(--line); }
[dir="rtl"] .spark { transform: scaleX(-1); }  /* oldest on the right in Persian, now on the left */
.spark-axis { display: flex; justify-content: space-between; margin: 2px 0 0; color: var(--muted); font-size: 0.7rem; }
.problems { list-style: none; margin: 0; padding: 0; }
.problems li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 10px 12px; margin-bottom: 8px;
               border-radius: 10px; background: var(--alert-bg); color: var(--alert-text); }
.problems li small { margin-inline-start: auto; }

/* Service control (D-059) */
.service-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.service-actions form { margin: 0; }
.stop-box > summary { list-style: none; }
.stop-box > summary::-webkit-details-marker { display: none; }
.stop-box[open] { flex-basis: 100%; }
.stop-box .inline { margin-top: 8px; }
.stop-box .hint { margin: 4px 0 0; }

/* Users (D-060) */
.login-way { display: inline-flex; align-items: center; gap: 4px; margin-inline-end: 10px; font-size: 0.85rem; }
.login-way .icon { width: 16px; height: 16px; }
.user-actions { display: inline-flex; gap: 6px; margin: 0; }
.linked-name .badge { align-self: flex-start; margin-top: 2px; }
