:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #263449;
  --bg-input: #0b1324;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --income: #22c55e;
  --expense: #fb7185;
  --warn-bg: rgba(234, 179, 8, 0.14);
  --warn-border: rgba(234, 179, 8, 0.45);
  --danger: #ef4444;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: radial-gradient(circle at top right, #1e1b4b 0%, var(--bg) 42%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 1260px;
  margin: 0 auto;
  padding: 20px 18px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

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

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
  color: white;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.month-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13.5px;
}

.month-picker-wrap input {
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 600;
  padding: 2px;
  width: auto;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 10px 15px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

.banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 13.5px;
  flex-wrap: wrap;
}

.banner-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.card {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.card h3, .card h4 {
  margin-top: 0;
  margin-bottom: 8px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 13px;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

.text-income {
  color: var(--income);
}

.text-expense {
  color: var(--expense);
}

.accounts-mini-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  margin-top: 2px;
}

.acc-mini-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
}

@media (max-width: 920px) {
  .charts-grid, .two-col-grid {
    grid-template-columns: 1fr !important;
  }
}

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.donut-layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 18px;
  align-items: center;
}

@media (max-width: 600px) {
  .donut-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

.donut-chart-box {
  width: 200px;
  height: 200px;
  display: grid;
  place-items: center;
}

.category-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-height: 270px;
  overflow-y: auto;
  padding-right: 4px;
}

.cat-stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.cat-stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
}

.bar-chart-box {
  width: 100%;
  min-height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.tx-table th, .tx-table td {
  padding: 11px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.tx-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tx-table tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

.tx-table tr.dup-row td {
  background: var(--warn-bg);
}

.right {
  text-align: right !important;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
}

.source-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

/* Forms & Buttons */
input, select, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13.5px;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.filters-bar {
  display: grid;
  grid-template-columns: 2fr repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

@media (max-width: 860px) {
  .filters-bar {
    grid-template-columns: 1fr 1fr;
  }
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-row > * {
  flex: 1;
  min-width: 160px;
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 9px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
}

.full-width {
  width: 100%;
}

/* Dropzone */
.dropzone {
  display: block;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 18px;
  text-align: center;
  cursor: pointer;
  margin: 12px 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.dropzone-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shot-previews {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.shot-thumb {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}

/* Settings & Logs */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.status-box {
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 13.5px;
}

.sync-logs-list, .settings-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scrollable-list {
  max-height: 330px;
  overflow-y: auto;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 9px;
  font-size: 13px;
}

.code-preview {
  background: #090e1a;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px;
  font-size: 12.5px;
  overflow-x: auto;
  margin-top: 12px;
  white-space: pre-wrap;
}

/* Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 22, 0.78);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: #1e293b;
  border-left: 4px solid var(--primary);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 9px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  font-size: 13.5px;
}

.error-text {
  color: #fda4af;
  font-size: 13px;
  margin-top: 8px;
}
