:root {
  --bg: #0f1412;
  --bg-elevated: #171d1a;
  --bg-soft: #1e2622;
  --line: rgba(232, 224, 208, 0.08);
  --line-strong: rgba(232, 224, 208, 0.16);
  --text: #f3eee4;
  --muted: #9aa59c;
  --accent: #e8a045;
  --accent-2: #f0c27a;
  --accent-soft: rgba(232, 160, 69, 0.14);
  --ok: #4fbf8a;
  --warn: #e8a045;
  --danger: #e56b5d;
  --today: #6db3f2;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --font: "Manrope", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at -10% -20%, rgba(232, 160, 69, 0.12), transparent 55%),
    radial-gradient(900px 500px at 110% 0%, rgba(79, 191, 138, 0.08), transparent 50%),
    linear-gradient(160deg, #101613 0%, #0c100e 45%, #121816 100%);
  background-attachment: fixed;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: #fff; }
code, .mono { font-family: var(--mono); font-size: 0.9em; }

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: rgba(12, 16, 14, 0.72);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand { display: flex; gap: 14px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px;
  background:
    linear-gradient(135deg, var(--accent) 0%, #c9782a 45%, #2f6b52 100%);
  box-shadow: 0 10px 30px rgba(232, 160, 69, 0.25);
  position: relative;
  display: grid;
  place-items: center;
  color: #1a1208;
}
.brand-mark::after { display: none; }
.brand-icon { width: 22px; height: 22px; }
.brand-name { font-weight: 800; letter-spacing: -0.03em; font-size: 1.05rem; }
.brand-sub { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.sidebar-foot { display: grid; gap: 10px; }

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.icon {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -0.2em;
}
.icon-sm { width: 1rem; height: 1rem; }
.icon-xs { width: 0.85rem; height: 0.85rem; }

.nav-link {
  color: var(--muted);
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
  transition: 0.18s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-link .icon { opacity: 0.85; }
.nav-link:hover { background: var(--bg-soft); color: var(--text); }
.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-2);
  box-shadow: inset 0 0 0 1px rgba(232, 160, 69, 0.25);
}
.nav-link.is-active .icon { color: var(--accent); opacity: 1; }

.bot-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); font-size: 0.85rem;
}

.stat-label {
  color: var(--muted); font-size: 0.82rem; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}

.panel-head h2 {
  margin: 0; font-size: 1.05rem; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 8px;
}

.cell-with-icon {
  display: inline-flex; align-items: center; gap: 6px;
}
.money-line {
  display: inline-flex; align-items: center; gap: 6px;
}

.countdown {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.countdown-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(79,191,138,0.15);
}
.countdown.is-soon {
  color: var(--accent-2);
  border-color: rgba(232,160,69,0.3);
  background: rgba(232,160,69,0.08);
}
.countdown.is-soon .countdown-dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(232,160,69,0.18);
  animation: pulse 1.4s ease-in-out infinite;
}
.countdown.is-today {
  color: #9dceff;
  border-color: rgba(109,179,242,0.35);
  background: rgba(109,179,242,0.1);
}
.countdown.is-today .countdown-dot {
  background: var(--today);
  box-shadow: 0 0 0 3px rgba(109,179,242,0.2);
  animation: pulse 1s ease-in-out infinite;
}
.countdown.is-overdue {
  color: #ffb1a8;
  border-color: rgba(229,107,93,0.35);
  background: rgba(229,107,93,0.12);
}
.countdown.is-overdue .countdown-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(229,107,93,0.2);
  animation: pulse 0.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

.btn-ok {
  color: #b6efd1;
  border-color: rgba(79,191,138,0.35);
}

.field-label {
  color: var(--muted); font-size: 0.82rem; font-weight: 650;
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.field > span {
  display: inline-flex; align-items: center; gap: 6px;
}

.currency-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.currency-option {
  cursor: pointer;
  position: relative;
}
.currency-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.currency-face {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: #0d1210;
  transition: 0.18s ease;
  min-height: 96px;
}
.currency-face .icon {
  width: 1.4rem;
  height: 1.4rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.currency-face strong {
  font-size: 1rem;
  letter-spacing: -0.02em;
}
.currency-face small {
  color: var(--muted);
  font-size: 0.78rem;
}
.currency-option:hover .currency-face {
  border-color: rgba(232,160,69,0.35);
}
.currency-option.is-active .currency-face,
.currency-option:has(input:checked) .currency-face {
  border-color: rgba(232,160,69,0.55);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(232,160,69,0.2), 0 10px 24px rgba(0,0,0,0.2);
}
.currency-option.is-active .currency-face .icon,
.currency-option:has(input:checked) .currency-face .icon {
  color: var(--accent-2);
}

.main { padding: 28px 32px 48px; max-width: 1280px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.topbar h1 {
  margin: 0; font-size: clamp(1.6rem, 2vw, 2rem);
  letter-spacing: -0.04em; font-weight: 800;
}
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  appearance: none; border: 1px solid var(--line-strong);
  background: var(--bg-soft); color: var(--text);
  border-radius: 12px; padding: 10px 14px;
  font: inherit; font-weight: 650; cursor: pointer;
  transition: 0.15s ease; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: rgba(232,160,69,0.45); transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #d4882f);
  color: #1a1208; border-color: transparent;
  box-shadow: 0 10px 24px rgba(232, 160, 69, 0.22);
}
.btn-primary:hover { filter: brightness(1.05); color: #1a1208; }
.btn-ghost { background: transparent; }
.btn-danger { color: #ffd4cf; border-color: rgba(229,107,93,0.35); }
.btn-sm { padding: 7px 10px; font-size: 0.82rem; border-radius: 10px; }
.btn-block { width: 100%; justify-content: center; }

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.stat {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; inset: auto -20% -40% 40%;
  height: 90px; background: radial-gradient(circle, rgba(255,255,255,0.08), transparent 70%);
}
.stat-label { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.stat-value {
  font-size: 2rem; font-weight: 800; letter-spacing: -0.05em;
  margin: 8px 0 4px; line-height: 1;
}
.stat-meta { color: var(--muted); font-size: 0.78rem; }
.stat.warn .stat-value { color: var(--warn); }
.stat.danger .stat-value { color: var(--danger); }
.stat.accent .stat-value { color: var(--accent-2); }

.grid-2 {
  display: grid; grid-template-columns: 1.3fr 0.9fr; gap: 16px;
}
.panel {
  background: rgba(23, 29, 26, 0.88);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  padding: 18px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: -0.02em; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left; padding: 12px 10px;
  border-bottom: 1px solid var(--line); vertical-align: top;
}
th {
  color: var(--muted); font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 700;
}
.cell-title { font-weight: 700; }
.cell-sub { color: var(--muted); font-size: 0.82rem; margin-top: 3px; }
.right { text-align: right; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.actions form { display: inline; }
.link { font-weight: 650; }

.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 750;
  border: 1px solid transparent;
}
.status-ok { background: rgba(79,191,138,0.12); color: #8be0b4; border-color: rgba(79,191,138,0.25); }
.status-soon { background: rgba(232,160,69,0.12); color: #f0c27a; border-color: rgba(232,160,69,0.28); }
.status-today { background: rgba(109,179,242,0.12); color: #9dceff; border-color: rgba(109,179,242,0.28); }
.status-overdue { background: rgba(229,107,93,0.14); color: #ffb1a8; border-color: rgba(229,107,93,0.3); }
.status-inactive { background: rgba(154,165,156,0.1); color: #b7c0b9; border-color: rgba(154,165,156,0.2); }

.flash {
  margin-bottom: 16px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); font-weight: 600;
}
.flash-success { background: rgba(79,191,138,0.12); color: #b6efd1; }
.flash-error { background: rgba(229,107,93,0.14); color: #ffc4bd; }

.empty {
  padding: 28px 12px; text-align: center; color: var(--muted);
}

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 12px; align-items: start; }
.dot {
  width: 10px; height: 10px; border-radius: 50%; margin-top: 6px;
  background: var(--muted);
}
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(79,191,138,0.15); }
.dot.fail { background: var(--danger); box-shadow: 0 0 0 4px rgba(229,107,93,0.15); }

.form-panel { max-width: 860px; }
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.field { display: grid; gap: 8px; }
.field span { color: var(--muted); font-size: 0.82rem; font-weight: 650; }
.field-span { grid-column: 1 / -1; }
input, select, textarea {
  width: 100%; border-radius: 12px; border: 1px solid var(--line-strong);
  background: #0d1210; color: var(--text);
  padding: 12px 14px; font: inherit;
  outline: none; transition: 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(232,160,69,0.55);
  box-shadow: 0 0 0 3px rgba(232,160,69,0.15);
}
.check {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); font-weight: 600;
}
.check input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 0.9rem; margin-top: 18px; }
.muted { color: var(--muted); }

.info-strip {
  display: flex; gap: 18px; flex-wrap: wrap;
  margin-bottom: 14px; padding: 12px 14px;
  border-radius: 12px; border: 1px dashed var(--line-strong);
  color: var(--muted); background: rgba(255,255,255,0.02);
}

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 650; }
.steps { margin: 0; padding-left: 18px; color: var(--muted); display: grid; gap: 10px; }
.steps li { padding-left: 4px; }

.totals-panel { margin-bottom: 16px; }
.fx-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.fx-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.fx-title {
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  color: var(--accent-2);
}
.fx-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.fx-row .fx-code {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  min-width: 3.2rem;
  flex-shrink: 0;
}
.fx-row strong {
  font-size: 1.2rem;
  letter-spacing: -0.03em;
  text-align: right;
  white-space: nowrap;
}
.fx-meta { margin-top: 10px; color: var(--muted); font-size: 0.8rem; }
tfoot td { border-bottom: 0; padding-top: 14px; }

/* Auth */
.auth-body {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  position: relative; overflow: hidden;
}
.auth-bg {
  position: absolute; inset: -20%;
  background:
    radial-gradient(circle at 20% 20%, rgba(232,160,69,0.18), transparent 35%),
    radial-gradient(circle at 80% 30%, rgba(47,107,82,0.22), transparent 40%),
    radial-gradient(circle at 50% 90%, rgba(229,107,93,0.08), transparent 35%);
  filter: blur(10px); animation: drift 16s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(2%, 2%, 0) scale(1.05); }
}
.auth-card {
  position: relative; width: min(420px, 100%);
  background: rgba(18, 22, 20, 0.88);
  border: 1px solid var(--line-strong);
  border-radius: 24px; padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.brand-auth { margin-bottom: 22px; }
.auth-card h1 {
  margin: 0 0 8px; font-size: 1.7rem; letter-spacing: -0.04em;
}
.stack { display: grid; gap: 14px; margin-top: 18px; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .fx-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .currency-picker { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; height: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .main { padding: 20px 16px 40px; }
  .kv { grid-template-columns: 1fr; gap: 4px; }
}
