:root {
  --bg: #f5f9fc;
  --surface: #ffffff;
  --soft: #eef7fb;
  --line: #d7e5ef;
  --text: #0b1b33;
  --muted: #62738b;
  --primary: #00a7b5;
  --primary-dark: #008996;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 14px 42px rgba(11, 27, 51, .07);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

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

a { color: inherit; text-decoration: none; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 42px;
  border-radius: 13px;
  background: #081424;
  color: white;
  font-weight: 800;
  letter-spacing: .08em;
}

.brand h1, .brand strong { display: block; margin: 0; font-size: 20px; line-height: 1.1; }
.brand span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; margin-top: 4px; }

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .82);
  overflow: auto;
}

.nav-group {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.65);
}

.nav-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
  font-weight: 800;
  text-transform: uppercase;
  margin: 3px 4px 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #24344d;
  font-weight: 700;
}

.nav-link:hover, .nav-link.active {
  background: #e6fbff;
  border-color: #a7edf4;
  color: #006a75;
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #edf5fb;
  color: #6e8097;
  font-size: 12px;
}

.content {
  min-width: 0;
  padding: 24px 28px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.search {
  width: min(560px, 100%);
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 16px;
  background: white;
  color: var(--text);
}

.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.page-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--primary-dark);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .1em;
  font-weight: 900;
}

h2, h3 { margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 34px; line-height: 1.1; }
h3 { font-size: 21px; }
p { color: var(--muted); line-height: 1.55; }

.role-pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #a7e8f4;
  border-radius: 999px;
  background: #effdff;
  color: #006a75;
  padding: 8px 12px;
  font-weight: 800;
}

.grid { display: grid; gap: 16px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.card-pad { padding: 20px; }
.metric { padding: 18px; min-height: 104px; }
.metric .label { color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.metric .value { font-size: 32px; font-weight: 900; margin-top: 10px; letter-spacing: -0.03em; }
.metric .hint { color: var(--muted); margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
}
td {
  border-bottom: 1px solid #e7eff5;
  padding: 13px 10px;
  vertical-align: top;
}
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #eafcff; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0 16px;
  background: #edf5fb;
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}
.btn:hover { border-color: #a7edf4; background: #e6fbff; }
.btn.primary { border-color: var(--primary); background: var(--primary); color: white; }
.btn.danger { border-color: #ffcaca; background: #fff1f1; color: #b91c1c; }
.btn.small { min-height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13px; }

label { display: block; color: #23324a; font-weight: 800; margin-bottom: 8px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #bdd2e5;
  border-radius: 12px;
  min-height: 42px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
textarea { min-height: 96px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-full { grid-column: 1 / -1; }

.status-plan { background: #fff3cd; color: #8a5200; border-color: #ffe29a; }
.status-progress { background: #dff7ff; color: #006a75; border-color: #a7edf4; }
.status-done { background: #dcfce7; color: #166534; border-color: #b4f2c7; }
.status-late { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.status-hold { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; }

.progress {
  height: 9px;
  border-radius: 999px;
  background: #e7eef5;
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--success));
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.section-head h3 { margin: 0 0 6px; }
.section-head p { margin: 0; }

.status-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.status-summary strong {
  font-size: 26px;
  letter-spacing: -0.02em;
}

.order-status-panel { overflow: hidden; }
.order-progress { height: 11px; margin: 16px 0 18px; }

.timeline-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.timeline-step {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 86px;
  padding: 12px;
  border: 1px solid #d9e7f2;
  border-radius: 16px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.timeline-step:hover {
  border-color: #8eddea;
  box-shadow: 0 12px 28px rgba(14, 165, 233, .13);
  transform: translateY(-1px);
}

.timeline-dot {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  border: 2px solid #d9e7f2;
  background: #f8fbff;
  color: var(--muted);
}

.timeline-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.timeline-body strong { overflow-wrap: anywhere; }

.timeline-body small {
  color: var(--muted);
  font-weight: 700;
}

.timeline-done .timeline-dot { background: #dcfce7; border-color: #86efac; color: #166534; }
.timeline-in_progress .timeline-dot { background: #dff7ff; border-color: #8eddea; color: #006a75; }
.timeline-plan .timeline-dot { background: #fff7d6; border-color: #facc15; color: #854d0e; }
.timeline-late .timeline-dot { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.timeline-hold .timeline-dot { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }

.timeline-late {
  border-color: #fecaca;
  background: #fffafa;
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.timeline-legend span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.done { background: #22c55e; }
.legend-dot.progress { background: #0ea5e9; }
.legend-dot.plan { background: #f59e0b; }
.legend-dot.late { background: #ef4444; }
.legend-dot.hold { background: #6366f1; }

.compact-metrics {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e7eff5;
}

.compact-metrics > div {
  border: 1px solid #e7eff5;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fbfdff;
}

.compact-metrics .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 900;
  margin-bottom: 5px;
}

.compact-metrics strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.notice {
  border: 1px solid #bdebf2;
  background: #effdff;
  color: #164b5b;
  border-radius: 14px;
  padding: 13px 15px;
  font-weight: 700;
  margin-bottom: 18px;
}

.flash {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.muted { color: var(--muted); }
.strong { font-weight: 900; }
.nowrap { white-space: nowrap; }

.stage-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px 120px 145px 145px 150px;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #e7eff5;
}

.stage-card:last-child { border-bottom: 0; }

.next-step-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-color: #a7edf4;
  background: linear-gradient(180deg, #ffffff, #f4fdff);
}

.next-step-panel h3 { margin-top: 4px; }
.next-step-panel p { margin-bottom: 0; }

.stage-work-card {
  border: 1px solid #e4eef7;
  border-radius: 16px;
  padding: 14px;
  margin-top: 12px;
  background: #fff;
}

.stage-work-card:target {
  border-color: #5fd7e5;
  box-shadow: 0 12px 34px rgba(0, 167, 181, .16);
}

.stage-work-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.stage-work-head p {
  margin: 4px 0 0;
}

.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
}

.stage-edit-grid {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) minmax(120px, .7fr) minmax(140px, .8fr) minmax(140px, .8fr) minmax(160px, 1fr);
  gap: 12px;
  align-items: end;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #eef3f8;
}

.alert-list { display: grid; gap: 10px; }

.alert-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 130px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid #e7eff5;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}

.alert-row:hover { background: #eafcff; border-color: #a7edf4; }

.people-load-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.person-load-card {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid #e4eef7;
  border-radius: 16px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.person-load-card:hover {
  border-color: #8eddea;
  box-shadow: 0 12px 28px rgba(14, 165, 233, .12);
  transform: translateY(-1px);
}

.person-load-head, .person-load-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.person-load-card p {
  margin: 0;
  font-size: 13px;
}

.person-load-foot {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.calendar-head,
.calendar-day {
  min-height: 48px;
  padding: 10px;
  border-right: 1px solid #e7eff5;
  border-bottom: 1px solid #e7eff5;
  background: #fff;
}

.calendar-head {
  min-height: auto;
  background: #f0f7fc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.calendar-day:nth-child(7n),
.calendar-head:nth-child(7n) { border-right: 0; }

.calendar-day { cursor: pointer; }
.calendar-day:hover { background: #eafcff; }
.calendar-day.empty { background: #f8fbfd; cursor: default; }
.calendar-date { font-weight: 900; margin-bottom: 8px; }
.calendar-load { color: var(--muted); font-size: 12px; }
.load-ok { box-shadow: inset 0 0 0 2px rgba(16,185,129,.18); }
.load-warn { box-shadow: inset 0 0 0 2px rgba(245,158,11,.28); }
.load-over { box-shadow: inset 0 0 0 2px rgba(239,68,68,.28); background: #fff7f7; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .metrics, .two, .three, .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .page-title, .topbar { align-items: stretch; flex-direction: column; }
  .stage-card { grid-template-columns: 1fr; }
  .section-head, .status-summary { align-items: flex-start; flex-direction: column; }
  .next-step-panel, .stage-work-head { align-items: flex-start; flex-direction: column; }
  .stage-edit-grid { grid-template-columns: 1fr; }
}
