:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #eef5f1;
  --text: #18212f;
  --muted: #667085;
  --line: #d8dde5;
  --accent: #147d64;
  --accent-dark: #0c5f4c;
  --danger: #b42318;
  --warning: #9a6700;
  --shadow: 0 14px 36px rgba(24, 33, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: #17202c;
  color: #ffffff;
  padding: 24px 18px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #2fb394;
  color: #08241d;
  font-weight: 800;
}

.brand small,
.auth-brand small {
  display: block;
  color: #a9b5c3;
  margin-top: 2px;
}

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

.nav a {
  border-radius: 8px;
  color: #d9e2ed;
  padding: 11px 12px;
}

.nav a:hover,
.nav a.active {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.logout-form {
  margin-top: auto;
}

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

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

.topbar h1,
.form-heading h1 {
  margin: 0;
  font-size: 28px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.profile {
  min-width: 160px;
  text-align: right;
}

.profile span,
.profile small {
  display: block;
}

.profile small {
  color: var(--muted);
}

.panel,
.metrics article,
.auth-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.panel.narrow {
  max-width: 780px;
}

.panel.wide {
  max-width: 1120px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.metrics article {
  padding: 20px;
}

.metrics span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metrics strong {
  display: block;
  font-size: 24px;
}

.section-title {
  margin-bottom: 20px;
}

.section-title.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-title h2 {
  margin: 0;
  font-size: 20px;
}

.section-title p,
.form-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 13px;
  font-weight: 700;
}

.status.ok {
  background: #e7f6ef;
  color: #126044;
}

.status.off {
  background: #f1f3f5;
  color: #667085;
}

.status.warn {
  background: #fff7df;
  color: var(--warning);
}

.field-note {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.operation-form {
  grid-template-columns: 1fr 240px;
}

.operation-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

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

.details-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.details-grid .span-2 {
  grid-column: span 2;
}

.details-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
}

.details-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(460px, 100%);
  padding: 28px;
}

.auth-brand {
  margin-bottom: 24px;
}

.auth-brand small {
  color: var(--muted);
}

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

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

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
}

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

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.16);
}

fieldset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

legend {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  padding: 0 8px;
}

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

.settings-grid fieldset {
  display: grid;
  gap: 15px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  grid-column: 1 / -1;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  padding: 10px 14px;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

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

.button.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.button.danger {
  border-color: #f4c7c3;
  color: var(--danger);
}

.button.small {
  min-height: 34px;
  padding: 7px 10px;
}

.button.full {
  width: 100%;
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.message {
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  font-weight: 700;
}

.message.success {
  background: #e7f6ef;
  border-color: #a6dbc5;
  color: #126044;
}

.message.error {
  background: #fff0ee;
  border-color: #f4c7c3;
  color: var(--danger);
}

.empty {
  color: var(--muted);
  margin: 0;
}

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

  .sidebar {
    position: static;
  }

  .main {
    padding: 20px;
  }

  .topbar,
  .section-title.row {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile {
    text-align: left;
  }

  .metrics,
  .settings-grid,
  .form.grid,
  .operation-form,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .details-grid .span-2 {
    grid-column: auto;
  }

  .form-actions {
    justify-content: stretch;
    flex-direction: column-reverse;
  }

  .button {
    width: 100%;
  }
}
