:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --text: #1e2522;
  --muted: #66736e;
  --line: #d9e1dd;
  --soft: #eef3f1;
  --primary: #0f7a5b;
  --primary-dark: #0a5a43;
  --accent: #2f80ed;
  --amber: #b7791f;
  --danger: #c2413d;
  --green-soft: #e8f6ef;
  --blue-soft: #eaf2ff;
  --amber-soft: #fff4d6;
  --red-soft: #fdecec;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p,
a,
label {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
  padding: 0 16px;
  min-width: 0;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
}

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

button.danger {
  background: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  min-height: 40px;
  padding: 9px 12px;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: 0;
  padding: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 4px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  vertical-align: middle;
  cursor: help;
  overflow-wrap: normal;
}

.field-help:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field-help-tooltip {
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: calc(100% + 8px);
  width: min(280px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.field-help:hover .field-help-tooltip,
.field-help:focus .field-help-tooltip,
.field-help:focus-within .field-help-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.compact-help {
  margin: -4px 0 0;
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
}

.login {
  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: 8px;
  padding: 28px;
  box-shadow: 0 18px 55px rgba(30, 37, 34, 0.09);
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-weight: 900;
}

.app-version {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-version {
  margin: -8px 0 20px 62px;
}

.sidebar-version {
  margin-top: 18px;
}

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

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}

.nav-item.active {
  background: var(--green-soft);
  color: var(--primary);
}

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

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

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid > *,
.split > * {
  min-width: 0;
}

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

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

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.metric {
  display: grid;
  gap: 6px;
  min-width: 0;
  container-type: inline-size;
}

.metric-value {
  display: block;
  font-size: 28px;
  line-height: 1.18;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.metric--status .metric-value {
  font-size: clamp(14px, 10cqw, 20px);
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.muted {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.section-title {
  margin: 26px 0 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  line-height: 1.2;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.badge.green {
  background: var(--green-soft);
  color: var(--primary);
}

.badge.blue {
  background: var(--blue-soft);
  color: var(--accent);
}

.badge.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.red {
  background: var(--red-soft);
  color: var(--danger);
}

.badge.gray {
  background: var(--soft);
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

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

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

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

tr.selected {
  background: var(--green-soft);
}

tr.future-pass {
  background: var(--amber-soft);
}

tr.future-pass.selected {
  outline: 2px solid color-mix(in srgb, var(--amber) 35%, transparent);
  outline-offset: -2px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid.compact {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.inline {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.notice {
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--blue-soft);
  color: #1d4f91;
  overflow-wrap: anywhere;
}

.notice.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.notice.danger {
  background: var(--red-soft);
  color: var(--danger);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.mobile-actions {
  display: none;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .main {
    padding: 18px;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .split,
  .form-grid,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }
}
