:root {
  /* Shades of blue - brand chrome (header, buttons, links, focus) */
  --blue-950: #0b1526;
  --blue-900: #101b33;
  --blue-800: #17284a;
  --blue-700: #1e3868;
  --blue-600: #24478b;
  --blue-500: #2e5aac;
  --blue-400: #6685c4;
  --blue-100: #dce6f5;
  --blue-50: #f4f6fa;

  --navy: var(--blue-900);
  --navy-light: var(--blue-700);
  --accent: var(--blue-500);
  --accent-ink: #ffffff;

  --bg: var(--blue-50);
  --card: #ffffff;
  --border: #e3e7f0;
  --text: #142338;
  --muted: #647184;

  /* Status colors stay semantically distinct on purpose - they're read at a
     glance to tell pending/approved/rejected and baseline/amendment/addendum
     apart, which a single hue can't do as reliably. Danger reuses the logo
     red - kept sparing (critical/destructive states only) so it doesn't
     compete with the blue accent. */
  --danger: #c8102e;
  --success: #2e7d4f;
  --warning: #c7862b;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--blue-600); text-decoration: none; transition: color 120ms ease; }
a:hover { color: var(--blue-700); text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: linear-gradient(180deg, var(--blue-950), var(--blue-900));
  color: #fff;
  padding: 10px 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; line-height: 1.15; }
.brand-mark {
  height: 36px;
  width: auto;
  border-radius: 5px;
  background: #fff;
  padding: 2px;
}
.brand-name { display: flex; flex-direction: column; }
.brand-company { font-size: 11px; font-weight: 700; letter-spacing: .4px; color: var(--blue-100); text-transform: uppercase; }
.brand-suite { font-size: 13px; color: #fff; }

.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a {
  color: #c8d9f0;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color 150ms ease, background-color 150ms ease;
}
.mainnav a:hover { color: #fff; background: rgba(255,255,255,0.08); text-decoration: none; }

.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-role { background: rgba(255,255,255,0.15); padding: 2px 8px; border-radius: 10px; }
.logout-link { color: #f0c9c9; transition: color 150ms ease; }
.logout-link:hover { color: #ffdede; }

.content { max-width: 1200px; margin: 0 auto; padding: 20px; }

.app-footer {
  text-align: center;
  padding: 16px 20px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

.flash-stack { margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  animation: flash-in 220ms var(--ease-out);
}
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.flash-danger { background: #fdecea; color: var(--danger); border: 1px solid #f3c2be; }
.flash-success { background: #e9f7ee; color: var(--success); border: 1px solid #b9e6c6; }
.flash-warning { background: #fdf4e3; color: var(--warning); border: 1px solid #f0d9a0; }
.flash-info { background: var(--blue-100); color: var(--blue-700); border: 1px solid #c6dbf2; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h2, .card h3 { margin-top: 0; }

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform 160ms var(--ease-out), box-shadow 160ms ease, border-color 160ms ease;
}
.card-link:hover {
  text-decoration: none;
  border-color: var(--blue-400);
  box-shadow: 0 4px 14px rgba(15, 60, 110, 0.1);
  transform: translateY(-2px);
}
.card-link:active { transform: translateY(-1px) scale(0.99); }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { margin: 0; font-size: 22px; color: var(--blue-900); }
.subtitle { color: var(--muted); font-size: 13px; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--blue-50); color: var(--blue-800); font-weight: 600; }
tbody tr { transition: background-color 120ms ease; }
tbody tr:hover { background: var(--blue-50); }
tr.section-row td { background: #eef3fb; font-weight: 700; color: var(--blue-800); }
tr.section-row:hover td { background: #eef3fb; }
tr.subtotal-row td { font-weight: 700; border-top: 2px solid var(--border); }
.num { text-align: right; white-space: nowrap; }

.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 6px;
  background: var(--blue-900);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 13px;
  transition: transform 160ms var(--ease-out), background-color 150ms ease;
}
.btn:hover { background: var(--blue-700); text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn-accent { background: var(--blue-500); color: #fff; font-weight: 600; }
.btn-accent:hover { background: var(--blue-600); }
.btn-danger { background: var(--danger); }
.btn-outline { background: transparent; color: var(--blue-800); border: 1px solid var(--blue-700); }
.btn-outline:hover { background: var(--blue-50); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.im-picker-cell { position: relative; min-width: 260px; }
.im-picker-cell .im-search { width: 100%; box-sizing: border-box; }
.im-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--blue-400);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(11, 21, 38, 0.18);
}
.im-result-row { padding: 6px 10px; font-size: 13px; cursor: pointer; }
.im-result-row:hover { background: var(--blue-50); }
.im-result-empty { cursor: default; color: var(--muted); font-style: italic; }
.im-result-empty:hover { background: transparent; }

form.inline { display: inline; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 20px; }
.form-grid.cols-1 { grid-template-columns: 1fr; max-width: 360px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}
.field textarea { resize: vertical; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.badge-pending { background: #fdf4e3; color: var(--warning); }
.badge-approved { background: #e9f7ee; color: var(--success); }
.badge-rejected { background: #fdecea; color: var(--danger); }
.badge-baseline { background: var(--blue-100); color: var(--blue-700); }
.badge-addendum { background: #eef1fb; color: #3d4fa8; }
.badge-amendment { background: #e6f3fb; color: #0e6ba8; }
.badge-cancelled { background: #eceef1; color: var(--muted); }
.badge-accent { background: var(--blue-500); color: #fff; }

.diff-add { background: #e9f7ee; }
.diff-remove { background: #fdecea; text-decoration: line-through; color: #8a8f94; }
.diff-change { background: #fdf4e3; }

.grid-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue-500);
  border-radius: 8px;
  padding: 14px 16px;
}
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; color: var(--blue-900); }
.stat .value.good { color: var(--success); }
.stat .value.bad { color: var(--danger); }

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding-top: 14px;
  margin-top: -14px;
}

.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; border-radius: 6px 6px 0 0; color: var(--muted); transition: color 150ms ease, background-color 150ms ease; }
.tabs a:hover { background: var(--blue-50); text-decoration: none; }
.tabs a.active { background: var(--card); border: 1px solid var(--border); border-bottom-color: var(--card); color: var(--blue-800); font-weight: 600; margin-bottom: -1px; }

.print-sheet { background: #fff; padding: 20px; }
.print-sheet .letterhead { text-align: center; margin-bottom: 16px; }
.print-sheet .letterhead h1 { margin: 0; font-size: 18px; color: var(--blue-900); }
.print-sheet .meta-table td { border: none; padding: 2px 4px; }
.signatures { display: flex; justify-content: space-between; margin-top: 40px; }
.signatures .sig { text-align: center; width: 30%; border-top: 1px solid #000; padding-top: 4px; font-size: 12px; }

.empty-state { color: var(--muted); padding: 30px 0; text-align: center; }

.dal-print .weather-block { display: flex; align-items: center; gap: 24px; margin-bottom: 16px; }
.weather-wheel-wrap { position: relative; width: 150px; height: 150px; flex: 0 0 auto; }
.weather-wheel { position: relative; width: 150px; height: 150px; border-radius: 50%; border: 1px solid #333; }
.wheel-label { position: absolute; font-size: 10px; font-weight: 600; color: #222; }
.wheel-top { top: -16px; left: 50%; transform: translateX(-50%); }
.wheel-bottom { bottom: -16px; left: 50%; transform: translateX(-50%); }
.wheel-left { left: -46px; top: 50%; transform: translateY(-50%); }
.wheel-right { right: -46px; top: 50%; transform: translateY(-50%); }
.weather-legend { font-size: 12px; }
.legend-row { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.legend-swatch { display: inline-block; width: 14px; height: 14px; border: 1px solid #999; }

.dal-print .dal-cols { display: flex; gap: 14px; align-items: flex-start; }
.dal-print .dal-col { flex: 1; min-width: 0; }
.dal-print .dal-fixed-table, .dal-print .dal-checklist-table { font-size: 11px; table-layout: fixed; width: 100%; }
.dal-print .dal-fixed-table th, .dal-print .dal-fixed-table td,
.dal-print .dal-checklist-table th, .dal-print .dal-checklist-table td { padding: 3px 6px; overflow-wrap: break-word; word-break: break-word; }
.dal-print .dal-fixed-table td:first-child, .dal-print .dal-fixed-table th:first-child { width: 46%; }
.dal-print .dal-checklist-table td:nth-child(2), .dal-print .dal-checklist-table th:nth-child(2) { width: 34%; }
.dal-print .total-row td { font-weight: 700; background: var(--blue-50); }
.dal-print .sig-role { font-weight: 400; color: var(--muted); font-size: 11px; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 21, 38, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--card);
  border-radius: 10px;
  padding: 20px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(11, 21, 38, 0.35);
}
.modal-box h3 { margin-top: 0; }

.reveal {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  overflow: hidden;
  transition: grid-template-rows 220ms var(--ease-in-out), opacity 180ms ease;
}
.reveal.open { grid-template-rows: 1fr; opacity: 1; }
.reveal > * { min-height: 0; }
.hidden { display: none; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .content { max-width: none; padding: 0; }
  .card { border: none; padding: 0; }
}
