/* ── Reset / Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --hero:    #062650;
  --red:     #E8000D;
  --yellow:  #FEF33C;
  --orange:  #FF6400;
  --blue:    #1060C8;
  --ui-navy: #1A2A3A;
  --border:  #d1dbe8;
  --light:   #f0f4f8;
  --muted:   #4A5568;
  --text:    #0D1B2A;
  --white:   #ffffff;
  --green:   #16a34a;
  --shadow:  0 1px 4px rgba(6,38,80,0.1);
}
html { font-size: 15px; }
body {
  font-family: 'Work Sans', 'Outfit', sans-serif;
  background: var(--light);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
.portal-nav {
  background: var(--hero);
  height: 56px;
  border-bottom: 4px solid;
  border-image: linear-gradient(90deg, var(--yellow), var(--orange), var(--red)) 1;
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  width: 100%;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-logo { height: 28px; filter: brightness(0) invert(1); display: block; }
.nav-brand-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
.nav-logo-accent {
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, var(--yellow) 0%, var(--orange) 55%, var(--red) 100%);
  border-radius: 2px;
}
.nav-label {
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.nav-links { display: flex; gap: 4px; flex: 1; min-width: 0; margin-right: 8px; }
.nav-link {
  color: rgba(255,255,255,0.75);
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  text-decoration: none;
}
.nav-user { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.nav-username { color: rgba(255,255,255,0.65); font-size: 13px; }
@media (max-width: 1600px) { .nav-username { display: none; } }
.nav-logout { display: none; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--red);  color: #fff; border-color: var(--red); }
.btn-primary:hover { background: #c0000b; border-color: #c0000b; }
.btn-secondary { background: #fff; color: var(--ui-navy); border-color: var(--border); }
.btn-secondary:hover { background: var(--light); }
.btn-ghost     { background: transparent; color: rgba(255,255,255,0.8); border-color: rgba(255,255,255,0.3); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-lg        { padding: 12px 28px; font-size: 15px; }
.btn-sm        { padding: 5px 12px; font-size: 13px; }
.btn-link      { background: none; border: none; color: var(--blue); padding: 0; cursor: pointer; font-size: 13px; }
.btn-link.danger { color: var(--red); }
.btn-link:hover { text-decoration: underline; }
.w-full { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Main layout ──────────────────────────────────────────────────────────── */
.main-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.main-wide { max-width: 1100px; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--hero); }
.page-sub   { margin-top: 4px; display: flex; align-items: center; gap: 8px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafbfd;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--hero); letter-spacing: 0.3px; }
.card-hint  { font-size: 12px; color: var(--muted); }
.card-body  { padding: 20px; }
.card-body.p0 { padding: 0; }

/* ── Form grid ────────────────────────────────────────────────────────────── */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .form-grid-2 { grid-template-columns: 1fr; } }

/* ── Form elements ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: 14px;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(16,96,200,0.1);
}
textarea.form-input { resize: vertical; }
.form-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: var(--white);
  font-size: 14px;
  cursor: pointer;
}
.form-select:focus { outline: none; border-color: var(--blue); }
.form-select-sm { padding: 5px 10px; font-size: 13px; }
.form-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; display: block; }
.req { color: var(--red); }
.check-group { display: flex; align-items: center; gap: 8px; }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: capitalize;
}
.badge-draft     { background: #e2e8f0; color: #475569; }
.badge-sent      { background: #dbeafe; color: #1d4ed8; }
.badge-accepted  { background: #dcfce7; color: #15803d; }
.badge-expired   { background: #fee2e2; color: #b91c1c; }
.badge-cancelled { background: #f1f5f9; color: #64748b; text-decoration: line-through; }
.badge-declined  { background: #fef2f2; color: #991b1b; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table th {
  background: #f1f5f9;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 8px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #edf0f5;
  vertical-align: top;
}
.data-table tbody tr:hover td { background: #fafbfd; }
.ref-link { font-weight: 700; color: var(--hero); font-size: 13px; letter-spacing: 0.3px; }
.ref-link:hover { color: var(--red); }

/* items view table (narrower padding) */
.items-view-table th, .items-view-table td { padding: 6px 14px; }
.items-view-table .subtotal-row td { font-weight: 700; background: var(--light) !important; border-top: 2px solid var(--border); }

/* ── Section header row (in tables/sections) ──────────────────────────────── */
.section-header-row {
  background: var(--ui-navy);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 14px;
}

/* ── Line items editor ────────────────────────────────────────────────────── */
.items-editor-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.items-editor {
  width: 100%;
  min-width: 580px;
  border-collapse: collapse;
  font-size: 13.5px;
  table-layout: fixed;
}
.items-editor colgroup col.col-desc  { width: auto; }
.items-editor colgroup col.col-qty   { width: 70px; }
.items-editor colgroup col.col-price { width: 130px; }
.items-editor colgroup col.col-total { width: 120px; }
.items-editor colgroup col.col-del   { width: 38px; }
.items-editor th {
  background: #f1f5f9;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.items-editor th.th-qty   { text-align: center; }
.items-editor th.th-price, .items-editor th.th-total { text-align: right; }
.items-editor td {
  padding: 3px 4px;
  border-bottom: 1px solid #edf0f5;
  vertical-align: middle;
}
.items-editor tr:hover td { background: #f8faff; }

/* Input cells */
.i-desc, .i-qty, .i-price {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: transparent;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text);
  box-sizing: border-box;
}
.i-desc:hover, .i-qty:hover, .i-price:hover {
  border-color: var(--border);
  background: #fff;
}
.i-desc:focus, .i-qty:focus, .i-price:focus {
  outline: none;
  border-color: var(--blue);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(16,96,200,0.1);
}
.i-qty   { text-align: center; }
.i-price { text-align: right; }
.i-total {
  text-align: right;
  font-weight: 600;
  color: var(--hero);
  padding: 5px 10px;
  white-space: nowrap;
}
.del-row {
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  display: block;
  margin: 0 auto;
}
.del-row:hover { color: var(--red); background: #fff1f1; }
@media (max-width: 700px) {
  .i-desc, .i-qty, .i-price { min-height: 38px; font-size: 15px; border-color: var(--border); background: #fff; }
  .items-editor td { padding: 2px 2px; }
}

/* Add row + subtotal */
.add-row-cell { padding: 7px 10px; }
.add-row-btn {
  background: none;
  border: 1.5px dashed var(--border);
  color: var(--blue);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.add-row-btn:hover { border-color: var(--blue); color: #0748a0; }
.subtotal-row td {
  background: #f8fafc;
  font-weight: 700;
  border-top: 2px solid var(--border);
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--hero);
}
.subtotal-row td:last-child, .subtotal-row td:nth-last-child(2) { text-align: right; }

/* ── Totals bar ───────────────────────────────────────────────────────────── */
.totals-bar {
  margin-top: 20px;
  background: var(--hero);
  border-radius: 8px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  color: #fff;
}
.totals-breakdown { display: flex; gap: 20px; flex: 1; flex-wrap: wrap; font-size: 13px; color: rgba(255,255,255,0.7); }
.totals-breakdown strong { color: #fff; }
.grand-total-display { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.grand-total-display strong { color: var(--yellow); font-size: 22px; }

/* ── Grand total row (view page) ──────────────────────────────────────────── */
.grand-total-row {
  background: var(--hero);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}
.grand-total-amt { font-size: 18px; }

/* ── Detail view rows ─────────────────────────────────────────────────────── */
.detail-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #edf0f5;
  font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.detail-value.strong { font-weight: 700; font-size: 16px; color: var(--hero); }
.accept-highlight .detail-label, .accept-highlight .detail-value { color: #15803d; }
.accept-highlight { background: #f0fdf4; padding: 8px; border-radius: 4px; margin-top: 4px; }

/* ── Action strip ─────────────────────────────────────────────────────────── */
.action-strip {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.inline-form { display: flex; gap: 6px; align-items: center; }
.copy-link-wrap { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 260px; }
.copy-label { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.copy-input {
  flex: 1;
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted);
  background: #f8fafc;
}

/* ── Stats grid (dashboard) ───────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 700px) {
  .stat-grid { grid-template-columns: 1fr !important; gap: 8px; margin-bottom: 12px; }
  .stat-card { padding: 10px 14px; display: flex; align-items: center; gap: 14px; }
  .stat-value { font-size: 22px; line-height: 1; min-width: 44px; }
  .stat-label { font-size: 12px; margin-top: 0; }
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  border-left: 4px solid var(--hero);
  box-shadow: var(--shadow);
  display: block;
  color: inherit;
  transition: box-shadow .15s, transform .15s;
}
a.stat-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  transform: translateY(-2px);
  cursor: pointer;
}
.stat-sent     { border-left-color: var(--blue); }
.stat-accepted { border-left-color: var(--green); }
.stat-expired  { border-left-color: var(--red); }
.stat-value    { font-size: 30px; font-weight: 700; color: var(--hero); line-height: 1; }
.stat-label    { font-size: 12px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); margin-top: 6px; }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.filter-bar { margin-bottom: 16px; }
.filter-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-search { max-width: 280px; }

/* ── Row actions ──────────────────────────────────────────────────────────── */
.row-actions { display: flex; gap: 10px; align-items: center; }

/* ── Auth pages ───────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--hero) 0%, #1A2A3A 100%);
  padding: 24px;
}
.auth-card {
  background: var(--white);
  border-radius: 10px;
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(6,38,80,0.25);
}
.auth-logo { text-align: center; margin-bottom: 20px; }
.auth-logo img { height: 48px; }
.auth-title { font-size: 19px; font-weight: 700; color: var(--hero); margin-bottom: 16px; text-align: center; }
.auth-sub   { font-size: 13.5px; color: var(--muted); text-align: center; margin-bottom: 16px; }

/* ── Text helpers ─────────────────────────────────────────────────────────── */
.text-muted { color: var(--muted); }
.text-sm    { font-size: 12.5px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-mono  { font-variant-numeric: tabular-nums; }
.mono       { font-variant-numeric: tabular-nums; }
.link-sm    { font-size: 13px; color: var(--blue); }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* ── Nav responsive ──────────────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: 8px;
  flex-shrink: 0;
}
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: rgba(255,255,255,0.85);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Compact nav at medium desktop widths — prevents overflow with many links */
@media (max-width: 1600px) {
  .nav-link { padding: 5px 10px; font-size: 13px; }
  .nav-inner { gap: 10px; }
}
@media (max-width: 1400px) {
  .nav-link { padding: 5px 8px; font-size: 12.5px; }
  .nav-inner { gap: 6px; padding: 0 16px; }
}
@media (max-width: 1280px) {
  .nav-link { padding: 4px 6px; font-size: 12px; }
  .nav-inner { gap: 4px; padding: 0 12px; }
}

/* Hamburger nav — tablets and mobile */
@media (max-width: 1180px) {
  .nav-hamburger { display: flex; }
  .nav-user { display: none; }
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0; right: 0;
    background: var(--hero);
    border-top: 2px solid rgba(255,255,255,0.1);
    padding: 10px 16px 16px;
    gap: 2px;
    z-index: 99;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-links.open { display: flex; }
  .nav-logout { display: block; }
  .nav-links .nav-link {
    padding: 10px 14px;
    font-size: 15px;
  }
  .nav-links .nav-username-mobile {
    color: rgba(255,255,255,0.5);
    font-size: 12px;
    padding: 8px 14px 4px;
  }
  .nav-inner { position: relative; gap: 8px; }
  .main-wrap { padding: 16px 14px 40px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .hide-mobile { display: none !important; }
  .card { overflow-x: auto; }
}


