/* ═══════════════════════════════════════════════════════
   THOTH FINANCE — style.css
   ═══════════════════════════════════════════════════════ */

:root {
  --bg:        #0a0a0f;
  --bg2:       #111118;
  --bg3:       #18181f;
  --border:    #2a2a35;
  --border2:   #3a3a4a;
  --text:      #e8e8f0;
  --text2:     #9090a8;
  --text3:     #5a5a70;
  --accent:    #00ff88;
  --accent2:   #00cc6a;
  --red:       #ff4466;
  --yellow:    #ffb300;
  --blue:      #4488ff;
  --purple:    #aa66ff;
  --mono:      'JetBrains Mono', monospace;
  --radius:    8px;
  --radius2:   12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ── Scrollbars ─────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ═══════════════════════════════════════════════════════
   AUTH GATE
   ═══════════════════════════════════════════════════════ */
.auth-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 40px;
  width: 360px;
  box-shadow: 0 0 60px rgba(0,255,136,0.05);
}

.auth-logo {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 32px;
}

.auth-sym {
  font-size: 2.4rem;
  color: var(--accent);
  line-height: 1;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
}

.auth-sub {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.auth-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--text2);
  margin-bottom: 6px;
}

.auth-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  outline: none;
  transition: border-color .2s;
}

.auth-input:focus { border-color: var(--accent); }

.auth-btn {
  width: 100%;
  margin-top: 16px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 11px;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: background .2s;
}

.auth-btn:hover { background: var(--accent2); }

.auth-err {
  color: var(--red);
  font-size: 0.75rem;
  margin-top: 10px;
  text-align: center;
  min-height: 18px;
}

/* ═══════════════════════════════════════════════════════
   APP SHELL
   ═══════════════════════════════════════════════════════ */
.app { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  display: flex; align-items: center; gap: 0;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  position: sticky; top: 0; z-index: 50;
  flex-shrink: 0;
}

.app-logo-wrap {
  display: flex; align-items: baseline; gap: 6px;
  margin-right: 32px;
}

.app-logo {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.app-logo-sub {
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: var(--text3);
}

.app-nav {
  display: flex; gap: 2px;
  flex: 1;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  padding: 6px 14px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: color .15s, background .15s;
}

.nav-btn:hover { color: var(--text); background: var(--bg3); }
.nav-btn.active { color: var(--accent); background: rgba(0,255,136,.08); }

.header-right {
  display: flex; align-items: center; gap: 12px;
}

.header-date {
  font-size: 0.68rem;
  color: var(--text3);
  letter-spacing: 0.06em;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 0.85rem;
  padding: 4px 8px;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}

.icon-btn:hover { color: var(--red); border-color: var(--red); }

.app-main {
  flex: 1;
  padding: 24px;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
}

/* ═══════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════ */
.tab-panel { animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(6px) } to { opacity:1; transform:none } }

/* ═══════════════════════════════════════════════════════
   STAT CARDS ROW
   ═══════════════════════════════════════════════════════ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 18px 20px;
}

.stat-label {
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  color: var(--text3);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 4px;
}

.stat-sub {
  font-size: 0.68rem;
  color: var(--text3);
}

.stat-value.positive { color: var(--accent); }
.stat-value.negative { color: var(--red); }
.stat-value.warn     { color: var(--yellow); }

.month-inout {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 4px;
}

.month-in  { color: var(--accent); }
.month-out { color: var(--red); }
.month-sep { color: var(--text3); font-size: 0.7rem; }

.account-pills {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 4px;
}

.account-pill {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.72rem;
  gap: 8px;
}

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

.pill-name { flex: 1; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-bal  { color: var(--text); font-weight: 600; }

/* ═══════════════════════════════════════════════════════
   CHART CARDS
   ═══════════════════════════════════════════════════════ */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 18px 20px;
}

.chart-card.wide { grid-column: 1; }

.chart-hdr {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 14px;
}

.chart-title {
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  color: var(--text3);
}

.chart-sub {
  font-size: 0.65rem;
  color: var(--text3);
}

/* Donut */
.donut-wrap {
  display: flex; align-items: center; gap: 16px;
}

.donut-legend {
  flex: 1;
  display: flex; flex-direction: column; gap: 5px;
  overflow: hidden;
}

.leg-row {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.68rem;
  color: var(--text2);
}

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

.leg-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg-amt  { color: var(--text); font-weight: 600; }

/* Bill strip */
.bill-strip {
  display: flex; flex-wrap: wrap; gap: 8px;
  min-height: 48px;
  align-items: flex-start;
}

.bill-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg3);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.72rem;
  border-left: 3px solid;
  cursor: default;
}

.bill-chip.overdue { opacity: .6; filter: grayscale(.3); }

.bill-chip-day {
  font-weight: 700;
  color: var(--text);
  min-width: 20px;
}

.bill-chip-name { color: var(--text2); }

.bill-chip-amt {
  color: var(--text);
  font-weight: 600;
  margin-left: 4px;
}

/* ═══════════════════════════════════════════════════════
   PANEL HEADER
   ═══════════════════════════════════════════════════════ */
.panel-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-hdr-left  { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.panel-hdr-right { display: flex; align-items: center; gap: 8px; }

.panel-title {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--text2);
  font-weight: 600;
}

.tx-filters { display: flex; gap: 8px; }

/* ═══════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════ */
.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 7px 14px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text2);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-family: var(--mono);
  font-size: 0.72rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}

.btn-secondary:hover { border-color: var(--text2); color: var(--text); }

.btn-ghost {
  background: none;
  border: none;
  color: var(--text3);
  font-family: var(--mono);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: color .15s;
}

.btn-ghost:hover { color: var(--red); }

.btn-danger {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 0.68rem;
  cursor: pointer;
  transition: background .15s;
}

.btn-danger:hover { background: rgba(255,68,102,.12); }

/* ═══════════════════════════════════════════════════════
   QUICK ADD
   ═══════════════════════════════════════════════════════ */
.quick-add {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.qa-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.qa-ctrl {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  outline: none;
  transition: border-color .15s;
  min-width: 0;
}

.qa-ctrl:focus { border-color: var(--accent); }
.qa-ctrl option { background: var(--bg3); }
.qa-desc { flex: 1; min-width: 160px; }
.qa-cat  { min-width: 140px; }
.qa-amt  { width: 100px; }
.qa-acc  { min-width: 120px; }
.qa-type { width: 100px; }

/* ═══════════════════════════════════════════════════════
   CSV IMPORT
   ═══════════════════════════════════════════════════════ */
.csv-area {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 16px;
  margin-bottom: 14px;
}

.csv-hint {
  font-size: 0.7rem;
  color: var(--text3);
  margin-bottom: 10px;
  line-height: 1.6;
}

.csv-hint code {
  background: var(--bg3);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}

.csv-ta {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.72rem;
  min-height: 100px;
  resize: vertical;
  outline: none;
}

.csv-ta:focus { border-color: var(--accent); }

.csv-btns {
  display: flex; gap: 8px; margin-top: 10px; align-items: center;
}

.csv-preview-table {
  width: 100%; margin-top: 12px;
  border-collapse: collapse; font-size: 0.72rem;
}

.csv-preview-table th {
  text-align: left; color: var(--text3); font-weight: 400;
  border-bottom: 1px solid var(--border); padding: 4px 8px;
  letter-spacing: 0.08em;
}

.csv-preview-table td {
  padding: 4px 8px; border-bottom: 1px solid var(--border);
  color: var(--text2);
}

.csv-preview-table .neg { color: var(--red); }
.csv-preview-table .pos { color: var(--accent); }

/* ═══════════════════════════════════════════════════════
   DATA TABLE
   ═══════════════════════════════════════════════════════ */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.data-table th {
  text-align: left;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--text3);
  font-weight: 400;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  white-space: nowrap;
}

.data-table th.right { text-align: right; }

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: var(--bg3); }

.data-table .right  { text-align: right; }
.data-table .income { color: var(--accent); font-weight: 600; }
.data-table .expense{ color: var(--red); }

.tx-desc  { color: var(--text); }
.cat-badge {
  display: inline-block;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--text2);
}

.empty-state {
  text-align: center;
  color: var(--text3);
  padding: 40px !important;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

/* ═══════════════════════════════════════════════════════
   BILLS GRID
   ═══════════════════════════════════════════════════════ */
.bills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.bill-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 16px;
  border-left: 3px solid;
  position: relative;
}

.bill-card-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 10px;
}

.bill-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.bill-cat-badge {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--text3);
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 3px;
}

.bill-amount {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.bill-meta {
  font-size: 0.68rem;
  color: var(--text3);
  margin-bottom: 12px;
}

.bill-actions { display: flex; gap: 6px; }

/* ═══════════════════════════════════════════════════════
   ACCOUNTS GRID
   ═══════════════════════════════════════════════════════ */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.acc-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 20px;
  border-top: 3px solid;
}

.acc-card-hdr {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 14px;
}

.acc-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.acc-type {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--text3);
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 3px;
}

.acc-balance {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.acc-balance.positive { color: var(--accent); }
.acc-balance.negative { color: var(--red); }

.acc-actions { display: flex; gap: 6px; }

/* ═══════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 28px 30px;
  width: 420px;
  max-width: 95vw;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(0,0,0,.6);
}

.modal-x {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none;
  color: var(--text3); font-size: 0.9rem;
  cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius);
  transition: color .15s;
}

.modal-x:hover { color: var(--red); }

.modal-title {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  color: var(--text2);
  font-weight: 600;
  margin-bottom: 20px;
}

.form-row {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 5px;
}

.form-input, .form-select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  outline: none;
  transition: border-color .15s;
}

.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-select option { background: var(--bg3); }

.form-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════
   FILTER CONTROLS
   ═══════════════════════════════════════════════════════ */
.filter-ctrl {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.72rem;
  outline: none;
  transition: border-color .15s;
}

.filter-ctrl:focus { border-color: var(--accent); }
.filter-ctrl option { background: var(--bg3); }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .stats-row  { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .app-main { padding: 12px; }
  .stats-row { grid-template-columns: 1fr; }
  .app-header { padding: 0 12px; }
  .app-logo-wrap { margin-right: 16px; }
}
