:root {
  --bg: #f2f7f5;
  --surface: #ffffff;
  --surface-soft: #f8fbfa;
  --text: #1f2d2a;
  --muted: #5f706c;
  --line: #d7e5e1;
  --brand: #1f9f83;
  --brand-deep: #0e6f5b;
  --warn: #e0982f;
  --danger: #d35353;
  --radius: 14px;
  --shadow: 0 10px 28px rgba(15, 61, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Outfit", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, #d8f0e6 0%, transparent 36%),
    radial-gradient(circle at 95% 95%, #e7f3ff 0%, transparent 32%),
    var(--bg);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: linear-gradient(140deg, #21b895, #128267);
}

.brand h1 {
  font-size: 17px;
  margin: 0;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.nav-menu {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.nav-item-row {
  display: grid;
  grid-template-columns: 1fr 30px;
  gap: 6px;
  align-items: center;
}

.nav-item-row .nav-item {
  width: 100%;
}

.nav-item-toggle {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  height: 32px;
  width: 30px;
  font-size: 14px;
}

.nav-item-toggle:hover {
  background: #eef5f2;
  color: var(--text);
}

.nav-item:hover {
  background: #e9f3f0;
}

.nav-item.active {
  background: linear-gradient(145deg, #1f9f83 0%, #157762 100%);
  color: white;
}

.nav-submenu {
  display: grid;
  gap: 4px;
  margin: -2px 0 6px 12px;
}

.nav-subitem {
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 7px 10px;
  text-align: left;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.nav-subitem:hover {
  background: #eef5f2;
  color: var(--text);
}

.nav-subitem.active {
  background: #dff0ea;
  color: #0f6d58;
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.sidebar-footer label {
  font-size: 12px;
  color: var(--muted);
}

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

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 9px 10px;
}

.main-content {
  padding: 20px;
}

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

.topbar h2 {
  margin: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.ghost-btn,
.primary-btn,
.danger-btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

.ghost-btn {
  background: #ecf4f2;
  color: var(--text);
}

.primary-btn {
  color: white;
  background: linear-gradient(140deg, var(--brand), var(--brand-deep));
}

.danger-btn {
  background: #ffe9e9;
  color: #8e2323;
}

.page-root {
  display: grid;
  gap: 14px;
}

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

.panel h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

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

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.metric-label {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.metric-value {
  margin: 8px 0 6px;
  font-size: 23px;
}

.metric-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
}

.full {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  font-weight: 600;
  color: var(--muted);
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  display: inline-block;
}

.b-info { background: #e8f8f4; color: #0e745f; }
.b-warn { background: #fff5e6; color: #986319; }
.b-danger { background: #ffeceb; color: #a43434; }
.b-done { background: #ebf2ff; color: #2057a6; }

.split {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
}

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

.list-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.small {
  color: var(--muted);
  font-size: 12px;
}

.notice {
  border-left: 4px solid var(--warn);
  background: #fff8eb;
  color: #7d5b1b;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

.critical-alert {
  border-left: 4px solid var(--danger);
  background: #fff1f1;
  color: #7b2424;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  display: grid;
  gap: 8px;
}

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

.critical-alert-item {
  border: 1px solid #f2c7c7;
  background: #fff9f9;
  border-radius: 8px;
  padding: 8px 10px;
}

.bar {
  height: 10px;
  background: #e6f0ee;
  border-radius: 999px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #22b99f, #1b7f88);
}

.thumb-wrap {
  min-height: 56px;
  display: flex;
  align-items: center;
}

.thumb-img {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: zoom-in;
  background: #f5fbfa;
}

.image-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 24, 22, 0.58);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.image-viewer-overlay.open {
  display: flex;
}

.image-viewer-dialog {
  width: min(1100px, 96vw);
  height: min(760px, 90vh);
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
  display: grid;
  grid-template-rows: auto 1fr;
}

.image-viewer-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.image-viewer-actions {
  display: flex;
  gap: 8px;
}

.image-viewer-body {
  overflow: auto;
  background: #eff7f5;
  display: grid;
  place-items: center;
  padding: 16px;
}

.image-viewer-body img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  transition: transform 0.08s linear;
}

@media (max-width: 1200px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .split {
    grid-template-columns: 1fr;
  }
}
