@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@300;400;500;600&display=swap');

:root {
  /* ── Warm off-white palette ── */
  --bg:       #f5f2ed;
  --bg-1:     #faf8f5;
  --bg-2:     #eeebe4;
  --bg-3:     #e5e0d7;
  --bg-4:     #d8d2c8;

  --border:       rgba(60,50,35,0.10);
  --border-hover: rgba(60,50,35,0.20);
  --border-strong:rgba(60,50,35,0.32);

  /* Accent — deep forest green, warm & premium */
  --accent:     #2d5a3d;
  --accent-mid: #3a7050;
  --accent-dim: rgba(45,90,61,0.10);
  --accent-dim2:rgba(45,90,61,0.05);

  /* Partner colors — keep readable on light bg */
  --raghav:     #2d5a3d;
  --raghav-dim: rgba(45,90,61,0.09);
  --jatin:      #1e4d82;
  --jatin-dim:  rgba(30,77,130,0.09);

  --blue:     #1e4d82;
  --blue-dim: rgba(30,77,130,0.09);
  --red:      #b83232;
  --red-dim:  rgba(184,50,50,0.09);

  /* Typography */
  --text:   #1c1814;
  --text-2: #6b6256;
  --text-3: #a09485;

  /* Type families */
  --display: 'Plus Jakarta Sans', sans-serif;
  --serif:   'Cormorant Garamond', Georgia, serif;
  --mono:    'IBM Plex Mono', 'Courier New', monospace;

  /* Shape */
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 18px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--display);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── LAYOUT ── */
.app-shell {
  display: grid;
  grid-template-columns: 224px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  grid-row: 1 / -1;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 26px 22px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .wordmark {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.01em;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-logo .wordmark span { color: var(--accent); }

.sidebar-logo .sub {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-3);
  margin-top: 6px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 14px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-section-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 12px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.13s ease;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
}

.nav-item .nav-icon {
  width: 15px;
  height: 15px;
  opacity: 0.5;
  flex-shrink: 0;
}

.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item:hover .nav-icon { opacity: 0.75; }

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 55%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar-footer {
  padding: 14px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid var(--border);
  background: var(--bg-2);
  width: 100%;
  transition: all 0.13s;
  font-family: var(--display);
}

.sidebar-footer-btn:hover { border-color: var(--border-hover); color: var(--text); background: var(--bg-3); }
.sidebar-footer-btn svg { width: 13px; height: 13px; opacity: 0.55; }

/* ── TOPBAR ── */
.topbar {
  grid-column: 2;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  padding: 0 30px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left { display: flex; align-items: center; gap: 14px; }

.page-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  font-style: italic;
  color: var(--text);
  letter-spacing: 0.01em;
}

.week-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 11px;
}

.week-selector label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.week-selector select {
  background: none;
  border: none;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--display);
  cursor: pointer;
  outline: none;
}

.week-selector select option { background: var(--bg-1); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ── MAIN ── */
.main {
  grid-column: 2;
  padding: 26px 30px;
  overflow-x: hidden;
  background: var(--bg);
}

.panel { display: none; animation: fadeIn 0.18s ease; }
.panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── METRIC CARDS ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metric-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: border-color 0.15s;
}

.metric-card:hover { border-color: var(--border-hover); }

.metric-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 9px;
}

.metric-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}

.metric-value.positive { color: var(--accent); }
.metric-value.negative { color: var(--red); }
.metric-value.blue     { color: var(--blue); }

.metric-sub {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-3);
  margin-top: 5px;
}

/* ── CARDS ── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 14px;
}

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

.card-title {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ── PARTNER SPLIT ── */
.partner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.partner-card {
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid var(--border);
}

.partner-card.raghav { background: var(--raghav-dim); border-color: rgba(45,90,61,0.18); }
.partner-card.jatin  { background: var(--jatin-dim);  border-color: rgba(30,77,130,0.18); }

.partner-name {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.02em;
  margin-bottom: 7px;
}

.partner-card.raghav .partner-name { color: var(--raghav); }
.partner-card.jatin  .partner-name { color: var(--jatin); }

.partner-cashflow {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}

.partner-card.raghav .partner-cashflow { color: var(--raghav); }
.partner-card.jatin  .partner-cashflow { color: var(--jatin); }

.partner-detail {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.85;
}

.partner-detail span { color: var(--text-2); }

/* ── SETTLEMENT BOX ── */
.settlement-box {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  text-align: center;
  margin-bottom: 14px;
}

.settlement-box.has-payment { border-color: rgba(30,77,130,0.25); background: rgba(30,77,130,0.03); }
.settlement-box.balanced    { border-color: rgba(45,90,61,0.22);  background: rgba(45,90,61,0.03); }

.settlement-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}

.settlement-amount {
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 10px;
  color: var(--blue);
}

.settlement-amount.balanced {
  font-family: var(--serif);
  font-size: 26px;
  font-style: italic;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.01em;
}

.settlement-sublabel { font-size: 12px; color: var(--text-3); }

.settlement-arrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  font-size: 13px;
  font-weight: 600;
}

.arrow-from { color: var(--text-2); }
.arrow-to   { color: var(--text); }
.arrow-line {
  width: 36px; height: 1px;
  background: var(--border-strong);
  position: relative;
}
.arrow-line::after {
  content: '→';
  position: absolute;
  right: -8px; top: -9px;
  font-size: 13px;
  color: var(--text-3);
}

/* ── BREAKDOWN ── */
.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.breakdown-item:last-child { border-bottom: none; }
.breakdown-key { color: var(--text-2); font-family: var(--mono); font-size: 10px; }
.breakdown-val { font-family: var(--mono); font-weight: 500; }
.breakdown-val.neg  { color: var(--red); }
.breakdown-val.pos  { color: var(--accent); }
.breakdown-val.blue { color: var(--blue); }

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

table { width: 100%; border-collapse: collapse; font-size: 12px; }

thead th {
  text-align: left;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-weight: 400;
}

tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
  transition: background 0.1s;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-2); }
tbody td:first-child { color: var(--text); font-weight: 500; }

.amount-cell {
  text-align: right;
  font-family: var(--mono);
  font-weight: 500;
  white-space: nowrap;
}

.amount-cell.neg  { color: var(--red); }
.amount-cell.pos  { color: var(--accent); }
.amount-cell.blue { color: var(--blue); }

th.right, td.right { text-align: right; }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-raghav {
  background: var(--raghav-dim);
  color: var(--raghav);
  border: 1px solid rgba(45,90,61,0.22);
}

.badge-jatin {
  background: var(--jatin-dim);
  color: var(--jatin);
  border: 1px solid rgba(30,77,130,0.22);
}

.badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-2);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  border: 1px solid var(--border);
}

/* ── FORMS ── */
.form-grid { display: grid; gap: 9px; margin-bottom: 12px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

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

.field label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-3);
}

.field input,
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 11px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--display);
  transition: border-color 0.13s, background 0.13s;
  outline: none;
  width: 100%;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  background: var(--bg-1);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.field input::placeholder { color: var(--text-3); }
.field select option { background: var(--bg-1); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-hover);
  background: var(--bg-2);
  color: var(--text-2);
  transition: all 0.13s;
  white-space: nowrap;
}

.btn:hover { background: var(--bg-3); color: var(--text); border-color: var(--border-strong); }
.btn:active { transform: scale(0.975); }
.btn svg { width: 13px; height: 13px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent-mid);
  border-color: var(--accent-mid);
  color: #fff;
}

.btn-sm { padding: 4px 10px; font-size: 11px; border-radius: 6px; }

.btn-danger {
  color: var(--red);
  border-color: rgba(184,50,50,0.22);
  background: var(--red-dim);
}
.btn-danger:hover { background: rgba(184,50,50,0.15); border-color: rgba(184,50,50,0.35); color: var(--red); }

/* ── INVOICE LINE ITEMS ── */
.inv-line {
  display: grid;
  grid-template-columns: 3fr 0.7fr 1.2fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

/* ── INVOICE PREVIEW (white paper) ── */
.invoice-preview {
  background: #fff;
  color: #1a1a1a;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 52px 56px;
  margin-bottom: 14px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12px;
  line-height: 1.65;
  box-shadow: 0 2px 12px rgba(60,45,25,0.07);
}

/* ── SAVED INVOICE LIST ── */
.inv-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.inv-list-item:last-child { border-bottom: none; }

/* ── EXPLAIN BOX ── */
.explain-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  line-height: 2;
  margin-bottom: 14px;
}
.explain-box strong { color: var(--text-2); font-weight: 500; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}

/* ── SETTLEMENT TABLE ── */
.sett-table thead th { color: var(--text-3); }
.sett-table tbody td { color: var(--text-2); }
.sett-table tbody td:first-child { color: var(--text); }

.owes-cell { font-family: var(--mono); font-size: 11px; }
.owes-pays { color: var(--red); font-weight: 500; }
.owes-gets { color: var(--accent); font-weight: 500; }
.owes-even { color: var(--text-3); }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 22px; right: 22px;
  background: var(--text);
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 12px;
  color: var(--bg-1);
  font-weight: 500;
  animation: slideUp 0.22s ease forwards;
  z-index: 1000;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ── NETWORKS ── */
.network-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 10px;
  transition: border-color 0.13s;
}
.network-card:hover { border-color: var(--border-hover); }

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

.network-name {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  font-style: italic;
  color: var(--text);
  margin-bottom: 3px;
  letter-spacing: 0.01em;
}

.network-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
}

.network-details {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.net-detail-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 3px;
}

.net-detail-val { font-size: 12px; color: var(--text-2); line-height: 1.5; }

/* ── BANK ACCOUNT CARDS (Settings) ── */
.bank-account-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 10px;
  transition: border-color 0.13s;
}
.bank-account-card:hover { border-color: var(--border-hover); }

.bank-account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.bank-account-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ── SETTLED STAMP ── */
.settled-stamp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
  padding: 10px 18px;
  background: var(--raghav-dim);
  border: 1px solid rgba(45,90,61,0.22);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
}

/* ── BANK INDICATOR ── */
.bank-indicator {
  display: none;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  margin-top: 6px;
}

/* ── SETTINGS ── */
.settings-section { margin-bottom: 20px; }

.settings-entity-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.settings-entity-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  font-style: italic;
  color: var(--text);
}

.settings-field-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 9px;
}

.settings-field-group.full { grid-template-columns: 1fr; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar, .main { grid-column: 1; }
  .cols-4 { grid-template-columns: 1fr 1fr; }
  .cols-3 { grid-template-columns: 1fr 1fr; }
  .partner-grid { grid-template-columns: 1fr; }
  .main { padding: 18px 16px; }
}

@media (max-width: 520px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .inv-line { grid-template-columns: 1fr auto; }
  .invoice-preview { padding: 28px 22px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .network-details { grid-template-columns: 1fr; }
  .settings-field-group { grid-template-columns: 1fr; }
  .network-card-header { flex-direction: column; }
}
