/* =========================================================
   Roxonic Limited - Client Management System
   Theme: "Ledger"
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --navy-900: #0E1526;
  --navy-800: #141C31;
  --navy-700: #1C263F;
  --gold-500: #C9A34E;
  --gold-600: #B5892F;
  --paper: #F4F6F9;
  --surface: #FFFFFF;
  --border: #E4E8EF;
  --ink-900: #171B27;
  --ink-600: #5B6478;
  --ink-400: #8A93A6;
  --green-600: #2F6F5E;
  --red-600: #B5482A;
  --amber-600: #B5892F;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(14, 21, 38, 0.06);
  --shadow-md: 0 8px 24px rgba(14, 21, 38, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink-900);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
}

h1, h2, h3, h4, .brand-font {
  font-family: 'Sora', 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-900);
  margin: 0;
}

.mono, .amount, td.num, th.num {
  font-family: 'IBM Plex Mono', monospace;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
  color: #E9ECF3;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 20;
}

.sidebar-logo {
  padding: 26px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo img { max-width: 150px; display: block; }

.sidebar-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }

.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(233,236,243,0.35);
  padding: 14px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(233,236,243,0.78);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  transition: background .15s ease, color .15s ease;
}

.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }

.nav-link.active {
  background: rgba(201,163,78,0.14);
  color: #fff;
  border-left: 3px solid var(--gold-500);
}

.nav-link .ico { width: 17px; text-align: center; opacity: 0.9; }

.sidebar-footer {
  padding: 14px 20px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: rgba(233,236,243,0.45);
}

/* ---------- Main area ---------- */
.main {
  margin-left: 232px;
  flex: 1;
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 { font-size: 18px; }

.topbar .user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-600);
}

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy-800);
  color: var(--gold-500);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
}

.content { padding: 24px 28px 60px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-500);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.stat-card .stat-icon {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 9px;
  background: rgba(201,163,78,0.12);
  color: var(--gold-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}

.stat-card .label { font-size: 12px; color: var(--ink-600); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-family: 'IBM Plex Mono', monospace; font-size: 22px; font-weight: 600; margin-top: 5px; }

.stat-card.income { border-left-color: var(--green-600); }
.stat-card.income .stat-icon { background: rgba(47,111,94,0.12); color: var(--green-600); }

.stat-card.expense { border-left-color: var(--red-600); }
.stat-card.expense .stat-icon { background: rgba(181,72,42,0.12); color: var(--red-600); }

/* ---------- Dashboard hero ---------- */
.dash-hero {
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
  border-radius: var(--radius);
  padding: 24px 28px;
  color: #fff;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.dash-hero .greeting { font-family: 'Sora', sans-serif; font-size: 20px; font-weight: 600; }
.dash-hero .date { color: rgba(255,255,255,0.55); font-size: 13px; margin-top: 4px; }
.dash-hero .quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-hero .btn-gold { box-shadow: var(--shadow-sm); }

/* ---------- Dashboard two-column layout ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title-row h3 { display: flex; align-items: center; gap: 8px; }

.card-title-row .count-pill {
  background: var(--paper);
  color: var(--ink-600);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
}

/* ---------- Deltas & pipeline ---------- */
.delta {
  font-size: 11.5px;
  font-weight: 600;
  margin-top: 4px;
}

.delta-up { color: var(--green-600); }
.delta-down { color: var(--red-600); }

.pipeline-row { margin-bottom: 14px; }
.pipeline-row:last-child { margin-bottom: 0; }
.pipeline-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12.5px;
}

.pipeline-track {
  background: var(--paper);
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.pipeline-fill { height: 100%; border-radius: 999px; }
.pipeline-new { background: var(--ink-400); }
.pipeline-contacted { background: #2A5CAD; }
.pipeline-qualified, .pipeline-negotiation { background: var(--gold-500); }
.pipeline-won { background: var(--green-600); }
.pipeline-lost { background: var(--red-600); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-600);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13.5px;
}
tbody tr:hover { background: #FAFBFD; }
td.num, th.num { text-align: right; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: filter .15s ease, background .15s ease;
}

.btn-primary { background: var(--navy-900); color: #fff; }
.btn-primary:hover { filter: brightness(1.2); }
.btn-gold { background: var(--gold-500); color: #1A1400; }
.btn-gold:hover { background: var(--gold-600); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--ink-900); }
.btn-outline:hover { background: var(--paper); }
.btn-danger { background: #fff; border-color: var(--red-600); color: var(--red-600); }
.btn-danger:hover { background: var(--red-600); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 7px 9px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-600); margin-bottom: 6px; }
.form-group { margin-bottom: 16px; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--ink-900);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(201,163,78,0.15);
}

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 18px; }
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-new, .badge-draft { background: #EEF1F6; color: var(--ink-600); }
.badge-contacted, .badge-sent { background: #E7EEFB; color: #2A5CAD; }
.badge-qualified, .badge-partially_paid { background: #FBF1DC; color: var(--amber-600); }
.badge-negotiation { background: #F4E7D9; color: #A05A2C; }
.badge-won, .badge-paid, .badge-active, .badge-accepted, .badge-completed { background: #E4F1EC; color: var(--green-600); }
.badge-lost, .badge-overdue, .badge-cancelled, .badge-rejected, .badge-inactive { background: #FBE7E1; color: var(--red-600); }

/* ---------- Utility ---------- */
.flex { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.between { justify-content: space-between; }
.muted { color: var(--ink-600); }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-400); }
.empty-state .ico { font-size: 30px; margin-bottom: 10px; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

.alert-success { background: #E4F1EC; color: var(--green-600); }
.alert-error { background: #FBE7E1; color: var(--red-600); }

.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(14,21,38,0.45);
  z-index: 100;
  align-items: center; justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-md);
}

@media (max-width: 880px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
}