:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --line: #d9dee7;
  --ink: #172033;
  --muted: #667085;
  --green: #157347;
  --red: #b42318;
  --blue: #1d4ed8;
  --control: #ffffff;
  --control-ink: #172033;
}

body[data-theme="dark"] {
  --bg: #0f172a;
  --panel: #111827;
  --line: #334155;
  --ink: #f8fafc;
  --muted: #cbd5e1;
  --green: #86efac;
  --red: #fca5a5;
  --blue: #93c5fd;
  --control: #1f2937;
  --control-ink: #f8fafc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-page {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 18px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.auth-brand {
  color: var(--ink);
}

.auth-form {
  display: grid;
  gap: 10px;
  margin: 18px 0 12px;
}

.auth-form button {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

a,
.text-link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.auth-error {
  color: var(--red);
}

.auth-success {
  color: var(--green);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #111827;
  color: #eef2ff;
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

/*.brand-mark {*/
/*  display: grid;*/
/*  place-items: center;*/
/*  width: 36px;*/
/*  height: 36px;*/
/*  border-radius: 8px;*/
/*  background: #2563eb;*/
/*  font-weight: 800;*/
/*}*/

.brand-mark {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    overflow: visible;
    flex-shrink: 0;
}

.brand-mark img{
    width:100%;
    height:100%;
    object-fit:contain;
    display:block;

    animation: innerGlowPulse 2.5s ease-in-out infinite;
}

@keyframes innerGlowPulse{

    0%{
        opacity:0.92;
        transform:scale(1);
    }

    50%{
        opacity:1;
        transform:scale(1.03);
    }

    100%{
        opacity:0.92;
        transform:scale(1);
    }
}

.worth {
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 18px;
}

.worth div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
}

.worth span,
.topbar p,
.groups small {
  color: var(--muted);
}

.worth span { color: #aab3c5; }
.danger { color: #fca5a5; }

.group {
  margin-bottom: 14px;
}

.group summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 6px;
}

.account-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

h1, h2, p { margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 15px; }

.auth-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

input, button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--control);
  color: var(--control-ink);
}

[hidden] {
  display: none !important;
}

button {
  cursor: pointer;
  font-weight: 650;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 17px;
  padding: 0;
}

.icon-button:hover,
.icon-button:focus {
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  outline: none;
}

.danger-action {
  color: var(--red);
}

.welcome-user {
  color: var(--muted);
  font-weight: 700;
  padding: 0 4px;
}

.overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.overview > div,
.setup-shell,
.grid-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.overview > div {
  min-height: 132px;
  padding: 14px;
}

ul {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}

li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #eef1f5;
}

.setup-shell {
  margin-bottom: 18px;
}

.setup-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.setup-head p {
  color: var(--muted);
  margin-top: 2px;
}

#setup-status {
  color: var(--blue);
  font-weight: 700;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
  padding: 14px;
}

.form-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.form-panel > summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.form-panel > summary::-webkit-details-marker {
  display: none;
}

.form-panel > summary::before {
  content: "+";
  margin-right: 8px;
  color: var(--blue);
}

.form-panel[open] > summary::before {
  content: "-";
}

.quick-form {
  display: grid;
  gap: 8px;
  align-content: start;
}

.quick-form h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--control);
  color: var(--control-ink);
}

.quick-form button {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.grid-toolbar,
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background-color: #555e6c;
  color: white;
}
/*#111827 !important;*/

.filter-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.filter-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.collapsible-grid > summary {
  cursor: pointer;
  list-style: none;
}

.collapsible-grid > summary::-webkit-details-marker {
  display: none;
}

.collapsible-grid > summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--blue);
}

.collapsible-grid[open] > summary::before {
  content: "-";
}

.collapsible-grid:not([open]) #process-recurring {
  display: none;
}

.toolbar-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 86%, var(--bg));
}

.row-actions button,
.toolbar-actions button {
  height: 30px;
}

.row-actions button:last-child {
  color: var(--red);
}

.amount-input {
  text-align: right;
}

.grid-shell + .grid-shell {
  margin-top: 18px;
}

.table-wrap {
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.amount {
  text-align: right;
}

td[contenteditable="true"] {
  outline: 2px solid transparent;
}

td[contenteditable="true"]:focus {
  outline-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 14%, transparent);
}

.income { color: var(--green); font-weight: 700; }
.expense { color: var(--ink); }
.liability { color: var(--red); font-weight: 700; }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .overview { grid-template-columns: 1fr; }
  .setup-grid { grid-template-columns: 1fr; }
  .filter-panel { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .auth-tools {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .auth-tools input { flex: 1; min-width: 0; }
  .grid-toolbar {
    align-items: flex-start;
    gap: 10px;
  }
  .grid-toolbar h2 {
    min-width: 120px;
    padding-top: 5px;
  }
  .toolbar-actions {
    flex: 1;
    min-width: 0;
    justify-content: flex-start;
    gap: 4px;
  }
  .toolbar-actions .icon-button {
    width: 30px;
    min-width: 30px;
  }
}

@media (max-width: 520px) {
  .workspace { padding: 12px; }
  .topbar { gap: 12px; }
  .auth-tools {
    display: grid;
    grid-template-columns: repeat(5, 32px) minmax(88px, 1fr);
    align-items: center;
  }
  .welcome-user {
    grid-column: 1 / -1;
    padding: 2px 0;
  }
  #logout-button {
    grid-column: span 2;
  }
  .grid-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .grid-toolbar h2 {
    min-width: 0;
  }
  .toolbar-actions {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }
  .toolbar-actions .icon-button {
    flex: 0 0 30px;
  }
}

/* ============================= */
/* NEW: TABLE ENHANCEMENTS */
/* ============================= */

/* Header colors */
.table-transactions thead {
  background-color: #1f2937 !important;
  color: #ffffff;
}

.table-recurring thead {
  background-color: #374151 !important;
  color: #ffffff;
}

.table-assets thead {
  background-color: #4b5563 !important;
  color: #ffffff;
}

/* Odd/Even rows */
table tbody tr:nth-child(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}

body.dark table tbody tr:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.04);
}

table tbody tr:nth-child(even) {
  background-color: transparent;
}

/* Recurring type colors */
.recurring-income {
  color: #16a34a !important;
  font-weight: 600;
}

.recurring-expense {
  color: #f87171 !important;
  font-weight: 600;
}

/* Toolbar icons (match your existing style) */
.toolbar-icon {
  cursor: pointer;
  padding: 4px 6px;
  margin-right: 6px;
  font-size: 15px;
  opacity: 0.85;
}

.toolbar-icon:hover {
  opacity: 1;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 10px;
  color: #888;
  font-style: italic;
}

#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
}

.toast {
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  margin-bottom: 10px;
  border-radius: 6px;
  font-size: 14px;
  opacity: 0.95;
}

.toast.error {
  background: #b91c1c;
}

.toast.success {
  background: #065f46;
}

/* ============================= */
/* Account balance inline edit */
/* ============================= */

.account-balance-edit {
  border: none;
  background: transparent;
  outline: none;
  text-align: center;
  font-weight: 600;
  width: 100px;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

/* Remove number arrows */
.account-balance-edit::-webkit-outer-spin-button,
.account-balance-edit::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.account-balance-edit[type=number] {
  -moz-appearance: textfield;
}

/* Hover effect (subtle hint editable) */
.account-row:hover .account-balance-edit {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

/* Focus state */
.account-balance-edit:focus {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  cursor: text;
}

/* Dark mode */
body.dark .account-row:hover .account-balance-edit {
  background: rgba(255, 255, 255, 0.08);
}

body.dark .account-balance-edit:focus {
  background: rgba(255, 255, 255, 0.12);
}

/* Sidebar colors */
.account-row.cash strong {
  color: #16a34a; /* green */
}

.group.cash > summary {
  color: #86efac;
}

.account-row.tracking strong {
  color: #2563eb; /* blue */
}

.group.tracking > summary {
  color: #93c5fd;
}

.account-row.asset-tracking strong {
  color: #eab308; /* yellow */
}

.asset-tracking-title {
  color: #fde047;
}

.worth .total-assets strong {
  color: #16a34a;
}

.worth .tracked-assets strong {
  color: #eab308;
}
/* Overlay */
.tour {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
}

.tour.hidden {
  display: none;
}

/* Highlight box */
.tour-highlight {
  position: absolute;
  border: 2px solid #3b82f6;
  border-radius: 8px;
  pointer-events: none;
  transition: all 0.3s ease;
}

/* Tooltip box */
.tour-box {
  position: fixed;
  background: white;
  padding: 14px;
  border-radius: 8px;
  max-width: 280px;
  z-index: 10000;
}

body.dark .tour-box {
  background: #1f2937;
  color: white;
}

.tour-actions {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
}
.info-icon {
  cursor: help;
  margin-left: 6px;
  font-size: 12px;
}
.account-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.delete-account-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: #fca5a5;
  opacity: 0;
  padding: 0 4px;
  height: 24px;
}

.account-row:hover .delete-account-btn {
  opacity: 1;
}

.suggestion-box {
  position: absolute;
  z-index: 10001;
  display: grid;
  gap: 2px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,.22);
}

.suggestion-box button {
  height: 30px;
  border: 0;
  border-radius: 6px;
  text-align: left;
  background: transparent;
  color: var(--ink);
}

.suggestion-box button:hover,
.suggestion-box button:focus {
  background: color-mix(in srgb, var(--blue) 16%, transparent);
}

li span small{
    margin-left: 8px;
    color: #999;
    font-size: 11px;
    background: #f2f2f2;
    padding: 2px 6px;
    border-radius: 10px;
}