:root {
  --navy: #102a43;
  --navy-2: #173f66;
  --blue: #1677ff;
  --sky: #eaf3ff;
  --ink: #14212b;
  --muted: #66788a;
  --line: #dbe4ec;
  --canvas: #f4f7fa;
  --white: #fff;
  --good: #17824b;
  --warning: #ad6b00;
  --danger: #b42318;
  --alert: #b54708;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
.topbar {
  min-height: 72px; display: flex; align-items: center; gap: 34px;
  padding: 0 28px; color: white; background: var(--navy);
  position: sticky; top: 0; z-index: 20; box-shadow: 0 4px 18px #102a4322;
}
.brand { display: flex; align-items: center; gap: 12px; color: white; min-width: 260px; }
.brand-logo { width: 142px; height: auto; display: block; }
.brand strong, .brand small { display: block; }
.brand small { color: #b9d2e8; margin-top: 2px; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; background: linear-gradient(135deg, #28a1ff, #1761c8);
  color: white; font-weight: 800; letter-spacing: -.03em;
}
.brand-mark-large { width: 54px; height: 54px; border-radius: 14px; font-size: 20px; }
nav { display: flex; gap: 10px; flex: 1; }
nav a { color: #d9e8f5; padding: 10px 12px; border-radius: 8px; }
nav a:hover { background: #ffffff14; color: white; }
.user-menu { display: flex; align-items: center; gap: 16px; color: #d9e8f5; font-size: 14px; }
.user-menu form, .actions form { display: inline; }
.page { max-width: 1660px; margin: 0 auto; padding: 30px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 24px; }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(28px, 3vw, 40px); letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 19px; }
.page-heading p { color: var(--muted); margin-bottom: 0; }
.eyebrow { color: var(--blue) !important; text-transform: uppercase; letter-spacing: .13em; font-size: 12px; font-weight: 800; }
.date-filter label { color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%; border: 1px solid #c8d4df; border-radius: 9px;
  padding: 10px 12px; background: white; color: var(--ink); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #1677ff20; }
.date-filter input { margin-top: 6px; min-width: 170px; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric { background: white; border: 1px solid var(--line); border-top: 4px solid var(--navy-2); border-radius: 12px; padding: 16px 18px; box-shadow: 0 4px 14px #102a4308; }
.metric span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { display: block; font-size: 32px; margin-top: 7px; }
.metric-good { border-top-color: var(--good); }
.metric-warning { border-top-color: #e6a117; }
.metric-danger { border-top-color: var(--danger); }
.metric-alert { border-top-color: var(--alert); }
.metric-site-delay { border-top-color: #d97706; }
.metric-complete { border-top-color: var(--good); }
.metric-grid-wide { grid-template-columns: repeat(7, minmax(130px, 1fr)); }
.sync-strip { display: flex; flex-wrap: wrap; gap: 18px; padding: 12px 16px; margin-bottom: 16px; border-radius: 9px; color: #245d3c; background: #e7f6ed; font-size: 13px; }
.sync-error { color: #8d241c; background: #fdecea; }
.panel { background: white; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 7px 24px #102a430c; overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 11px 12px; text-align: left; color: #53677a; background: #f7f9fb; border-bottom: 1px solid var(--line); font-size: 11px; text-transform: uppercase; letter-spacing: .045em; }
td { padding: 13px 12px; border-bottom: 1px solid #eaf0f4; font-size: 13px; vertical-align: top; }
td small { display: block; color: var(--muted); margin-top: 4px; }
tbody tr:hover { background: #f9fbfd; }
.load-row { cursor: pointer; }
.load-row:focus { outline: 3px solid #1677ff30; outline-offset: -3px; background: #f4f9ff; }
.row-canceled { opacity: .55; text-decoration: line-through; }
.badge { display: inline-block; padding: 5px 8px; border-radius: 999px; background: #edf2f6; color: #3b5165; font-size: 11px; font-weight: 800; }
.risk-on-time { color: #146c3d; background: #e2f5e9; }
.risk-at-risk { color: #895500; background: #fff2cf; }
.risk-running-behind { color: #9d241b; background: #fde5e2; }
.risk-site-delay { color: #8a3d00; background: #ffead5; }
.risk-complete { color: #146c3d; background: #dff4e7; }
.alert-text { color: var(--danger); white-space: normal; min-width: 180px; max-width: 260px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 40px; padding: 9px 15px; border: 0; border-radius: 9px; font-weight: 750; cursor: pointer; }
.button-primary { color: white; background: var(--blue); }
.button-primary:hover { background: #0567e5; }
.button-secondary { color: #30485c; background: #e9eff4; }
.button-danger { color: white; background: var(--danger); }
.button-danger:hover { background: #941d14; }
.link-button { padding: 0; border: 0; color: #b9d2e8; background: transparent; cursor: pointer; }
.danger-link { color: var(--danger); margin-left: 10px; }
.close-link { color: #8a3d00; margin-left: 10px; }
.actions { min-width: 105px; }
.form-panel { padding: 24px; max-width: 980px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-grid label, .stack label { color: #43596d; font-size: 13px; font-weight: 750; }
.form-grid input, .form-grid select, .form-grid textarea, .stack input { margin-top: 7px; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.import-panel {
  display: flex; align-items: end; gap: 16px; padding: 22px;
  margin-bottom: 18px;
}
.file-field { flex: 1; color: #43596d; font-size: 13px; font-weight: 750; }
.file-field input { margin-top: 7px; }
.import-summary {
  display: grid; grid-template-columns: repeat(3, minmax(150px, 240px));
  gap: 14px; margin-bottom: 18px;
}
.preview-panel { margin-bottom: 18px; }
.preview-panel .panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.rejected-panel { border-color: #efc1bc; }
.load-dialog {
  width: min(1080px, calc(100vw - 32px)); max-height: calc(100vh - 40px);
  padding: 0; border: 0; border-radius: 16px; color: var(--ink);
  box-shadow: 0 28px 90px #07192a66;
}
.load-dialog::backdrop { background: #07192a99; backdrop-filter: blur(2px); }
.dialog-heading {
  display: flex; justify-content: space-between; align-items: start;
  padding: 22px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2; background: white;
}
.dialog-heading h2 { font-size: 24px; }
.dialog-heading .eyebrow { margin-bottom: 6px; }
.dialog-close {
  width: 36px; height: 36px; border: 0; border-radius: 9px;
  color: #53677a; background: #edf2f6; font-size: 25px; line-height: 1;
  cursor: pointer;
}
.detail-content { padding: 22px 24px; }
.detail-section + .detail-section { margin-top: 22px; }
.detail-section h3 {
  margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
  color: var(--navy-2); font-size: 14px; text-transform: uppercase;
  letter-spacing: .055em;
}
.detail-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 18px; margin: 0;
}
.detail-grid div { min-width: 0; padding: 9px 0; }
.detail-grid dt { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.detail-grid dd { margin: 5px 0 0; overflow-wrap: anywhere; font-size: 14px; }
.dialog-actions {
  display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px;
  border-top: 1px solid var(--line); position: sticky; bottom: 0; background: white;
}
.flash { padding: 12px 16px; border-radius: 9px; margin-bottom: 16px; }
.flash-error { color: #8d241c; background: #fdecea; }
.flash-success { color: #146c3d; background: #e2f5e9; }
.login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 80% 10%, #187ce050, transparent 36%),
              linear-gradient(145deg, #0e2740, #173f66);
}
.login-card { width: min(430px, 100%); padding: 34px; border-radius: 18px; background: white; box-shadow: 0 28px 70px #07192a77; }
.login-brand { display: flex; align-items: center; gap: 15px; margin-bottom: 28px; }
.login-logo { width: 190px; max-width: 48%; height: auto; }
.login-brand h1 { font-size: 24px; margin-bottom: 3px; }
.login-brand p { color: var(--muted); margin: 0; }
.stack { display: grid; gap: 18px; }
.error-page { max-width: 650px; padding: 40px; }
.closure-warning {
  padding: 14px 16px; margin-bottom: 20px; border-left: 4px solid #d97706;
  color: #75400c; background: #fff5e8; border-radius: 8px;
}
.audit-details { white-space: normal; min-width: 240px; max-width: 520px; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; padding: 14px 18px; gap: 10px 20px; }
  .brand { min-width: 0; flex: 1; }
  nav { order: 3; flex-basis: 100%; }
  .user-menu span { display: none; }
  .page { padding: 20px 14px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-grid-wide { grid-template-columns: repeat(2, 1fr); }
  .import-summary { grid-template-columns: 1fr; }
  .import-panel { align-items: stretch; flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
