:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #172033;
  --muted: #657087;
  --blue: #3155d9;
  --orange: #9a4b0b;
  --border: #d8deeb;
  --danger: #a52b2b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--blue); }
.site-header {
  min-height: 76px;
  padding: 16px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  color: var(--text);
  font-size: 24px;
  font-weight: 750;
  text-decoration: none;
}
.brand span { color: var(--blue); }
.page { max-width: 1180px; margin: 0 auto; padding: clamp(20px, 4vw, 48px) 16px; }
.login-card, .card {
  max-width: 440px;
  margin: 40px auto;
  padding: clamp(22px, 5vw, 36px);
  background: var(--surface);
  border: 1px dashed var(--blue);
  border-radius: 18px;
}
h1 { margin: 0 0 12px; font-size: clamp(28px, 5vw, 40px); line-height: 1.15; }
.eyebrow { margin: 0 0 8px; color: var(--orange); font-weight: 700; text-transform: uppercase; font-size: 13px; letter-spacing: .08em; }
.muted { color: var(--muted); }
.alert { padding: 12px 14px; color: var(--danger); background: #fff0f0; border-radius: 10px; }
.form-stack { display: grid; gap: 18px; margin-top: 24px; }
label { display: grid; gap: 7px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  padding: 12px 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(49, 85, 217, .18); border-color: var(--blue); }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.button-primary { color: #fff; background: var(--blue); }
.button-secondary { color: var(--text); background: #eef1ff; }
.button:focus { outline: 3px solid rgba(237, 123, 54, .35); }
.cabinet-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 24px; }
.cabinet-card {
  display: grid;
  gap: 8px;
  padding: 20px;
  color: var(--text);
  background: var(--surface);
  border: 1px dashed var(--blue);
  border-radius: 14px;
  text-decoration: none;
}
.cabinet-card span { color: var(--muted); font-size: 14px; }
.cabinet-card.selected { border: 2px solid var(--blue); background: #eef1ff; }
.cabinet-niche { color: var(--orange) !important; font-size: 12px !important; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.account { overflow-wrap: anywhere; }
.goal-caption { min-height: 20px; }
.detail-section { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.detail-section h2 { margin: 0 0 10px; font-size: clamp(25px, 4vw, 34px); }
.topup-layout { display: grid; grid-template-columns: minmax(280px, 420px) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 32px; }
.topup-card { margin: 16px 0 0; max-width: none; }
.topup-status:empty { display: none; }
.operation-card { margin-top: 24px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.operation-card h3 { margin-top: 0; }
.warning-card { border-color: var(--orange); }
.history-block summary { margin: 16px 0 0; padding: 14px 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; font-weight: 700; cursor: pointer; }
.comment-cell { white-space: normal; min-width: 180px; }
.choose-cabinet { margin-top: 24px; }
.period-form { max-width: 460px; margin: 20px 0; }
.period-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 12px; }
.period-link { padding: 8px 13px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--surface); text-decoration: none; }
.period-link.active { color: #fff; background: var(--blue); border-color: var(--blue); }
.cabinet-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.cabinet-title strong { font-size: 19px; }
.metric-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--muted); }
.metric-line strong { color: var(--text); text-align: right; }
.cabinet-open { margin-top: 6px; color: var(--blue) !important; }
.status-stale { color: var(--danger); font-size: 13px; }
.cabinet-meta { margin: 16px 0; }
.cabinet-meta p { margin: 6px 0; }
.empty-state { padding: 24px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: 14px; }
.table-wrap { max-width: 100%; overflow-x: auto; margin-top: 20px; background: var(--surface); border-radius: 14px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
th, td { padding: 11px 10px; text-align: right; border-bottom: 1px solid #e8ebf1; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); background: #f8f9fc; font-weight: 650; }
.total-row { font-weight: 750; background: #eef1ff; }
@media (max-width: 800px) {
  .topup-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .site-header { min-height: 66px; }
  .login-card, .card { margin-top: 16px; }
  .cabinet-grid { grid-template-columns: minmax(0, 1fr); }
  .cabinet-title { align-items: flex-start; flex-direction: column; }
  .metric-line { gap: 8px; }
}
.direction-summary, .direction-section { margin-top: 28px; }
.base-metrics { display: flex; flex-wrap: wrap; gap: 12px 28px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.base-metrics span { color: var(--muted); }
.base-metrics strong { color: var(--text); }
