:root {
  --sidebar-w: 240px;
  --brand: #0b5ed7;
  --brand-dark: #084298;
  --accent: #6366f1;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e4e8ee;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #ca8a04;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow: 0 4px 14px rgba(15,23,42,.06);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0b1220 0%, #111a2e 100%);
  color: #cbd5e1;
  flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
  border-right: 1px solid #1e293b;
}
.sidebar .brand {
  padding: 18px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar .brand i { color: #60a5fa; font-size: 1.4rem; }
.sidebar .nav-section {
  color: #64748b;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 18px 20px 6px;
  font-weight: 600;
}
.sidebar .nav-link {
  color: #94a3b8;
  padding: 9px 20px;
  font-size: 0.9rem;
  display: flex; align-items: center; gap: 10px;
  border-left: 3px solid transparent;
  transition: all 0.12s;
  font-weight: 500;
}
.sidebar .nav-link:hover {
  background: rgba(255,255,255,0.04);
  color: #fff;
}
.sidebar .nav-link.active {
  background: linear-gradient(90deg, rgba(96,165,250,0.15), transparent);
  color: #fff;
  border-left-color: #60a5fa;
}
.sidebar .nav-link i { width: 20px; text-align: center; color: inherit; opacity: 0.9; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--surface);
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 10;
  box-shadow: var(--shadow-sm);
}
.topbar h5 { font-weight: 600; font-size: 1.05rem; }

.content { padding: 24px; max-width: 1500px; width: 100%; }

/* KPI cards */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-card .icon {
  width: 50px; height: 50px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff; flex-shrink: 0;
}
.kpi-card .label { color: var(--muted); font-size: 0.8rem; margin: 0; font-weight: 500; }
.kpi-card .value { font-size: 1.5rem; font-weight: 700; margin: 0; line-height: 1.2; letter-spacing: -0.5px; }

/* Cards */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  padding: 14px 18px;
}
.card-body { padding: 18px; }

/* Tables */
.table { color: var(--text); }
.table thead th {
  background: #f8fafc;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table td, .table th { vertical-align: middle; padding: 10px 12px; }
.table-hover tbody tr:hover { background: #f8fafc; }

.badge { font-weight: 500; padding: 5px 9px; font-size: 0.72rem; letter-spacing: 0.3px; }

/* Buttons */
.btn { font-weight: 500; font-size: 0.88rem; border-radius: 7px; padding: 7px 14px; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-lg { padding: 10px 18px; font-size: 0.95rem; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* Forms */
.form-control, .form-select { border-radius: 7px; border-color: var(--border); font-size: 0.9rem; padding: 7px 11px; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,94,215,0.12); }
.form-label { font-weight: 500; font-size: 0.83rem; color: #334155; margin-bottom: 5px; }

/* Tabs */
.nav-tabs .nav-link { color: var(--muted); border: 0; padding: 10px 16px; font-weight: 500; }
.nav-tabs .nav-link.active { color: var(--brand); background: transparent; border-bottom: 2px solid var(--brand); }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0b1220 0%, #1e3a8a 60%, #312e81 100%);
  font-family: 'Inter', sans-serif;
}
.login-card {
  background: #fff; padding: 38px; border-radius: 14px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-card .brand {
  text-align: center; margin-bottom: 6px;
  font-size: 1.7rem; font-weight: 800;
  letter-spacing: -0.5px;
}
.login-card .brand i { color: var(--brand); }

/* Document view (quotation/invoice/shipment printable) */
.doc-page {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 48px;
  box-shadow: var(--shadow-sm);
  max-width: 980px;
  margin: 0 auto;
}
.doc-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 22px; margin-bottom: 22px;
  border-bottom: 2px solid var(--brand);
}
.doc-title { font-size: 2rem; font-weight: 800; color: var(--brand); margin: 0; letter-spacing: -0.5px; }
.doc-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; font-weight: 600; }
.doc-value { font-size: 0.95rem; }
.doc-section { margin-bottom: 22px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 20px 0; }
.doc-table th { background: #f1f5f9; padding: 10px 12px; text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; color: #475569; border-bottom: 2px solid var(--brand); }
.doc-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.doc-footer { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 0.82rem; color: var(--muted); }
.doc-footer h6 { color: var(--text); font-weight: 600; margin-bottom: 6px; }
.doc-totals { margin-left: auto; width: 350px; }
.doc-totals .row { display: flex; justify-content: space-between; padding: 6px 0; }
.doc-totals .grand { border-top: 2px solid var(--text); font-weight: 700; font-size: 1.1rem; padding-top: 10px; margin-top: 6px; }

/* Toolbar */
.page-toolbar { display:flex; flex-wrap:wrap; justify-content:space-between; gap:12px; margin-bottom:16px; align-items:center; }

/* Empty state */
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-state i { font-size: 3rem; opacity: 0.3; margin-bottom: 10px; display: block; }

/* Stamp */
.doc-status-stamp {
  position: absolute;
  top: 70px; right: 60px;
  border: 3px solid currentColor;
  padding: 6px 20px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  transform: rotate(-12deg);
  opacity: 0.75;
}
.stamp-paid { color: #16a34a; }
.stamp-overdue { color: #dc2626; }
.stamp-draft { color: #64748b; }
.stamp-cancelled { color: #dc2626; }

@media (max-width: 768px) {
  .sidebar { position: fixed; left: -260px; z-index: 1000; transition: left 0.2s; }
  body.sidebar-open .sidebar { left: 0; }
  .doc-page { padding: 20px; }
}
