:root {
  --midnight: #0F1E36;
  --midnight-light: #1D3557;
  --cyan: #00B4DB;
  --canvas: #F4F7FA;
  --line: #D3E0EA;
  --ink: #1D2733;
  --ink-muted: #6C7A89;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.display { font-family: "Space Grotesk", system-ui, sans-serif; }

a { color: inherit; }

.app { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--midnight);
  color: white;
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 24px 20px; }
.brand-name { font-weight: 600; font-size: 15px; line-height: 1; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 4px; }
.nav { flex: 1; padding: 0 8px; }
.nav a {
  display: block;
  padding: 9px 16px;
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  margin-bottom: 2px;
}
.nav a.active { background: rgba(255,255,255,0.1); color: white; }
.nav a:hover:not(.active) { background: rgba(255,255,255,0.05); color: white; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); padding: 16px 20px; }
.sidebar-footer .name { font-size: 14px; }
.sidebar-footer .signout { font-size: 12px; color: var(--cyan); margin-top: 4px; cursor: pointer; border: none; background: none; padding: 0; }

/* ---- Main ---- */
main { flex: 1; padding: 32px; max-width: 1100px; }
.global-search { display: flex; gap: 8px; margin-bottom: 24px; max-width: 480px; }
.global-search input {
  flex: 1; margin: 0; padding: 8px 12px; border: 1px solid var(--line); font-size: 14px; font-family: inherit;
}
.global-search input:focus { outline: none; border-color: var(--cyan); }
.global-search button {
  background: var(--midnight); color: white; border: none; padding: 8px 16px; font-size: 14px; cursor: pointer;
}
.global-search button:hover { background: var(--midnight-light); }
h1.page-title { font-size: 24px; font-weight: 600; color: var(--midnight); margin: 0; }
.page-sub { font-size: 14px; color: var(--ink-muted); margin: 4px 0 0; }

/* ---- Metric panels ---- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 24px; }
.metric { position: relative; overflow: hidden; border: 1px solid var(--line); background: white; padding: 16px 16px 16px 20px; }
.metric::before {
  content: ""; position: absolute; left: 0; top: 0; height: 100%; width: 6px;
  background: var(--cyan);
  clip-path: polygon(0 0, 100% 10%, 100% 90%, 0 100%);
}
.metric-label { font-size: 12px; font-weight: 500; color: var(--ink-muted); }
.metric-value { font-size: 30px; font-weight: 600; color: var(--midnight); margin-top: 4px; }
.metric-detail { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }
.metric-detail.alert { color: #dc2626; font-weight: 500; }

/* ---- Panels / tables ---- */
.panel { border: 1px solid var(--line); background: white; margin-top: 32px; }
.panel-header { border-bottom: 1px solid var(--line); padding: 12px 20px; }
.panel-header h2 { font-size: 16px; font-weight: 600; color: var(--midnight); margin: 0; }
.panel table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.panel thead { border-bottom: 1px solid var(--line); font-size: 12px; color: var(--ink-muted); }
.panel th, .panel td { padding: 12px 20px; }
.panel tbody tr { border-bottom: 1px solid var(--line); }
.panel tbody tr:last-child { border-bottom: none; }

.wo-row { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.wo-row:last-child { border-bottom: none; }
.wo-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.wo-title { font-size: 14px; font-weight: 500; color: var(--ink); margin: 0; }
.wo-meta { font-size: 12px; color: var(--ink-muted); margin: 3px 0 0; }
.badge-emergency { font-size: 11px; font-weight: 500; color: #dc2626; background: #fef2f2; padding: 2px 8px; white-space: nowrap; }

/* ---- Stage pipeline ---- */
.pipeline { display: flex; width: 100%; max-width: 460px; margin-top: 12px; }
.stage { flex: 1; padding: 6px 4px; text-align: center; font-size: 10.5px; font-weight: 500; background: rgba(211,224,234,0.6); color: var(--ink-muted); }
.stage.reached { background: var(--midnight); color: white; }
.stage:not(:first-child) { margin-left: -6px; }
.stage:first-child { clip-path: polygon(0 0, 92% 0, 100% 50%, 92% 100%, 0 100%); }
.stage:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 8% 50%); }
.stage:not(:first-child):not(:last-child) { clip-path: polygon(0 0, 92% 0, 100% 50%, 92% 100%, 0 100%, 8% 50%); }

/* ---- Forms ---- */
form.card { max-width: 480px; border: 1px solid var(--line); background: white; padding: 20px; }
label.field { display: block; margin-top: 14px; font-size: 14px; font-weight: 500; }
label.field:first-child { margin-top: 0; }
input, textarea, select {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); font-size: 14px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--cyan); }
button.btn {
  margin-top: 16px; background: var(--midnight); color: white; border: none;
  padding: 10px 18px; font-size: 14px; font-weight: 500; cursor: pointer;
}
button.btn:hover { background: var(--midnight-light); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.btn.small { padding: 7px 14px; font-size: 12px; margin-top: 12px; }
.error-text { color: #dc2626; font-size: 14px; margin-top: 12px; }

/* ---- Login page ---- */
.login-grid { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login-brand {
  background: var(--midnight); color: white; padding: 48px; position: relative;
  overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
}
.login-brand .tagline { font-size: 34px; font-weight: 600; line-height: 1.25; font-family: "Space Grotesk", sans-serif; }
.login-brand .sub { max-width: 340px; font-size: 14px; color: rgba(255,255,255,0.6); margin-top: 16px; }
.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-form-wrap form { width: 100%; max-width: 360px; }
@media (max-width: 800px) {
  .login-grid { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}

/* ---- Searchable select (search-to-filter combobox) ---- */
.searchable-wrap { position: relative; }
.searchable-input {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); font-size: 14px; font-family: inherit;
}
.searchable-input:focus { outline: none; border-color: var(--cyan); }
.searchable-list {
  position: absolute; z-index: 20; top: 100%; left: 0; right: 0;
  max-height: 240px; overflow-y: auto; background: white;
  border: 1px solid var(--line); border-top: none;
  box-shadow: 0 4px 10px rgba(15, 30, 54, 0.08);
}
.searchable-option { padding: 8px 10px; font-size: 14px; cursor: pointer; }
.searchable-option:hover, .searchable-option.is-highlighted { background: #f1f5f9; }
