/* ============================================================
   Qazyna — luxury dark/gold theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Playfair+Display:wght@600;700&display=swap');

:root {
  /* surfaces */
  --surface-0: #0c0a07;   /* app background */
  --surface-1: #14110b;   /* card background (validated dataviz surface) */
  --surface-2: #1c1811;   /* raised / input background */
  --surface-3: #262016;   /* hover / pressed */
  --hairline: #332c1f;

  /* text */
  --ink-primary: #f3ead9;
  --ink-secondary: #b9ab8f;
  --ink-muted: #7d715c;

  /* gold brand chrome (UI only, never for data) */
  --gold-1: #d4af37;
  --gold-2: #f4e4bc;
  --gold-gradient: linear-gradient(135deg, var(--gold-1) 0%, var(--gold-2) 100%);

  /* status (reserved, always paired with icon+label) */
  --status-good: #4e9f5c;
  --status-warning: #d9a441;
  --status-critical: #d14b4b;

  /* categorical palette (validated via dataviz skill, dark surface #14110B) */
  --cat-food: #b8862a;
  --cat-transport: #3e6fcc;
  --cat-housing: #c13f6e;
  --cat-health: #26a085;
  --cat-clothes: #c2703e;
  --cat-fun: #2aa6a6;
  --cat-subs: #8c6fd1;
  --cat-other: #9c8b2e;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-0);
  color: var(--ink-primary);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(212,175,55,0.10), transparent 60%),
    var(--surface-0);
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------- topbar */

.topbar {
  padding: calc(18px + env(safe-area-inset-top)) 20px 14px;
  text-align: center;
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(180deg, rgba(212,175,55,0.06), transparent);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.brand-gem {
  font-size: 18px;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar-sub {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ink-muted);
}

/* ---------------------------------------------------------- views */

#views {
  flex: 1;
  padding: 16px 16px 8px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fade-in 0.18s ease;
}

.view[hidden] { display: none; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------- cards */

.card {
  background: linear-gradient(160deg, var(--surface-1), var(--surface-2));
  border: 1px solid var(--hairline);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px rgba(0,0,0,0.25);
}

.card[hidden] { display: none; }

.card-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--ink-primary);
}

.card-hint {
  font-size: 13px;
  color: var(--ink-secondary);
  margin: -6px 0 14px;
  line-height: 1.5;
}

/* ---------------------------------------------------------- hero card */

.hero-card {
  text-align: center;
  border: 1px solid rgba(212,175,55,0.25);
  background:
    radial-gradient(ellipse 140% 100% at 50% -20%, rgba(212,175,55,0.14), transparent 60%),
    linear-gradient(160deg, var(--surface-1), var(--surface-2));
}

.hero-label {
  font-size: 12.5px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}

.hero-value {
  font-family: 'Playfair Display', serif;
  font-size: 34px;
  font-weight: 700;
  color: var(--ink-primary);
  margin-bottom: 14px;
}

.hero-value.gold-text {
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-row {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}

.hero-stat-label {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.hero-stat-value {
  font-size: 17px;
  font-weight: 700;
}

.hero-stat-value.income { color: var(--status-good); }
.hero-stat-value.expense { color: var(--status-critical); }

/* ---------------------------------------------------------- budget bar */

.budget-bar-track {
  height: 10px;
  border-radius: 6px;
  background: var(--surface-3);
  overflow: hidden;
  border: 1px solid var(--hairline);
}

.budget-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px 4px 4px 6px;
  background: var(--gold-gradient);
  transition: width 0.3s ease, background 0.3s ease;
}

.budget-bar-fill.warning { background: var(--status-warning); }
.budget-bar-fill.critical { background: var(--status-critical); }

.budget-caption {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ink-secondary);
}

/* ---------------------------------------------------------- tips */

.tips-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tips-list li {
  position: relative;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-secondary);
}

.tips-list li::before {
  content: "◆";
  position: absolute;
  left: 0;
  top: 1px;
  font-size: 10px;
  color: var(--gold-1);
}

/* ---------------------------------------------------------- category bars */

.category-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.category-bar-row:last-child { margin-bottom: 0; }

.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.category-bar-label {
  font-size: 12.5px;
  color: var(--ink-secondary);
  width: 84px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-bar-track {
  flex: 1;
  height: 8px;
  border-radius: 5px;
  background: var(--surface-3);
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  border-radius: 5px;
}

.category-bar-amount {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-primary);
  width: 66px;
  flex-shrink: 0;
  text-align: right;
}

/* ---------------------------------------------------------- forms */

.field-label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-secondary);
  margin: 12px 0 6px;
}

.field-label:first-of-type { margin-top: 0; }

.field-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--ink-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.field-input::placeholder { color: var(--ink-muted); }

.field-input:focus {
  border-color: var(--gold-1);
}

select.field-input {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
                     linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* segmented control (расход / доход) */

.segmented {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}

.segmented-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 0;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented-btn.active {
  background: var(--gold-gradient);
  color: #1a1408;
}

/* buttons */

.btn-gold {
  width: 100%;
  margin-top: 16px;
  border: none;
  border-radius: 12px;
  padding: 13px 0;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #1a1408;
  background: var(--gold-gradient);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(212,175,55,0.25);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-gold:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(212,175,55,0.2);
}

.btn-gold:disabled {
  opacity: 0.55;
  box-shadow: none;
  cursor: default;
}

.btn-ghost-danger {
  border: none;
  background: transparent;
  color: var(--status-critical);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}

.form-message {
  margin-top: 10px;
  font-size: 13px;
  min-height: 16px;
}

.form-message.success { color: var(--status-good); }
.form-message.error { color: var(--status-critical); }

/* ---------------------------------------------------------- transaction history */

#tx-history {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--hairline);
}

.tx-row:last-child { border-bottom: none; }

.tx-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tx-info { flex: 1; min-width: 0; }

.tx-category {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-primary);
}

.tx-meta {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-amount {
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.tx-amount.income { color: var(--status-good); }
.tx-amount.expense { color: var(--ink-primary); }

.tx-delete {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 2px 4px 8px;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
  padding: 18px 0;
}

/* ---------------------------------------------------------- buy verdict */

.verdict-card {
  text-align: center;
}

.verdict-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.verdict-badge.yes { background: rgba(78,159,92,0.16); color: var(--status-good); }
.verdict-badge.maybe { background: rgba(217,164,65,0.16); color: var(--status-warning); }
.verdict-badge.careful { background: rgba(217,164,65,0.16); color: var(--status-warning); }
.verdict-badge.no { background: rgba(209,75,75,0.16); color: var(--status-critical); }

.verdict-title {
  font-family: 'Playfair Display', serif;
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 14px;
}

.verdict-reasons {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.verdict-reasons li {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-secondary);
  padding-left: 18px;
  position: relative;
}

.verdict-reasons li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--ink-muted);
}

/* ---------------------------------------------------------- split bar (calculator) */

.split-bar {
  display: flex;
  height: 12px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface-3);
  margin: 4px 0 14px;
}

.split-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.split-contributed { background: var(--ink-muted); }
.split-interest { background: var(--gold-gradient); }

.split-legend {
  display: flex;
  gap: 22px;
}

.legend-item {
  font-size: 12.5px;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-item b { color: var(--ink-primary); font-weight: 700; }

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-contributed { background: var(--ink-muted); }
.dot-interest { background: var(--gold-1); }

/* ---------------------------------------------------------- tabbar */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  background: rgba(20,17,11,0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--hairline);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 10;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--ink-muted);
  font-family: inherit;
  padding: 6px 2px;
  cursor: pointer;
  border-radius: 10px;
  transition: color 0.15s ease;
}

.tab-icon {
  font-size: 17px;
  line-height: 1;
}

.tab-label {
  font-size: 10px;
  font-weight: 600;
}

.tab-btn.active {
  color: var(--gold-1);
}

/* ---------------------------------------------------------- scrollbar (desktop preview) */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 6px; }

/* ---------------------------------------------------------- small screens */

@media (max-width: 360px) {
  .hero-value { font-size: 28px; }
  .category-bar-label { width: 68px; }
}
