/* ==========================================================================
   Aventrix Digital — Quotation & Invoicing System
   Design tokens: deep navy + brand blue, Manrope (display) / IBM Plex Sans (body)
   ========================================================================== */

:root {
  --navy-950: #0a0f1e;
  --navy-900: #0f1e50;
  --navy-800: #16296b;
  --blue-600: #2554c7;
  --blue-500: #3b82f6;
  --blue-100: #dbe7ff;

  --slate-50:  #f5f7fa;
  --slate-100: #eef1f6;
  --slate-200: #e2e6ed;
  --slate-300: #cbd2dd;
  --slate-500: #6b7280;
  --slate-600: #4b5566;

  --ink-900: #10151f;

  --green-600: #16a34a;
  --green-100: #dcfce8;
  --red-600:   #dc2626;
  --red-100:   #fde3e3;
  --amber-600: #d97706;
  --amber-100: #fdf0d8;

  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(15, 30, 80, 0.04);

  --font-display: 'Manrope', 'Segoe UI', Arial, sans-serif;
  --font-body: 'IBM Plex Sans', 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink-900);
  background: var(--slate-50);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--navy-900);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
p { line-height: 1.55; }
.muted { color: var(--slate-500); }
.tabular { font-variant-numeric: tabular-nums; }

/* Focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Gradient accent — the one signature motif, used sparingly
   ========================================================================== */
.accent-bar {
  height: 4px;
  background: linear-gradient(90deg, var(--navy-900), var(--blue-500));
  border-radius: 2px;
}
.brand-gradient {
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--blue-600) 65%, var(--blue-500) 100%);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1.3;
  text-decoration: none !important;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--navy-900), var(--blue-600));
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
  background: #fff;
  border-color: var(--slate-300);
  color: var(--navy-900);
}
.btn-secondary:hover { background: var(--slate-100); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--slate-600); border-color: transparent; }
.btn-ghost:hover { background: var(--slate-100); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

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

.sidebar {
  width: 240px;
  flex: none;
  background: var(--navy-950);
  color: #cdd6ea;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand img { width: 30px; height: auto; flex: none; }
.sidebar-brand .name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14.5px;
  color: #fff;
  line-height: 1.15;
}
.sidebar-brand .name span { display: block; font-family: var(--font-body); font-weight: 500; font-size: 10.5px; color: #7f8bab; letter-spacing: 0.02em; }

.nav-group { padding: 14px 10px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #56618a; padding: 8px 12px 6px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #b7c1de;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  margin-bottom: 2px;
}
.nav-link svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-link:hover { background: rgba(255,255,255,0.05); color: #fff; text-decoration: none; }
.nav-link.active {
  background: rgba(59,130,246,0.14);
  color: #fff;
  border-left-color: var(--blue-500);
}
.sidebar-foot {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12.5px;
  color: #7f8bab;
}
.sidebar-foot a { color: #b7c1de; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  background: #fff;
  border-bottom: 1px solid var(--slate-200);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar .subtitle { font-size: 13px; color: var(--slate-500); margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.content { padding: 24px 28px 60px; max-width: 1180px; width: 100%; }

/* ==========================================================================
   Cards, tables, misc admin components
   ========================================================================== */
.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h3 { font-size: 15px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.stat-card .label { font-size: 12.5px; color: var(--slate-500); font-weight: 500; }
.stat-card .value { font-family: var(--font-display); font-size: 25px; font-weight: 800; color: var(--navy-900); margin-top: 4px; }
.stat-card .sub { font-size: 12px; color: var(--slate-500); margin-top: 3px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-500);
  font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--slate-200);
  white-space: nowrap;
}
table.data td {
  padding: 12px;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--slate-50); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--slate-500); }
.empty-state h3 { color: var(--ink-900); margin-bottom: 6px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  line-height: 1.6;
}
.badge-muted { background: var(--slate-100); color: var(--slate-600); }
.badge-info { background: var(--blue-100); color: var(--blue-600); }
.badge-success { background: var(--green-100); color: var(--green-600); }
.badge-warn { background: var(--amber-100); color: var(--amber-600); }
.badge-danger { background: var(--red-100); color: var(--red-600); }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-900);
  margin-bottom: 6px;
}
label .opt { font-weight: 400; color: var(--slate-500); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], input[type=url], select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink-900);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-500); }
.help-text { font-size: 12.5px; color: var(--slate-500); margin-top: 5px; }
.input-prefix { position: relative; }
.input-prefix .prefix { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--slate-500); font-size: 14px; }
.input-prefix input { padding-left: 34px; }
fieldset { border: 1px solid var(--slate-200); border-radius: var(--radius-md); padding: 16px; margin-bottom: 16px; }
legend { font-weight: 700; font-family: var(--font-display); color: var(--navy-900); padding: 0 6px; font-size: 14px; }

/* Line item editor */
.item-row { display: grid; grid-template-columns: 1fr 90px 130px 130px 32px; gap: 10px; align-items: start; margin-bottom: 10px; }
.item-row textarea { min-height: 44px; }
@media (max-width: 800px) { .item-row { grid-template-columns: 1fr; } }
.item-head { display: grid; grid-template-columns: 1fr 90px 130px 130px 32px; gap: 10px; font-size: 11.5px; text-transform: uppercase; color: var(--slate-500); margin-bottom: 6px; }
@media (max-width: 800px) { .item-head { display: none; } }
.icon-btn { border: none; background: transparent; color: var(--slate-500); cursor: pointer; padding: 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--red-100); color: var(--red-600); }

/* ==========================================================================
   Alerts / flash messages
   ========================================================================== */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--green-100); color: #14532d; border-color: #bbf0cf; }
.alert-error { background: var(--red-100); color: #7f1d1d; border-color: #f6c6c6; }
.alert-info { background: var(--blue-100); color: var(--navy-900); border-color: #c3d7fb; }

/* ==========================================================================
   Login page
   ========================================================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-950);
  background-image: radial-gradient(circle at 20% 20%, rgba(59,130,246,0.18), transparent 45%),
                     radial-gradient(circle at 80% 85%, rgba(37,84,199,0.22), transparent 40%);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 32px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.auth-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 22px; }
.auth-logo .emblem-badge { width: 52px; height: 52px; border-radius: 13px; background: var(--navy-900); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.auth-logo .emblem-badge img { width: 34px; }
.auth-logo .name { font-family: var(--font-display); font-weight: 800; font-size: 17px; color: var(--navy-900); letter-spacing: -0.01em; }
.auth-logo .tag { font-size: 12px; color: var(--slate-500); margin-top: 2px; }

/* ==========================================================================
   Public client-facing document pages (quotation / invoice / statement)
   ========================================================================== */
.doc-page {
  min-height: 100vh;
  background: var(--navy-950);
  background-image: radial-gradient(circle at 15% 10%, rgba(59,130,246,0.16), transparent 40%);
  padding: 40px 16px 70px;
}
.doc-wrap { max-width: 800px; margin: 0 auto; }
.doc-top-strip { display: flex; align-items: center; gap: 10px; color: #9fb1dc; font-size: 13px; margin-bottom: 18px; justify-content: center; }
.doc-top-strip img { width: 22px; }
.doc-paper {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.doc-header { padding: 30px 34px 22px; display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.doc-header .co { display: flex; gap: 12px; align-items: flex-start; }
.doc-header .emblem-badge { width: 44px; height: 44px; border-radius: 11px; background: var(--navy-900); display: flex; align-items: center; justify-content: center; flex: none; }
.doc-header .emblem-badge img { width: 28px; }
.doc-header .co-name { font-family: var(--font-display); font-weight: 800; font-size: 18px; color: var(--navy-900); }
.doc-header .co-addr { font-size: 12.5px; color: var(--slate-500); max-width: 280px; margin-top: 3px; }
.doc-header .doc-title { text-align: right; }
.doc-header .doc-title h2 { font-size: 24px; margin: 0; }
.doc-header .doc-title .num { color: var(--slate-500); font-size: 13px; margin-top: 2px; }
.doc-body { padding: 6px 34px 34px; }
.doc-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 18px 0 22px; }
@media (max-width: 560px) { .doc-meta-grid { grid-template-columns: 1fr; } }
.doc-meta-grid .eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--slate-500); font-weight: 600; margin-bottom: 6px; }
.doc-meta-grid .row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; }
.doc-meta-grid .row .k { color: var(--slate-500); }
.doc-meta-grid .row .v { font-weight: 600; }

table.doc-items { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.doc-items th {
  background: var(--navy-900);
  color: #fff;
  font-size: 12px;
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
}
table.doc-items th.num, table.doc-items td.num { text-align: right; }
table.doc-items td { padding: 11px 12px; font-size: 13.5px; border-bottom: 1px solid var(--slate-100); }
table.doc-items tr:nth-child(even) td { background: var(--slate-50); }

.doc-totals { margin-top: 14px; margin-left: auto; width: 280px; }
.doc-totals .row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 5px 0; }
.doc-totals .row.total { border-top: 2px solid var(--navy-900); margin-top: 6px; padding-top: 10px; font-family: var(--font-display); font-weight: 800; font-size: 17px; color: var(--navy-900); }
.doc-totals .row.balance .v { color: var(--red-600); font-weight: 700; }
.doc-totals .row.balance.zero .v { color: var(--green-600); }

.doc-section { margin-top: 24px; }
.doc-section .eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--slate-500); font-weight: 600; margin-bottom: 8px; }
.doc-section p { font-size: 13px; color: var(--slate-600); margin: 0 0 6px; }

.doc-actions { display: flex; gap: 12px; flex-wrap: wrap; padding: 22px 34px 30px; border-top: 1px solid var(--slate-200); background: var(--slate-50); }
.doc-status-banner { padding: 14px 34px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.doc-status-banner.success { background: var(--green-100); color: #14532d; }
.doc-status-banner.danger { background: var(--red-100); color: #7f1d1d; }
.doc-status-banner.info { background: var(--blue-100); color: var(--navy-900); }

.doc-footer-note { text-align: center; color: #6d7ba3; font-size: 12px; margin-top: 22px; }
.doc-footer-note a { color: #9fb1dc; }

/* Modal (lightweight, no JS framework) */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(10,15,30,0.55);
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 460px; padding: 22px; }
.modal h3 { margin-bottom: 4px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* Print styles: used both for admin "print preview" and the client-facing pages */
@media print {
  body { background: #fff !important; }
  .no-print { display: none !important; }
  .doc-page { background: #fff; padding: 0; }
  .doc-paper { box-shadow: none; border-radius: 0; }
  .doc-top-strip { display: none; }
  .sidebar, .topbar { display: none !important; }
  .content { padding: 0 !important; max-width: none !important; }
}
