:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #eef3f2;
  --line: #dbe4e1;
  --text: #17211f;
  --muted: #66736f;
  --teal: #00796b;
  --teal-dark: #00594e;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #c2410c;
  --critical: #b91c1c;
  --shadow: 0 14px 36px rgba(26, 46, 43, 0.08);
  --radius: 8px;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  background: #10231f;
  color: #f8fbfa;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 8px;
  background: #d7f2ec;
  color: #073b34;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1,
.topbar h2,
.view-heading h3,
.panel h4 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 1.02rem;
  line-height: 1.25;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #a9c8c1;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d9e7e4;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(215, 242, 236, 0.11);
  border-color: rgba(215, 242, 236, 0.24);
  color: #ffffff;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.82rem;
  font-weight: 800;
}

.role-card {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.role-card label {
  color: #cfe2de;
  font-size: 0.86rem;
}

.role-card select {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 10px;
}

.main-content {
  min-width: 0;
  padding: 26px;
}

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

.topbar h2 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-indicator {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.secondary-button,
.ghost-button,
.primary-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--teal-dark);
  background: var(--teal);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.ghost-button {
  border: 1px solid transparent;
  background: var(--surface-muted);
  color: var(--teal-dark);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.view-heading h3 {
  font-size: clamp(1.25rem, 2vw, 1.8rem);
}

.view-heading p:last-child {
  max-width: 690px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

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

.kpi-card {
  display: grid;
  gap: 8px;
  min-height: 138px;
  padding: 18px;
}

.kpi-card span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.kpi-card strong {
  font-size: 2.25rem;
  line-height: 1;
}

.kpi-card small {
  color: var(--muted);
  line-height: 1.45;
}

.layout-grid {
  display: grid;
  gap: 14px;
}

.dashboard-layout {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
}

.twin-layout {
  grid-template-columns: minmax(0, 1.4fr) minmax(330px, 0.75fr);
}

.analysis-layout,
.report-layout {
  grid-template-columns: minmax(320px, 0.72fr) minmax(0, 1fr);
}

.wide-panel {
  min-width: 0;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-header h4 {
  font-size: 1rem;
}

.coast-map {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(196, 231, 222, 0.55), rgba(235, 247, 250, 0.88) 52%, rgba(196, 227, 245, 0.8));
}

.coast-map.small {
  min-height: 330px;
}

.coast-map svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-region {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 10px 20px rgba(7, 35, 32, 0.2);
}

.map-region::after {
  content: "";
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.25;
}

.map-region.low {
  background: #1b9e77;
  color: #1b9e77;
}

.map-region.medium {
  background: #d89b1d;
  color: #d89b1d;
}

.map-region.high {
  background: #e85d1f;
  color: #e85d1f;
}

.map-region.critical {
  background: #b91c1c;
  color: #b91c1c;
}

.map-region.selected {
  outline: 3px solid rgba(0, 121, 107, 0.3);
}

.map-label {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1% + 22px);
  transform: translateX(-50%);
  max-width: 155px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 8px 18px rgba(26, 46, 43, 0.1);
}

.map-legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: calc(100% - 28px);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.risk-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.risk-pill.low {
  background: #dff6ec;
  color: #087047;
}

.risk-pill.medium {
  background: #fff2cc;
  color: #8a5a00;
}

.risk-pill.high {
  background: #ffe1d3;
  color: #a13f11;
}

.risk-pill.critical {
  background: #ffe0e0;
  color: #a31616;
}

.status-pill {
  background: #eef3f2;
  color: #43524e;
}

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

.alert-item,
.priority-item,
.report-card,
.recommendation-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.alert-item strong,
.priority-item strong,
.report-card strong {
  line-height: 1.35;
}

.alert-item p,
.priority-item p,
.report-card p,
.recommendation-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.priority-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.score-bar {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #e8efed;
}

.score-bar span {
  display: block;
  width: calc(var(--score) * 1%);
  height: 100%;
  background: var(--teal);
}

.score-bar span.medium {
  background: var(--amber);
}

.score-bar span.high {
  background: var(--red);
}

.score-bar span.critical {
  background: var(--critical);
}

.chart-list {
  display: grid;
  gap: 12px;
}

.chart-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.chart-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e8efed;
}

.chart-track span {
  display: block;
  width: calc(var(--value) * 1%);
  height: 100%;
  background: var(--blue);
}

.detail-stack,
.recommendation-list {
  display: grid;
  gap: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-box {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.metric-box span {
  color: var(--muted);
  font-size: 0.78rem;
}

.metric-box strong {
  font-size: 1.1rem;
}

.gauge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.gauge-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  text-align: center;
}

.gauge-ring {
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffffff 0 57%, transparent 58%),
    conic-gradient(var(--color) calc(var(--score) * 1%), #e8efed 0);
}

.gauge-ring strong {
  font-size: 1.55rem;
}

.stack-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #34413e;
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 121, 107, 0.12);
}

textarea {
  resize: vertical;
}

.control-grid,
.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.range-control {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.range-control header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.range-control span {
  color: var(--muted);
  font-weight: 800;
}

input[type="range"] {
  padding: 0;
}

.photo-preview {
  min-height: 44px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 10px;
}

.photo-preview img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 6px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.filter-bar label {
  min-width: 220px;
}

.report-card {
  grid-template-columns: minmax(0, 1fr) 210px;
  align-items: start;
}

.report-main {
  display: grid;
  gap: 8px;
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.report-side {
  display: grid;
  gap: 8px;
}

.report-photo {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #43524e;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td {
  color: #2b3936;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  transform: translateY(18px);
  opacity: 0;
  max-width: min(380px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #10231f;
  color: #ffffff;
  box-shadow: var(--shadow);
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-layout,
  .twin-layout,
  .analysis-layout,
  .report-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-content {
    padding: 18px;
  }

  .topbar,
  .view-heading {
    align-items: start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .control-grid,
  .two-column,
  .metric-grid,
  .gauge-grid {
    grid-template-columns: 1fr;
  }

  .report-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .nav-list,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .brand {
    align-items: flex-start;
  }

  .sync-indicator {
    display: none;
  }

  .coast-map {
    min-height: 360px;
  }

  .coast-map.small {
    min-height: 300px;
  }

  .map-label {
    max-width: 108px;
    font-size: 0.68rem;
  }

  .chart-row {
    grid-template-columns: 88px minmax(0, 1fr) 28px;
  }
}
