@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f8f8f5;
  --ink: #16181d;
  --muted: #656c78;
  --line: #e6e6df;
  --line-strong: #d4d4ca;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --ok: #147a43;
  --ok-soft: #e8f6ee;
  --warn: #9a5a08;
  --warn-soft: #fbf1df;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --shadow: 0 1px 2px rgb(16 18 25 / 4%), 0 22px 44px -32px rgb(16 18 25 / 28%);
  --radius: 20px;
  --font: "Vazirmatn", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d12;
    --surface: #131720;
    --surface-2: #0f131b;
    --ink: #eef1f6;
    --muted: #9aa3b2;
    --line: #232a36;
    --line-strong: #333c4d;
    --accent: #9199ff;
    --accent-ink: #0b0d12;
    --accent-soft: #1b2040;
    --ok: #57d38c;
    --ok-soft: #11251a;
    --warn: #f0b35c;
    --warn-soft: #2a2114;
    --danger: #f28b82;
    --danger-soft: #2c1719;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 26px 56px -30px rgb(0 0 0 / 70%);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  position: relative;
  isolation: isolate;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: -220px -10% auto;
  height: 560px;
  background: radial-gradient(50% 60% at 68% 0%, color-mix(in oklab, var(--accent) 9%, transparent), transparent 72%);
  pointer-events: none;
  z-index: -1;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

bdi,
code {
  unicode-bidi: isolate;
}

code {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", monospace;
  font-size: 0.86em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
}

.topbar,
.shell,
.login-wrap {
  position: relative;
  z-index: 1;
}

.topbar {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 24px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in oklab, var(--accent) 22%, transparent);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  min-width: 0;
}

.brand-text strong {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-text small {
  font-size: 0.74rem;
  color: var(--muted);
}

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 24px 56px;
}

.accounts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.card-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.card-icon-svg {
  width: 22px;
  height: 22px;
}

.card-title h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.5;
}

.card-sub {
  margin: 1px 0 0;
  font-size: 0.71rem;
  color: var(--muted);
  line-height: 1.6;
}

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 600;
  line-height: 1.9;
  white-space: nowrap;
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chip-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chip-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-muted {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.amount-block {
  margin-top: 22px;
}

.amount {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.amount-value {
  font-size: clamp(2.1rem, 4.2vw, 2.7rem);
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.amount-unit {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.amount-unknown {
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: 0;
  color: var(--muted);
}

.amount-note {
  margin: 5px 0 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.split dt {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.8;
}

.split dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

.packages {
  list-style: none;
  margin: 18px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 15px;
}

.pkg {
  display: grid;
  gap: 6px;
}

.pkg-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.pkg-name {
  font-size: 0.87rem;
  font-weight: 550;
  min-width: 0;
}

.pkg-value {
  flex: 0 0 auto;
  font-size: 0.87rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.pkg-value small {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--muted);
}

.bar {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}

.bar::-webkit-progress-bar {
  background: var(--line);
  border-radius: 999px;
}

.bar::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

.bar::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.bar-low::-webkit-progress-value {
  background: var(--warn);
}

.bar-low::-moz-progress-bar {
  background: var(--warn);
}

.bar-dead::-webkit-progress-value {
  background: var(--line-strong);
}

.bar-dead::-moz-progress-bar {
  background: var(--line-strong);
}

.pkg-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.71rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pkg-dead .pkg-name,
.pkg-dead .pkg-value {
  color: var(--muted);
}

.pkg-date {
  font-size: 0.68rem;
  color: var(--muted);
}

.pkg-dead .pkg-date {
  opacity: 0.8;
}

.no-packages {
  margin: 18px 0 0;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}

.empty-state {
  margin-top: 22px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: var(--surface-2);
}

.empty-state p {
  margin: 0;
  font-size: 0.85rem;
}

.empty-hint {
  margin-top: 7px !important;
  color: var(--muted);
  font-size: 0.74rem !important;
}

.notice {
  margin: 14px 0 0;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  line-height: 1.8;
}

.notice-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in oklab, var(--warn) 20%, transparent);
}

.notice-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in oklab, var(--danger) 22%, transparent);
}

.card-foot {
  margin: 14px 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.meta-start {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-note,
.meta-updated {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.refresh-status {
  margin: 6px 0 0;
  min-height: 1.4em;
  font-size: 0.73rem;
  color: var(--muted);
}

.refresh-status.is-error {
  color: var(--danger);
}

#dashboard.is-refreshing #dashboard-content {
  opacity: 0.55;
  transition: opacity 180ms ease;
}

#dashboard-content {
  opacity: 1;
  transition: opacity 180ms ease;
}

.btn {
  appearance: none;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 550;
  line-height: 1;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, filter 160ms ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  width: 100%;
  min-height: 48px;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:active {
  transform: translateY(0.5px);
}

/* --- login --------------------------------------------------------------- */

.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.login-wrap {
  width: 100%;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(24px, 5vw, 38px);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 26px 0 6px;
  font-size: 1.55rem;
  font-weight: 750;
  letter-spacing: -0.015em;
  line-height: 1.5;
}

.login-sub {
  margin: 0;
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.9;
}

.login-form {
  margin-top: 22px;
  display: grid;
  gap: 8px;
}

.login-form label {
  font-size: 0.8rem;
  font-weight: 550;
}

.login-form input {
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  min-height: 48px;
  padding: 11px 14px;
  width: 100%;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-form .btn {
  margin-top: 8px;
}

.login-foot {
  margin: 22px 0 0;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  font-size: 0.71rem;
  color: var(--muted);
}

@media (max-width: 899px) {
  .accounts {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 18px 14px 8px;
  }

  .shell {
    padding: 16px 14px 44px;
  }

  .card {
    padding: 19px;
    border-radius: 17px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .chip {
    font-size: 0.67rem;
    padding: 2px 8px;
  }

  .card-icon {
    display: none;
  }

  .meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .login-page {
    padding: 20px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
