/* ===================================================
   OurFinanceGrid — Design System
   =================================================== */

:root {
  --primary:        #0F766E;
  --primary-dark:   #0C5F58;
  --primary-light:  #CCFBF1;
  --primary-mid:    #14B8A6;
  --accent:         #6366F1;
  --accent-light:   #EEF2FF;
  --danger:         #DC2626;
  --danger-light:   #FEF2F2;
  --success:        #16A34A;
  --success-light:  #F0FDF4;
  --warning:        #D97706;
  --warning-light:  #FFFBEB;
  --mh:             #7C3AED;
  --mh-light:       #F5F3FF;
  --mh-border:      #DDD6FE;

  --sidebar-bg:     #0C1A2E;
  --sidebar-hover:  rgba(255,255,255,.07);
  --sidebar-active: rgba(20,184,166,.18);
  --sidebar-text:   #94A3B8;
  --sidebar-active-text: #2DD4BF;

  --bg:             #F1F5F9;
  --surface:        #FFFFFF;
  --border:         #E2E8F0;
  --border-light:   #F1F5F9;
  --text:           #0F172A;
  --text-muted:     #64748B;
  --text-light:     #94A3B8;

  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --radius-xl:      20px;

  --shadow-sm:      0 1px 2px rgba(0,0,0,.06);
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:      0 10px 25px rgba(0,0,0,.1), 0 4px 10px rgba(0,0,0,.05);
  --shadow-xl:      0 25px 50px rgba(0,0,0,.15);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4,h5 { font-weight: 700; line-height: 1.3; }
p { color: var(--text-muted); }

/* ===================== AUTH LAYOUT ===================== */

.auth-body { min-height: 100vh; background: var(--bg); }

.auth-split {
  display: grid;
  grid-template-columns: 420px 1fr;
  min-height: 100vh;
}

@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

.auth-brand {
  background: linear-gradient(160deg, #0C1A2E 0%, #0F766E 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.auth-brand-inner { color: #fff; max-width: 340px; }

.auth-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 48px; }

.logo-mark-lg {
  width: 52px; height: 52px;
  background: var(--primary-mid);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}

.auth-logo-name { font-size: 20px; font-weight: 800; color: #fff; }
.auth-logo-tag { font-size: 12px; color: rgba(255,255,255,.55); margin-top: 1px; }

.auth-brand-copy h2 { font-size: 26px; color: #fff; margin-bottom: 12px; line-height: 1.3; }
.auth-brand-copy p { color: rgba(255,255,255,.65); font-size: 14px; margin-bottom: 28px; }

.auth-features { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.auth-features li { color: rgba(255,255,255,.8); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.auth-features li i { color: var(--primary-mid); font-size: 14px; flex-shrink: 0; }

.auth-brand-footer {
  margin-top: 48px;
  font-size: 11px;
  color: rgba(255,255,255,.35);
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  overflow-y: auto;
}

.auth-form-inner { width: 100%; max-width: 440px; }

.auth-mobile-logo {
  display: none;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 28px;
}

@media (max-width: 900px) { .auth-mobile-logo { display: flex; } }

.logo-mark {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}

/* Auth Form Box */
.auth-form-box { width: 100%; }
.auth-form-header { text-align: center; margin-bottom: 28px; }
.auth-form-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin: 0 auto 16px;
}
.auth-form-icon.personal { background: var(--primary-light); color: var(--primary); }
.auth-form-icon.company  { background: var(--accent-light); color: var(--accent); }
.auth-form-header h1 { font-size: 22px; margin-bottom: 4px; color: var(--text); }
.auth-form-header p { font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form-links { margin-top: 20px; text-align: center; font-size: 13px; }
.auth-form-links p { margin: 6px 0; color: var(--text-muted); }

/* Choose portal */
.choose-portal { width: 100%; }
.choose-portal h1 { font-size: 24px; margin-bottom: 6px; color: var(--text); text-align: center; }
.choose-sub { text-align: center; margin-bottom: 28px; font-size: 15px; }
.portal-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .portal-cards { grid-template-columns: 1fr; } }
.portal-card {
  display: block;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all .2s;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
}
.portal-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-3px); text-decoration: none; color: var(--text); }
.portal-card-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 14px;
}
.portal-card-icon.personal { background: var(--primary-light); color: var(--primary); }
.portal-card-icon.company  { background: var(--accent-light); color: var(--accent); }
.portal-card h3 { font-size: 16px; margin-bottom: 6px; }
.portal-card p { font-size: 13px; margin-bottom: 14px; }
.portal-card ul { list-style: none; display: flex; flex-direction: column; gap: 5px; margin-bottom: 18px; }
.portal-card ul li { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.portal-card ul li::before { content: '✓'; color: var(--primary); font-weight: 700; }
.portal-card-cta { font-size: 13px; font-weight: 600; color: var(--primary); display: flex; align-items: center; gap: 6px; }
.choose-login { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }

/* Register company form / signup wizard */
.auth-card { width: 100%; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; color: var(--text); }
.auth-card > p { margin-bottom: 24px; font-size: 14px; }
.auth-card-wide { width: 100%; max-width: 560px; }
.auth-card-wide h1 { font-size: 22px; margin-bottom: 4px; color: var(--text); }
.auth-card-wide > p { margin-bottom: 24px; font-size: 14px; }
.auth-link { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 16px; }

/* Utility */
.hidden { display: none !important; }
.client-table-wrap { overflow-x: auto; }
.email-html { font-size: 13px; line-height: 1.6; }

/* ===================== APP LAYOUT ===================== */

.app-body { background: var(--bg); }

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

/* Sidebar */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s ease;
  overflow-y: auto;
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block !important; }
}

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 199; }
.sidebar-overlay.active { display: block; }

.sidebar-header {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.sidebar-logo:hover { text-decoration: none; }
.logo-name { display: block; font-size: 14px; font-weight: 800; color: #fff; }
.logo-sub { display: block; font-size: 10px; color: rgba(255,255,255,.35); margin-top: 1px; }

.sidebar-close { display: none; background: none; border: none; color: var(--sidebar-text); font-size: 16px; cursor: pointer; padding: 4px; }
@media (max-width: 900px) { .sidebar-close { display: flex; } }

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  margin: 10px 10px 4px;
  background: rgba(255,255,255,.05);
  border-radius: var(--radius);
}

.profile-avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.company-avatar { background: var(--accent); font-size: 14px; }
.profile-name { display: block; font-size: 12px; font-weight: 600; color: #fff; }
.profile-ref { display: block; font-size: 10px; color: var(--sidebar-text); font-family: monospace; margin-top: 1px; }

.sidebar-mh-badge {
  margin: 0 10px 6px;
  background: rgba(124,58,237,.25);
  border: 1px solid rgba(124,58,237,.4);
  color: #C4B5FD;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 6px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s;
}

.nav-item i { width: 16px; text-align: center; font-size: 13px; flex-shrink: 0; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-active-text); font-weight: 600; }
.nav-divider { height: 1px; background: rgba(255,255,255,.07); margin: 6px 0; }

.sidebar-footer { padding: 10px; border-top: 1px solid rgba(255,255,255,.07); }
.nav-logout { color: var(--sidebar-text); }
.nav-logout:hover { color: #fff; }

/* Main wrapper */
.main-wrapper {
  flex: 1;
  margin-left: 250px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

@media (max-width: 900px) { .main-wrapper { margin-left: 0; } }

/* Topbar */
.topbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}
@media (max-width: 900px) { .topbar-menu-btn { display: flex; } }

.topbar-title { font-size: 15px; font-weight: 700; flex: 1; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all .15s;
  font-size: 15px;
}
.topbar-icon-btn:hover { background: var(--bg); color: var(--text); text-decoration: none; }

/* Page content */
.page-content { padding: 28px 28px 40px; max-width: 1280px; }
@media (max-width: 600px) { .page-content { padding: 16px 16px 32px; } }

/* ===================== FORMS ===================== */

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group input,
.form-group select,
.form-group textarea,
.form-control {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border .15s, box-shadow .15s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,118,110,.1);
}
.form-group input::placeholder { color: var(--text-light); }
.form-group textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.form-group select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748B'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }
.form-group input[disabled], .input-disabled { background: var(--bg) !important; color: var(--text-muted) !important; cursor: not-allowed; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-group-sm { max-width: 160px; }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 3px; }
.req { color: var(--danger); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; flex-wrap: wrap; }
.form-divider { padding-top: 20px; margin: 8px 0 16px; border-top: 1px solid var(--border); }
.form-divider h3 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.form-divider p { font-size: 13px; }

.input-icon-wrap { position: relative; }
.input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-light); font-size: 13px; pointer-events: none; }
.input-icon-wrap input { padding-left: 36px; }

.input-prefix {
  display: flex; align-items: center;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  transition: border .15s, box-shadow .15s;
}
.input-prefix:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.1); }
.input-prefix > span, .input-prefix-label {
  padding: 0 10px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 14px;
  border-right: 1.5px solid var(--border);
  height: 100%;
  display: flex; align-items: center;
  white-space: nowrap;
}
.input-prefix input { border: none; box-shadow: none !important; padding-left: 10px; flex: 1; }
.input-prefix input:focus { outline: none; }

.checkbox-group label { display: flex; align-items: flex-start; gap: 9px; font-weight: 500; cursor: pointer; font-size: 14px; color: var(--text); }
.checkbox-group input[type=checkbox] { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }
.checkbox-group p { padding-left: 25px; }
.mh-checkbox label { background: var(--mh-light); border: 1.5px solid var(--mh-border); border-radius: var(--radius); padding: 12px; }

.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.checkbox-grid label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 400; cursor: pointer; }
.hidden { display: none !important; }

/* ===================== BUTTONS ===================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ===================== ALERTS ===================== */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #BBF7D0; }
.alert-error   { background: var(--danger-light); color: var(--danger); border: 1px solid #FECACA; }
.alert-info    { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #99F6E4; }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #FDE68A; }

/* ===================== PAGE HEADER ===================== */

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 12px; flex-wrap: wrap;
}
.page-header-left h1 { font-size: 22px; color: var(--text); }
.page-header-left p { font-size: 14px; margin-top: 2px; }
.page-header h1 { font-size: 22px; color: var(--text); }
.page-header p { font-size: 14px; margin-top: 2px; }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===================== CARDS ===================== */

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 0;
}
.card-header h2 { font-size: 15px; font-weight: 700; }
.card-body { padding: 18px 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

/* ===================== STATS ===================== */

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.stat-card.c-teal::before  { background: var(--primary); }
.stat-card.c-danger::before{ background: var(--danger); }
.stat-card.c-purple::before{ background: var(--mh); }
.stat-card.c-orange::before{ background: var(--warning); }
.stat-card.c-accent::before{ background: var(--accent); }
.stat-card.c-success::before{ background: var(--success); }

.stat-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  margin-bottom: 12px;
}
.stat-icon.teal  { background: var(--primary-light); color: var(--primary); }
.stat-icon.red   { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple{ background: var(--mh-light); color: var(--mh); }
.stat-icon.orange{ background: var(--warning-light); color: var(--warning); }
.stat-icon.accent{ background: var(--accent-light); color: var(--accent); }
.stat-icon.green { background: var(--success-light); color: var(--success); }

.stat-value { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-sub   { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* ===================== PANELS ===================== */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-size: 14px; font-weight: 700; }
.panel-body { padding: 16px 20px; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 768px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* Empty states */
.empty-state { padding: 40px 20px; text-align: center; color: var(--text-muted); }
.empty-state p { margin-bottom: 12px; font-size: 14px; }
.empty-icon { font-size: 40px; margin-bottom: 12px; display: block; }
.empty-page { padding: 60px 20px; text-align: center; }
.empty-page p { margin-bottom: 12px; }

/* ===================== TABLES ===================== */

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: var(--bg);
  text-align: left;
  padding: 10px 14px;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #F8FAFC; }
.td-sub { display: block; font-size: 11px; color: var(--text-light); margin-top: 2px; }
.td-name { font-weight: 600; }

/* ===================== BADGES ===================== */

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-default  { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge-teal     { background: var(--primary-light); color: var(--primary-dark); }
.badge-green    { background: var(--success-light); color: var(--success); }
.badge-red      { background: var(--danger-light); color: var(--danger); }
.badge-orange   { background: var(--warning-light); color: var(--warning); }
.badge-purple   { background: var(--mh-light); color: var(--mh); }
.badge-accent   { background: var(--accent-light); color: var(--accent); }

.ref-tag {
  display: inline-block;
  font-family: 'Courier New', monospace;
  font-size: 11px; font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  color: var(--text);
  letter-spacing: .05em;
}
.ref-tag-lg { font-size: 13px; padding: 4px 10px; }

/* Status badges */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-assessment  { background: #FEF9C3; color: #854D0E; }
.status-active      { background: #DBEAFE; color: #1D4ED8; }
.status-breathing_space { background: var(--success-light); color: var(--success); }
.status-mental_health_bs { background: var(--mh-light); color: var(--mh); }
.status-paused      { background: var(--bg); color: var(--text-muted); }
.status-completed   { background: #DCFCE7; color: #166534; }
.status-cancelled   { background: var(--danger-light); color: var(--danger); }
.status-sent        { background: #DBEAFE; color: #1E40AF; }
.status-replied     { background: var(--success-light); color: var(--success); }
.status-failed      { background: var(--danger-light); color: var(--danger); }
.status-draft       { background: var(--bg); color: var(--text-muted); }

.flag-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.flag-mh   { background: var(--mh-light); color: var(--mh); border: 1px solid var(--mh-border); }
.flag-vuln { background: var(--warning-light); color: var(--warning); border: 1px solid #FDE68A; }

/* ===================== TABS ===================== */

.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab {
  background: none; border: none;
  padding: 10px 18px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 10px; margin-left: 5px;
}
.tab-content { display: none; }
.tab-content.active, .tab-content:first-of-type { display: block; }

/* ===================== MODAL ===================== */

.modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 20px;
  overflow-y: auto;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 0;
  width: 100%; max-width: 540px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-shrink: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* Old modals without .modal-body wrapper */
.modal-box > form { padding: 22px; overflow-y: auto; }

/* ===================== CREDITOR AUTOCOMPLETE ===================== */
.creditor-autocomplete { position: relative; }
.creditor-suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
}
.creditor-suggestion-item {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.creditor-suggestion-item:last-child { border-bottom: none; }
.creditor-suggestion-item:hover { background: var(--primary-light); }
.cs-name { font-size: 13px; font-weight: 600; color: var(--text); }
.cs-email { font-size: 11px; color: var(--text-muted); }
.cs-unknown { font-style: italic; }
.creditor-match-hint {
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: -8px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  line-height: 1.5;
}
.creditor-match-hint i { margin-top: 1px; flex-shrink: 0; }
.creditor-match-hint:has(.fa-circle-check) { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.creditor-match-hint:has(.fa-circle-info) { background: #FFF7ED; color: #9A3412; border: 1px solid #FED7AA; }

/* ===================== DEBT CARDS ===================== */

.debt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.debt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
}
.debt-card:hover { box-shadow: var(--shadow-md); }
.debt-settled { opacity: .6; }

.debt-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.debt-card-top h3 { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.debt-type-badge { font-size: 11px; background: var(--bg); border: 1px solid var(--border); padding: 2px 7px; border-radius: 4px; color: var(--text-muted); text-transform: capitalize; }
.debt-card-amount { text-align: right; }
.debt-card-amount .amount-val { font-size: 18px; font-weight: 800; color: var(--danger); }
.debt-card-amount .amount-sub { font-size: 11px; color: var(--text-light); margin-top: 1px; }

.debt-card-details { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.debt-card-detail { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.debt-card-detail i { font-size: 11px; color: var(--text-light); }

.debt-card-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.debt-card-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--border-light); }

.debt-row-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.debt-row-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.debt-num { font-size: 13px; font-weight: 700; }
.btn-remove-debt { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 4px; font-family: inherit; }
.btn-remove-debt:hover { background: var(--danger-light); }
.debt-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .debt-fields { grid-template-columns: 1fr; } }
.debt-actions { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; }
.debt-total { font-weight: 700; font-size: 14px; }

/* Inline debt list */
.debt-list-items { display: flex; flex-direction: column; }
.debt-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.debt-list-item:last-child { border-bottom: none; }
.dli-info { display: flex; flex-direction: column; gap: 2px; }
.dli-info strong { font-size: 13px; }
.dli-info span { font-size: 11px; color: var(--text-muted); }
.dli-right { text-align: right; }
.dli-right strong { font-size: 14px; font-weight: 700; }

/* ===================== LETTERS ===================== */

.letter-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--surface);
  transition: box-shadow .15s;
}
.letter-card:hover { box-shadow: var(--shadow-sm); }
.letter-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.letter-card-header strong { font-size: 14px; font-weight: 600; }
.letter-creditor { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.letter-card-meta { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); }
.letter-reply-preview {
  background: var(--success-light); border: 1px solid #BBF7D0; border-radius: var(--radius-sm);
  padding: 10px 12px; margin-top: 10px; font-size: 12px;
}
.letter-reply-preview strong { color: var(--success); display: block; margin-bottom: 4px; }
.letter-reply-preview p { font-size: 12px; }

/* ===================== INBOX ===================== */

.email-list { display: flex; flex-direction: column; gap: 4px; }
.email-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow .1s;
  background: var(--surface);
}
.email-item:hover { box-shadow: var(--shadow-sm); }
.email-unread { border-left: 3px solid var(--primary); }
.email-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 14px; }
.email-from { display: block; font-weight: 700; font-size: 13px; color: var(--text); }
.email-subject { display: block; color: var(--text-muted); font-size: 13px; margin-top: 1px; }
.email-date { font-size: 12px; color: var(--text-light); flex-shrink: 0; margin-left: 10px; }
.email-body { padding: 12px 14px; border-top: 1px solid var(--border-light); }
.email-text { font-size: 13px; white-space: pre-wrap; font-family: inherit; color: var(--text); line-height: 1.6; }

/* ===================== COMPOSE ===================== */

.compose-layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; }
@media (max-width: 768px) { .compose-layout { grid-template-columns: 1fr; } }

.compose-sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; height: fit-content; box-shadow: var(--shadow); }
.compose-sidebar h3 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 10px; margin-top: 16px; }
.compose-sidebar h3:first-child { margin-top: 0; }
.compose-sidebar select { width: 100%; margin-bottom: 14px; }

.template-list { max-height: 280px; overflow-y: auto; margin-bottom: 4px; }
.template-cat-label { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-light); padding: 5px 6px 3px; }
.template-option { padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.template-option:hover { background: var(--bg); color: var(--text); }
.template-option.selected { background: var(--primary); color: #fff; }

.compose-main { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.preview-header { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.preview-meta { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.letter-preview {
  background: #FAFAFA; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px; font-size: 14px; line-height: 1.8; min-height: 200px;
}
.letter-preview p { margin-bottom: 12px; color: var(--text); }
.letter-preview ul { margin: 10px 0 12px 20px; }
.compose-placeholder { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.placeholder-icon { font-size: 40px; margin-bottom: 14px; display: block; }
.placeholder-icon i { color: var(--border); }
.client-context-bar {
  background: var(--primary-light); border: 1px solid #99F6E4;
  border-radius: var(--radius); padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap;
}

/* ===================== WIZARD ===================== */

.wizard-steps { display: flex; align-items: center; margin-bottom: 28px; }
.step {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--border); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
  transition: all .2s;
}
.step.active { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-light); }
.step.done { background: var(--success); color: #fff; }
.step-line { height: 2px; flex: 1; background: var(--border); max-width: 50px; transition: background .2s; }
.step-line.done { background: var(--success); }

.income-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 600px) { .income-grid { grid-template-columns: 1fr; } }

/* ===================== REVIEW ===================== */

.review-section { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.review-section h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 12px; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.review-grid div { display: flex; flex-direction: column; gap: 2px; }
.review-grid span { color: var(--text-muted); font-size: 12px; }
.review-grid strong { color: var(--text); }
.review-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.review-table th { text-align: left; padding: 6px 8px; font-weight: 700; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.review-table td { padding: 7px 8px; border-bottom: 1px solid var(--border-light); }
.review-table tfoot td { font-weight: 700; padding-top: 10px; }
.dmp-suggestion { background: linear-gradient(135deg, var(--primary-light), #E0F2FE); border: 1px solid #99F6E4; border-radius: var(--radius-lg); padding: 18px; display: flex; gap: 14px; align-items: flex-start; margin-bottom: 20px; }
.dmp-suggestion-icon { font-size: 28px; flex-shrink: 0; }
.dmp-suggestion p { font-size: 13px; margin-top: 4px; }

/* ===================== COMPLETE PAGE ===================== */

.complete-card { text-align: center; }
.complete-icon { font-size: 56px; margin-bottom: 12px; }
.ref-display { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; margin: 16px 0; }
.ref-display label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); display: block; margin-bottom: 10px; }
.ref-big { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 22px; font-weight: 800; font-family: 'Courier New', monospace; color: var(--primary); flex-wrap: wrap; }
.copy-btn { font-size: 12px; padding: 5px 12px; background: var(--primary); color: #fff; border: none; border-radius: 5px; cursor: pointer; font-weight: 600; font-family: inherit; }
.copy-btn:hover { background: var(--primary-dark); }
.ref-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.dmp-summary { background: var(--bg); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.dmp-summary h3 { font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.dmp-stats { display: flex; gap: 24px; justify-content: center; }
.dmp-stat { text-align: center; }
.dmp-stat span { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.dmp-stat strong { font-size: 20px; font-weight: 800; }
.next-steps { text-align: left; margin: 16px 0; }
.next-steps h3 { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.next-steps ol { padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.next-steps li { font-size: 13px; color: var(--text-muted); }
.next-steps strong { color: var(--text); }
.mh-support-box { background: var(--mh-light); border: 1px solid var(--mh-border); border-radius: var(--radius); padding: 14px; margin: 16px 0; text-align: left; }
.mh-support-box h4 { font-size: 13px; font-weight: 700; color: var(--mh); margin-bottom: 6px; }

/* ===================== PROFILE ===================== */

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .profile-grid { grid-template-columns: 1fr; } }
.profile-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow); }
.profile-panel h2 { font-size: 15px; font-weight: 700; margin-bottom: 18px; }
.profile-divider { margin: 20px 0 16px; padding-top: 18px; border-top: 1px solid var(--border); }
.profile-divider h3 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.ref-display-sm { background: var(--bg); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.ref-code-sm { font-size: 20px; font-weight: 800; font-family: 'Courier New', monospace; color: var(--primary); letter-spacing: .05em; }
.ref-code-sm.small { font-size: 13px; word-break: break-all; }
.mh-help-box { background: var(--mh-light); border: 1px solid var(--mh-border); border-radius: var(--radius); padding: 14px; margin-top: 16px; }
.mh-help-box h4 { font-size: 13px; font-weight: 700; color: var(--mh); margin-bottom: 6px; }
.mh-help-box p { font-size: 12px; margin-bottom: 8px; }

/* ===================== STANDING ORDER ===================== */

.so-guide { background: linear-gradient(135deg, var(--primary-light), #E0F2FE); border: 1px solid #99F6E4; border-radius: var(--radius-lg); padding: 20px; display: flex; gap: 16px; margin-bottom: 20px; }
.so-guide-icon { font-size: 32px; flex-shrink: 0; }
.so-guide h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.so-guide p { font-size: 13px; }
.so-panel, .so-form-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow); }
.so-panel h3, .so-form-panel h3 { font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.so-suggested { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 600px) { .so-suggested { grid-template-columns: 1fr; } }
.so-suggested div { background: var(--bg); border-radius: var(--radius-sm); padding: 12px; }
.so-suggested span { display: block; font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.so-suggested strong { font-size: 15px; font-weight: 700; }

/* ===================== DOCUMENTS ===================== */

.doc-info-box { background: var(--primary-light); border: 1px solid #99F6E4; border-radius: var(--radius-lg); padding: 16px; display: flex; gap: 14px; margin-bottom: 20px; }
.doc-info-icon { font-size: 28px; flex-shrink: 0; }
.doc-info strong { display: block; margin-bottom: 4px; font-size: 14px; }
.doc-info p { font-size: 13px; }
.mh-note { background: var(--mh-light); border: 1px solid var(--mh-border); border-radius: var(--radius); padding: 12px; margin: 14px 0; font-size: 13px; }
.mh-note strong { color: var(--mh); display: block; margin-bottom: 4px; }
.doc-categories { display: flex; flex-direction: column; gap: 24px; }
.doc-group h3 { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.doc-list { display: flex; flex-direction: column; gap: 6px; }
.doc-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; align-items: flex-start; gap: 12px; box-shadow: var(--shadow-sm); }
.doc-icon { font-size: 22px; flex-shrink: 0; margin-top: 2px; }
.doc-info { flex: 1; }
.doc-info strong { display: block; font-size: 14px; font-weight: 600; }
.doc-desc { font-size: 12px; color: var(--text-muted); margin: 2px 0; }
.doc-meta { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.doc-actions { display: flex; gap: 6px; align-items: flex-start; }

/* ===================== QUICK ACTIONS ===================== */

.quick-actions { margin-top: 20px; }
.quick-actions h2 { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.action-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 14px;
  text-align: center; text-decoration: none; color: var(--text);
  transition: all .2s; box-shadow: var(--shadow);
}
.action-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; color: var(--text); }
.action-icon { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--radius); margin: 0 auto 10px; font-size: 18px; }
.action-card span:last-child { font-size: 12px; font-weight: 600; }

/* ===================== CLIENT LIST ===================== */

.client-preview-list { display: flex; flex-direction: column; }
.client-preview-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none; color: var(--text);
  transition: none;
}
.client-preview-item:last-child { border-bottom: none; }
.client-preview-item:hover { text-decoration: none; }
.client-preview-left { display: flex; align-items: center; gap: 10px; }
.client-avatar { width: 32px; height: 32px; border-radius: 9px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.client-name { font-size: 13px; font-weight: 600; }
.client-meta { font-size: 11px; color: var(--text-light); margin-top: 1px; display: flex; align-items: center; gap: 6px; }
.client-preview-right { display: flex; align-items: center; gap: 8px; }

/* ===================== DETAIL GRID ===================== */

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 768px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.detail-panel h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 14px; }
.detail-rows { display: flex; flex-direction: column; gap: 1px; }
.detail-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border-light); gap: 12px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .dr-label { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.detail-row .dr-value { font-size: 13px; font-weight: 600; text-align: right; }

.client-header-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

/* ===================== SEARCH BAR ===================== */

.search-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 220px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 14px; font-family: inherit; background: var(--surface);
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.1); }
.search-bar select { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px; background: var(--surface); font-family: inherit; }

/* ===================== TEMPLATE EDITOR ===================== */

.template-editor { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }
.token-hints { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.8; }
.token-hints code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 11px; cursor: pointer; margin: 2px; display: inline-block; transition: all .1s; }
.token-hints code:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.template-group { margin-bottom: 24px; }
.template-group h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.template-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.template-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); }
.template-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; gap: 8px; }
.template-card-header strong { font-size: 13px; font-weight: 700; }
.template-subject { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.template-card-actions { display: flex; gap: 8px; }

/* ===================== FORM PANEL ===================== */

.form-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }
.form-panel h2 { font-size: 16px; font-weight: 700; margin-bottom: 18px; }

/* ===================== MISC COMPONENTS ===================== */

.mh-banner { background: var(--mh-light); border: 1px solid var(--mh-border); color: var(--mh); padding: 8px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.hint { color: var(--text-muted); font-size: 13px; }

.info-box { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; gap: 12px; align-items: flex-start; }
.info-box-icon { font-size: 20px; flex-shrink: 0; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-header h2 { font-size: 14px; font-weight: 700; }

/* ===================== LETTER THREAD ===================== */

.letter-card-link { display: block; text-decoration: none; color: inherit; cursor: pointer; }
.letter-card-link:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); transform: translateY(-1px); transition: all .15s; }

.letter-thread { display: flex; flex-direction: column; gap: 20px; max-width: 820px; }

.thread-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }

.thread-sent { border-top: 3px solid var(--primary); }
.thread-reply { border-top: 3px solid var(--success); }

.thread-meta { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 12px; }
.thread-direction { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.thread-sent .thread-direction { color: var(--primary); }
.thread-reply .thread-direction { color: var(--success); }
.thread-date { color: var(--text-muted); }

.thread-envelope { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.envelope-row { display: flex; gap: 12px; font-size: 13px; align-items: baseline; }
.envelope-row span:first-child { color: var(--text-muted); min-width: 60px; font-size: 12px; }

.letter-body-frame { padding: 24px; font-size: 14px; line-height: 1.7; }

.reply-body { padding: 16px; }

.thread-waiting { background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius); padding: 14px 18px; font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }

.page-header-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.page-header-sub a { color: var(--primary); text-decoration: none; }

/* ===================== SCROLLBAR ===================== */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ===================== RESPONSIVE ===================== */

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .review-grid { grid-template-columns: 1fr; }
  .debt-cards { grid-template-columns: 1fr; }
  .form-group-sm { max-width: 100%; }
  .profile-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}
