:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --ink: #182230;
  --muted: #667085;
  --line: #d5dbe5;
  --brand: #b91c1c;
  --brand-dark: #7f1d1d;
  --manager: #344054;
  --ok: #067647;
  --warn: #b54708;
  --danger: #b42318;
  --blue: #175cd3;
  --gold: #fbbf24;
  --ember: #ef4444;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.topbar {
  align-items: center;
  background: linear-gradient(90deg, #7f1d1d, #b91c1c);
  border-bottom: 1px solid var(--line);
  color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 36px);
  position: sticky;
  top: 0;
  z-index: 2;
}

.topbar.manager { background: linear-gradient(90deg, #1f2937, #7f1d1d); }
.brand-lockup { align-items: center; display: flex; gap: 12px; }
.brand-lockup img { background: rgba(255,255,255,.92); border-radius: 8px; height: 56px; object-fit: contain; padding: 4px; width: 56px; }
.topbar .eyebrow { color: #fde68a; }
.eyebrow { color: var(--brand); font-size: 12px; font-weight: 800; margin: 0 0 4px; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 22px; line-height: 1.1; margin-bottom: 0; }
h2 { font-size: clamp(24px, 5vw, 36px); line-height: 1.08; margin-bottom: 8px; }
h3 { font-size: 18px; margin-bottom: 0; }

.app-shell { margin: 0 auto; max-width: 1260px; padding: 16px; }
.app-shell.compact { max-width: 980px; }

.portal {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}
.portal-hero {
  background: linear-gradient(120deg, #fff, #fff1f0 55%, #eef4ff);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: auto;
  max-width: 760px;
  padding: clamp(24px, 6vw, 54px);
  width: 100%;
}
.portal-hero h1 { font-size: clamp(34px, 8vw, 58px); margin-bottom: 12px; }
.portal-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

.primary-action, .secondary-action, .ghost-link {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
}
.primary-action { background: var(--brand); border: 0; color: #fff; }
.secondary-action { background: var(--manager); color: #fff; }
.ghost-link { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.38); color: #fff; min-height: 38px; }

.tabs {
  background: #eceff3;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 16px;
  padding: 4px;
}
.tabs.two { grid-template-columns: repeat(2, 1fr); }
.tab { background: transparent; border: 0; border-radius: 6px; color: var(--muted); cursor: pointer; min-height: 44px; }
.tab.active { background: var(--surface); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); color: var(--ink); font-weight: 800; }
.view, .manager-panel { display: none; }
.view.active, .manager-panel.active { display: block; }

.panel, .kpi, .filter-panel, .manager-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.panel { padding: 16px; }
.panel-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: -2px 0 16px;
  padding-bottom: 12px;
}
.panel-head span, .required-note { color: var(--muted); font-size: 13px; }
.helper-text { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.required-note.sent { color: var(--ok); font-weight: 800; }

.field-grid, .filter-panel {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.filter-panel {
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  margin-bottom: 16px;
  padding: 14px;
}
label { color: #344054; display: grid; font-size: 13px; font-weight: 800; gap: 7px; }
input, select, textarea {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}
textarea { min-height: 96px; resize: vertical; }

.checklist-items { display: grid; gap: 10px; margin: 16px 0; }
.check-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1.3fr 1fr;
  padding: 12px;
}
.check-row.issue { background: #fffbfa; border-color: #fda29b; }
.conditional-box {
  background: #f8fafc;
  border: 1px dashed #98a2b3;
  border-radius: 8px;
  display: grid;
  gap: 14px;
  margin: 16px 0;
  padding: 14px;
}
.conditional-box.soft { background: #fffdf3; border-color: #fbbf24; }
.conditional-box.soft > div { display: grid; gap: 14px; margin-top: 10px; }
.hidden { display: none !important; }
.inline-warning { background: #fffbeb; border: 1px solid #fedf89; border-radius: 8px; color: var(--warn); font-weight: 800; margin: 16px 0; padding: 12px; }

.manager-hero {
  align-items: center;
  background:
    linear-gradient(120deg, rgba(255,255,255,.96), rgba(255,247,237,.92) 48%, rgba(238,244,255,.94)),
    radial-gradient(circle at 12% 20%, rgba(239,68,68,.16), transparent 28%);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: clamp(18px, 5vw, 34px);
}
.hero-crest { height: 112px; object-fit: contain; opacity: .95; width: 112px; }
.operation-banner {
  align-items: center;
  background:
    linear-gradient(120deg, rgba(127,29,29,.95), rgba(185,28,28,.9)),
    linear-gradient(45deg, rgba(251,191,36,.24), transparent);
  border-radius: 8px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: clamp(18px, 5vw, 30px);
}
.operation-banner .eyebrow { color: #fde68a; }
.operation-banner p { color: #fee2e2; margin-bottom: 0; }
.operation-banner img { background: rgba(255,255,255,.92); border-radius: 8px; height: 96px; object-fit: contain; padding: 6px; width: 96px; }
.arrow-nav { align-items: center; display: flex; gap: 10px; }
.arrow-nav button {
  background: var(--manager);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 32px;
  height: 48px;
  line-height: 1;
  width: 48px;
}

.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); margin-bottom: 16px; }
.kpi-grid.four { grid-template-columns: repeat(4, 1fr); }
.kpi { padding: 18px; }
.kpi span { color: var(--muted); display: block; font-size: 13px; margin-bottom: 8px; }
.kpi strong { font-size: 28px; overflow-wrap: anywhere; }
.kpi.ok { border-top: 4px solid var(--ok); }
.kpi.warn { border-top: 4px solid var(--warn); }
.kpi.danger { border-top: 4px solid var(--danger); }
.kpi.blue { border-top: 4px solid var(--blue); }
.kpi.neutral { border-top: 4px solid var(--manager); }

.dashboard-layout { display: grid; gap: 16px; grid-template-columns: 1.15fr 0.85fr; }
.alert-list, .bar-chart, .status-map { display: grid; gap: 10px; }
.alert-item, .bar-row, .status-tile {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  padding: 12px;
}
.status-map { grid-template-columns: repeat(2, 1fr); }
.status-tile { display: block; min-height: 92px; }
.status-tile strong { display: block; font-size: 32px; }
.status-tile span { color: var(--muted); font-weight: 800; }
.badge { border-radius: 999px; font-size: 12px; font-weight: 800; padding: 6px 9px; white-space: nowrap; }
.badge.ok { background: #ecfdf3; color: var(--ok); }
.badge.warn { background: #fffaeb; color: var(--warn); }
.badge.danger { background: #fef3f2; color: var(--danger); }

.bar-track { background: #eef2f6; border-radius: 999px; height: 10px; margin-top: 7px; overflow: hidden; }
.bar-fill { background: var(--brand); height: 100%; }
.inline-filter { align-items: center; display: flex; flex-direction: row; gap: 8px; min-width: 190px; }
.inline-filter select { min-height: 38px; }

.data-table { overflow-x: auto; }
table { border-collapse: collapse; min-width: 780px; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 10px; text-align: left; vertical-align: top; }
th { background: #f8fafc; color: #344054; font-size: 12px; text-transform: uppercase; }
td { font-size: 14px; }

.toast {
  background: #101828;
  border-radius: 8px;
  bottom: 16px;
  color: #fff;
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 12px 14px;
  position: fixed;
  transform: translateX(-50%);
}

@media (max-width: 840px) {
  .topbar, .manager-hero, .operation-banner, .panel-head { align-items: stretch; flex-direction: column; }
  .hero-crest, .operation-banner img { align-self: center; }
  .field-grid, .filter-panel, .dashboard-layout, .check-row, .kpi-grid, .kpi-grid.four, .status-map { grid-template-columns: 1fr; }
}
