:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --border: #334155;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.right { text-align: right; }
.error { color: var(--bad); margin-top: 8px; min-height: 18px; }

/* Login */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a, #1e293b);
}
.login-card {
  background: var(--panel); padding: 32px; border-radius: 12px; width: 320px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5); display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.login-card input, .login-card button { padding: 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.login-card button { background: var(--accent-strong); color: white; border: none; cursor: pointer; font-weight: 600; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 12px 24px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 18px; }
.version { font-size: 11px; color: var(--muted); margin-left: 6px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  background: transparent; border: none; color: var(--muted); padding: 8px 14px;
  border-radius: 6px; cursor: pointer; font-size: 14px;
}
.tab.active, .tab:hover { background: var(--panel-2); color: var(--text); }
.user-area { display: flex; align-items: center; gap: 12px; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; }
.btn-secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.period-picker { display: flex; align-items: center; gap: 8px; }
.period-picker select { padding: 6px 10px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; }

main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Cards & grid */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; margin-bottom: 16px;
}
.card-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.card-value { font-size: 24px; font-weight: 700; }
.balance-card .card-value { color: var(--accent); }
.account-card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.account-card .row { display: flex; justify-content: space-between; padding: 2px 0; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.table th { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.table tfoot th { border-top: 2px solid var(--border); border-bottom: none; }
.table .right, .table th.right { text-align: right; }
.table.editable td input, .table.editable td select { width: 100%; background: transparent; color: var(--text); border: 1px solid transparent; padding: 4px 6px; border-radius: 4px; }
.table.editable td input:focus, .table.editable td select:focus { border-color: var(--accent); background: var(--panel-2); outline: none; }
.row-action { background: transparent; color: var(--bad); border: none; cursor: pointer; }
.row-save { background: var(--good); color: white; border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; margin-right: 4px; }

/* Forms */
.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.row-form input, .row-form select { padding: 8px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; }
.row-form button { background: var(--accent-strong); color: white; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select, .filters input, .filters button {
  padding: 6px 10px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
}
.filters button { background: var(--accent-strong); cursor: pointer; }

.hist-summary {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 12px; margin-bottom: 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
}
.hist-summary strong { font-size: 1.2rem; }

/* Chips */
.chip-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip-list li {
  background: var(--panel-2); padding: 6px 12px; border-radius: 16px; display: flex; align-items: center; gap: 6px;
}
.chip-list .x { background: none; border: none; color: var(--bad); cursor: pointer; }
.info-list { list-style: none; padding: 0; }
.info-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: var(--panel); padding: 24px; border-radius: 10px; width: 420px; max-width: 90vw; }
.modal-card label { display: block; margin-bottom: 8px; }
.modal-card input { width: 100%; padding: 8px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-actions button { padding: 8px 14px; border-radius: 6px; border: none; cursor: pointer; }
.modal-actions button[type=submit] { background: var(--accent-strong); color: white; }

.balances-form label { display: block; margin-bottom: 12px; }
.balances-form input { padding: 6px 10px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; margin-left: 8px; }
.balances-form button { background: var(--accent-strong); color: white; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; }

canvas { max-height: 300px; }

.period-status {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--warn);
  color: var(--warn);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 600;
}

#import-result pre {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
}

code {
  background: var(--panel-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}
