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

/* ─── Fontaine Bank design system ────────────────────────────────────────────
   Midnight ink, champagne gold, ivory. Hairlines, small caps, serif display.
   ---------------------------------------------------------------------------- */

:root {
  --bg-primary: #0a0d14;
  --bg-surface: #10151f;
  --bg-elevated: #151c2a;
  --bg-well: #0c1018;

  --gold: #c8a45c;
  --gold-bright: #e3c78a;
  --gold-deep: #8e713a;

  --text-primary: #f4efe4;
  --text-muted: #98a0b3;

  --green: #3e9b6e;
  --claret: #c05b5b;
  --orange: #ce9c4f;
  --info: #7a95bc;

  --border: rgba(200, 164, 92, 0.16);
  --border-soft: rgba(255, 255, 255, 0.06);

  /* Legacy aliases (RRB-era class hooks still reference these) */
  --crimson: var(--gold);
  --accent: var(--gold-bright);

  --font-display: 'Cormorant Garamond', 'Times New Roman', serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-panel: 0 18px 40px rgba(3, 5, 10, 0.45);
  --radius: 14px;
}

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

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(1200px 500px at 85% -10%, rgba(200, 164, 92, 0.07), transparent 60%),
    radial-gradient(900px 420px at -10% 110%, rgba(122, 149, 188, 0.05), transparent 55%);
  background-attachment: fixed;
}

::selection {
  background: rgba(200, 164, 92, 0.35);
  color: var(--text-primary);
}

a {
  color: var(--gold);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--gold-bright);
}

button, input, select, textarea {
  font-family: var(--font-body);
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--gold-deep);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */

.layout-wrapper {
  display: flex;
  flex: 1;
  min-height: 100vh;
}

.sidebar {
  width: 264px;
  background: linear-gradient(180deg, #0c101a 0%, #0a0d14 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
}

.main-content {
  flex: 1;
  margin-left: 264px;
  overflow-y: auto;
  padding: 48px;
  min-height: 100vh;
}

/* ─── Sidebar brand ──────────────────────────────────────────────────────── */

.brand {
  padding: 34px 25px 28px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.32em;
  margin-right: -0.32em; /* optically recenter tracked type */
}

.brand .subtitle {
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.42em;
  margin-right: -0.42em;
  margin-top: 8px;
}

/* ─── Sidebar nav ────────────────────────────────────────────────────────── */

.nav-links {
  flex: 1;
  padding: 22px 0;
  display: flex;
  flex-direction: column;
}

.nav-links a {
  padding: 11px 28px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: all 0.2s;
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.nav-links a:hover {
  color: var(--gold-bright);
  background: rgba(200, 164, 92, 0.05);
}

.nav-links a.active {
  border-left-color: var(--gold);
  color: var(--gold);
  background: linear-gradient(90deg, rgba(200, 164, 92, 0.09), transparent 70%);
}

.sidebar-footer {
  padding: 20px 22px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: rgba(200, 164, 92, 0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status {
  font-size: 0.64rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-top: 2px;
}

/* ─── Account switcher ───────────────────────────────────────────────────── */

.account-switcher {
  position: relative;
  margin-bottom: 14px;
}

.account-switcher-label {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.26em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 7px;
}

.account-current {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name caret" "kind caret";
  align-items: center;
  gap: 0 8px;
  padding: 11px 12px;
  background: linear-gradient(180deg, rgba(200, 164, 92, 0.1), rgba(200, 164, 92, 0.04));
  border: 1px solid rgba(200, 164, 92, 0.32);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.account-current:hover {
  border-color: var(--gold);
  background: rgba(200, 164, 92, 0.12);
}

.account-current-name {
  grid-area: name;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-current-kind {
  grid-area: kind;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--gold);
  margin-top: 3px;
}

.account-caret {
  grid-area: caret;
  color: var(--gold);
  font-size: 0.7rem;
}

.account-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-panel);
  overflow: hidden;
  z-index: 200;
}

.account-menu[hidden] {
  display: none;
}

.account-option {
  display: block;
  width: 100%;
  padding: 11px 13px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.account-option:last-child {
  border-bottom: none;
}

.account-option:hover:not(:disabled) {
  background: rgba(200, 164, 92, 0.09);
}

.account-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.account-option.is-active {
  background: rgba(200, 164, 92, 0.07);
  box-shadow: inset 2px 0 0 var(--gold);
}

.account-option-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Register action sits below the accounts, set apart from them. */
.account-option-action {
  border-top: 1px solid var(--border);
  background: rgba(200, 164, 92, 0.04);
}

.account-option-action .account-option-name {
  color: var(--gold);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
}

.account-option-meta {
  display: block;
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
}

/* ─── Account separation ─────────────────────────────────────────────────────
   The two account kinds do not share a surface. Personal facilities are absent
   while banking as a firm, and firm facilities are absent while banking as a
   person, so nothing on screen belongs to an account you are not using. */

:root[data-account-kind="business"] .personal-only {
  display: none !important;
}

:root[data-account-kind="personal"] .business-only {
  display: none !important;
}

.sidebar-logout {
  display: block;
  text-align: center;
  padding: 9px 12px;
  margin-top: 12px;
  font-size: 0.66rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.sidebar-logout:hover {
  color: var(--gold);
  border-color: var(--border);
  background: rgba(200, 164, 92, 0.05);
}

/* ─── Panels ─────────────────────────────────────────────────────────────── */

.panel, .glass-panel {
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-panel);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 16px;
  margin-bottom: 22px;
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn, .btn-primary, .btn-secondary {
  border: none;
  border-radius: 9px;
  padding: 13px 26px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-bright) 0%, var(--gold) 45%, #a9853f 100%);
  color: #171207;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 6px 18px rgba(200, 164, 92, 0.18);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 10px 26px rgba(200, 164, 92, 0.28);
  filter: brightness(1.04);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--gold-deep);
  color: var(--gold);
}

.btn-secondary:hover {
  background: rgba(200, 164, 92, 0.08);
  border-color: var(--gold);
}

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

.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid rgba(23, 18, 7, 0.3);
  border-radius: 50%;
  border-top-color: #171207;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Inputs ─────────────────────────────────────────────────────────────── */

input, textarea, select {
  background: var(--bg-well);
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
  border-radius: 9px;
  padding: 12px 14px;
  font-size: 0.9rem;
  transition: all 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 164, 92, 0.12);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.input-group label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  font-weight: 600;
}

.input-wrapper {
  position: relative;
}

.currency-symbol {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.input-wrapper input {
  padding-left: 30px;
  width: 100%;
}

.input-wrapper.has-max input {
  padding-right: 54px;
}

.btn-max {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--gold);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 8px;
}

/* ─── Typography ─────────────────────────────────────────────────────────── */

.hero-balance {
  font-size: 3.4rem;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.sub-label {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.66rem;
  font-weight: 600;
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  border: 1px solid;
}

.badge.gold, .badge.crimson {
  background: rgba(200, 164, 92, 0.1);
  border-color: rgba(200, 164, 92, 0.45);
  color: var(--gold-bright);
}

.badge.good {
  background: rgba(62, 155, 110, 0.12);
  border-color: rgba(62, 155, 110, 0.5);
  color: #6fc79c;
}

.badge.warning {
  background: rgba(206, 156, 79, 0.12);
  border-color: rgba(206, 156, 79, 0.5);
  color: var(--orange);
}

.badge.danger {
  background: rgba(192, 91, 91, 0.12);
  border-color: rgba(192, 91, 91, 0.5);
  color: #d98a8a;
}

/* ─── Bento grid ─────────────────────────────────────────────────────────── */

.bento-grid {
  display: grid;
  gap: 22px;
  grid-template-columns: 2fr 1fr;
}

.bento-item {
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-panel);
}

@media (max-width: 1200px) {
  .bento-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */

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

.data-table thead {
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 12px;
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
}

.data-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.data-table tbody tr:hover {
  background: rgba(200, 164, 92, 0.04);
}

/* ─── Status messages ────────────────────────────────────────────────────── */

.status-msg {
  font-size: 0.85rem;
  margin-top: 10px;
  padding: 11px 15px;
  border-radius: 8px;
  border-left: 2px solid;
}

.status-msg.success {
  background: rgba(62, 155, 110, 0.1);
  border-color: var(--green);
  color: #6fc79c;
}

.status-msg.error {
  background: rgba(192, 91, 91, 0.1);
  border-color: var(--claret);
  color: #d98a8a;
}

.status-msg.warning {
  background: rgba(206, 156, 79, 0.1);
  border-color: var(--orange);
  color: var(--orange);
}

.status-msg.info {
  background: rgba(122, 149, 188, 0.1);
  border-color: var(--info);
  color: var(--info);
}

/* ─── Credit score ───────────────────────────────────────────────────────── */

.credit-score-bar {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--claret), var(--orange), var(--green));
  margin-top: 6px;
  overflow: hidden;
}

.credit-score-fill {
  height: 100%;
  background: var(--gold);
  transition: width 0.3s;
}

/* ─── Info rows ──────────────────────────────────────────────────────────── */

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.9rem;
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  color: var(--text-muted);
  font-weight: 500;
}

.info-value {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ─── Charts ─────────────────────────────────────────────────────────────── */

.chart-container {
  position: relative;
  height: 250px;
  margin: 20px 0;
}

/* ─── Dashboard ──────────────────────────────────────────────────────────── */

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.dashboard-header h1 {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 600;
}

.greeting h2 {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-card {
  text-align: center;
  padding: 22px 20px;
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-surface));
  border: 1px solid var(--border);
  border-radius: 12px;
}

.stat-card-label {
  color: var(--text-muted);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 8px;
  font-weight: 600;
}

.stat-card-value {
  font-size: 1.45rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--gold-bright);
}

/* ─── Tabs ───────────────────────────────────────────────────────────────── */

.d-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 22px;
}

.d-tab {
  padding: 12px 18px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
}

.d-tab:hover {
  color: var(--gold-bright);
}

.d-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ─── Hero panel (formerly header-gradient) ─────────────────────────────── */

.header-gradient {
  position: relative;
  background:
    radial-gradient(600px 200px at 20% 0%, rgba(200, 164, 92, 0.12), transparent 65%),
    linear-gradient(180deg, var(--bg-elevated), var(--bg-surface));
  padding: 36px 34px;
  border-radius: var(--radius);
  margin-bottom: 32px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.header-gradient::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(227, 199, 138, 0.5), transparent);
}

/* ─── Ornaments ──────────────────────────────────────────────────────────── */

.gold-rule {
  height: 1px;
  border: none;
  background: linear-gradient(90deg, transparent, rgba(200, 164, 92, 0.55), transparent);
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .layout-wrapper {
    flex-direction: column;
  }

  .main-content {
    margin-left: 0;
    padding: 20px;
  }

  .bento-grid {
    grid-template-columns: 1fr;
  }

  .hero-balance {
    font-size: 2.2rem;
  }

  .dashboard-header {
    flex-direction: column;
  }

  .data-table {
    font-size: 0.8rem;
  }

  .data-table th, .data-table td {
    padding: 8px;
  }
}

/* ─── Loading spinner ────────────────────────────────────────────────────── */

.spinner {
  border: 3px solid var(--border-soft);
  border-top: 3px solid var(--gold);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}
