:root {
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-900: #1e3a8a;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-500: #64748b;
  --slate-700: #334155;
  --slate-900: #0f172a;
  --white: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Arial, sans-serif;
  background: var(--slate-50);
  color: var(--slate-900);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--white);
  border-right: 1px solid var(--slate-200);
  box-shadow: 2px 0 8px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--slate-100);
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-logo {
  height: 36px;
  max-width: 140px;
  object-fit: contain;
  border-radius: 6px;
}
.brand-initials {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--blue-600);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-nav { flex: 1; padding: 8px 0; }

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--slate-400);
  padding: 16px 16px 4px;
}

.nav-item {
  display: block;
  padding: 8px 16px;
  margin: 1px 8px;
  border-radius: 6px;
  color: var(--slate-600);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--slate-50); color: var(--blue-600); }
.nav-item.active {
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--slate-100);
  font-size: 12px;
}
.sidebar-user { display: flex; align-items: center; justify-content: space-between; color: var(--slate-600); }
.sidebar-user a { color: var(--slate-400); text-decoration: none; font-size: 12px; }
.sidebar-user a:hover { color: var(--danger); }

/* ---------- Content area ---------- */
.app-content { margin-left: 200px; flex: 1; min-width: 0; }

.container { max-width: 1100px; margin: 32px auto; padding: 0 32px; }

/* ---------- Typography ---------- */
h1 { font-size: 22px; font-weight: 600; margin: 0 0 20px; letter-spacing: -.01em; }
h2 { font-size: 14px; font-weight: 600; margin: 0 0 16px; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-700); }
label { display: block; font-size: 11px; color: var(--slate-500); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
small { color: var(--slate-500); font-size: 12px; }

/* ---------- Cards / layout ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
}
.row { display: flex; gap: 18px; flex-wrap: wrap; }
.col { flex: 1; min-width: 200px; }

/* ---------- Forms ---------- */
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--slate-300);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--slate-900);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}
textarea { min-height: 80px; resize: vertical; }

button, .btn {
  background: var(--blue-600);
  color: var(--white);
  border: 0;
  padding: 9px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  transition: background .15s;
}
button:hover, .btn:hover { background: var(--blue-700); }
.btn.secondary { background: var(--slate-100); color: var(--slate-700); border: 1px solid var(--slate-200); }
.btn.secondary:hover { background: var(--slate-200); }
.btn.danger { background: var(--white); color: var(--danger); border: 1px solid var(--slate-200); padding: 6px 10px; font-size: 12px; }
.btn.danger:hover { background: #fef2f2; }

/* Hide number input spinner arrows */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* Action cells: uniform compact chip buttons */
td.actions { white-space: nowrap; }
td.actions a, td.actions button.btn {
  display: inline-block;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  border: 1px solid var(--slate-200);
  background: var(--white);
  color: var(--slate-700);
  text-decoration: none;
  margin: 0 2px 0 0;
  cursor: pointer;
  line-height: 1.3;
}
td.actions a:hover, td.actions button.btn.secondary:hover { background: var(--slate-100); color: var(--blue-700); border-color: var(--slate-300); }
td.actions button.btn.danger { color: var(--danger); }
td.actions button.btn.danger:hover { background: #fef2f2; }
td.actions form { display: inline; margin: 0; padding: 0; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--slate-200); text-align: left; vertical-align: top; }
th {
  background: var(--slate-50);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--slate-500);
  font-weight: 600;
}
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--blue-100);
  color: var(--blue-700);
}
.badge.sent { background: #dcfce7; color: #166534; }
.badge.accepted { background: #dcfce7; color: #166534; }
.badge.draft { background: #fef3c7; color: #92400e; }
.badge.rejected { background: #fee2e2; color: #991b1b; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 6px; background: #ecfdf5; color: #065f46; margin-bottom: 18px; font-size: 13px; border: 1px solid #a7f3d0; }
.flash.err { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* ---------- Totals box ---------- */
.totals { width: 340px; margin-left: auto; }
.totals td { padding: 8px 12px; border: 0; }
.totals tr td:first-child { color: var(--slate-500); font-size: 12px; }
.totals tr.grand td { font-weight: 700; font-size: 15px; color: var(--blue-700); border-top: 2px solid var(--blue-600); padding-top: 12px; }

/* ---------- Dashboard stat cards ---------- */
.stat { padding: 20px; }
.stat label { font-size: 11px; }
.stat .value { font-size: 26px; font-weight: 700; color: var(--blue-700); margin-top: 4px; }

/* ---------- Quotation Document ---------- */
.quote-doc,
.quote-doc * {
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
  color-adjust: exact !important;
}
.quote-doc {
  background: var(--white);
  padding: 28px 36px;
  max-width: 820px;
  margin: 20px auto;
  border: 1px solid var(--slate-200);
  border-radius: 4px;
}

/* Header: company on left, QUOTATION title on right */
.quote-doc .qhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  border-bottom: 2px solid var(--blue-600);
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.quote-doc .qhead .left { flex: 1; min-width: 0; }
.quote-doc .qhead .left img { max-height: 36px; margin: 0 0 6px -6px; display: block; }
.quote-doc .qhead .left .company { font-size: 16px; font-weight: 700; color: var(--slate-900); line-height: 1.2; }
.quote-doc .qhead .left .company-info {
  font-size: 11px;
  color: var(--slate-500);
  margin-top: 4px;
  line-height: 1.5;
}
.quote-doc .qhead .right { text-align: right; flex-shrink: 0; }
.quote-doc .qhead .right h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue-700);
  letter-spacing: .04em;
  margin: 0;
  line-height: 1;
}
.quote-doc .qhead .right .qno {
  font-size: 12px;
  color: var(--slate-700);
  font-weight: 600;
  margin-top: 4px;
}

/* Meta strip (date, valid till, ref, prepared by) */
.quote-doc .meta-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 4px;
  margin-bottom: 12px;
}
.quote-doc .meta-strip .cell { padding: 6px 10px; border-right: 1px solid var(--slate-200); }
.quote-doc .meta-strip .cell:last-child { border-right: 0; }
.quote-doc .meta-strip .cell .k { font-size: 9px; text-transform: uppercase; color: var(--slate-500); letter-spacing: .05em; font-weight: 600; }
.quote-doc .meta-strip .cell .v { font-size: 12px; font-weight: 600; color: var(--slate-900); margin-top: 1px; }

/* Bill-to / supply boxes */
.quote-doc .qmeta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.quote-doc .qmeta-grid .box {
  background: var(--blue-50);
  border-left: 3px solid var(--blue-600);
  padding: 8px 12px;
  border-radius: 4px;
}
.quote-doc .qmeta-grid .box .boxlabel {
  font-size: 9px; color: var(--blue-700); font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px;
}
.quote-doc .qmeta-grid .box .name { font-weight: 700; font-size: 13px; color: var(--slate-900); margin-bottom: 2px; }
.quote-doc .qmeta-grid .box .info { font-size: 11px; color: var(--slate-700); line-height: 1.5; }

.quote-doc .subject {
  background: var(--blue-50);
  padding: 6px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 12px;
}
.quote-doc .subject .k { color: var(--blue-700); font-weight: 700; margin-right: 6px; }

/* Items table — compact */
.quote-doc table { margin-bottom: 0; }
.quote-doc table thead th {
  background: var(--blue-600);
  color: var(--white);
  font-size: 10px;
  padding: 7px 10px;
  border-bottom: 0;
}
.quote-doc table tbody td { border-bottom: 1px solid var(--slate-200); font-size: 12px; padding: 7px 10px; }
.quote-doc table tbody tr:nth-child(even) td { background: var(--slate-50); }

/* Totals */
.quote-doc .totals { margin-top: 6px; }
.quote-doc .totals td { padding: 4px 10px; font-size: 12px; }
.quote-doc .totals tr.grand td { padding: 8px 10px; }

.quote-doc .amount-words {
  background: var(--blue-50);
  border: 1px dashed var(--blue-500);
  border-radius: 4px;
  padding: 6px 12px;
  margin: 10px 0;
  font-size: 12px;
}
.quote-doc .amount-words .k { font-weight: 700; color: var(--blue-700); margin-right: 6px; }

.quote-doc .section { margin-top: 12px; }
.quote-doc .section h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--blue-700);
  margin: 0 0 4px;
  font-weight: 700;
  border-bottom: 1px solid var(--slate-200);
  padding-bottom: 3px;
}
.quote-doc .section .body { font-size: 12px; color: var(--slate-700); line-height: 1.55; }

.quote-doc .footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 28px;
  border-top: 1px solid var(--slate-200);
  padding-top: 16px;
}
.quote-doc .footer-grid .client-sig { text-align: left; }
.quote-doc .footer-grid .signature  { text-align: right; }
.quote-doc .footer-grid .signature .sigbox,
.quote-doc .footer-grid .client-sig .sigbox {
  margin-top: 48px;
  border-top: 1px solid var(--slate-900);
  padding-top: 5px;
  font-size: 11px;
  display: inline-block;
  min-width: 200px;
  font-weight: 600;
}
.quote-doc .thanks {
  text-align: center;
  margin-top: 10px;
  font-size: 11px;
  color: var(--blue-700);
  font-weight: 600;
}

@page {
  size: A4;
  margin: 10mm;
}
@media print {
  .sidebar, .no-print { display: none !important; }
  .app-content { margin-left: 0 !important; }
  html, body { background: var(--white); margin: 0; padding: 0; }
  .container, .quote-doc { box-shadow: none; margin: 0; padding: 0; max-width: 100%; border: 0; }
  .quote-doc { padding: 0; }
  .quote-doc table tbody tr:nth-child(even) td { background: transparent; }
}
