:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-muted: #eef2f5;
  --border: #d7dee5;
  --border-strong: #b8c4cf;
  --text: #17212b;
  --muted: #5f6f7e;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --warning: #a15c07;
  --success: #087443;
  --shadow: 0 14px 36px rgba(23, 33, 43, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.loading-screen,
.auth-layout {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.loading-screen {
  gap: 14px;
  color: var(--muted);
}

.loading-mark {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-panel {
  width: min(100%, 420px);
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand {
  display: grid;
  gap: 6px;
  margin-bottom: 24px;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

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

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

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

.field span,
.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 11px 12px;
  background: var(--surface);
  color: var(--text);
}

.field textarea {
  min-height: 106px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

.field small {
  line-height: 1.35;
}

.checkbox-field {
  align-content: start;
  min-height: 70px;
}

.checkbox-field input {
  width: 20px;
  height: 20px;
  padding: 0;
  accent-color: var(--accent);
}

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

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  text-decoration: none;
}

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

.button.secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.button.secondary:hover {
  background: var(--surface-muted);
}

.button.danger {
  border-color: rgba(180, 35, 24, 0.25);
  background: #fff4f2;
  color: var(--danger);
}

.button.danger:hover {
  background: #ffe8e3;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.text-button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent-dark);
  font-weight: 700;
}

.notice {
  border-radius: 6px;
  padding: 11px 12px;
  font-size: 14px;
}

.notice.error {
  border: 1px solid rgba(180, 35, 24, 0.25);
  background: #fff4f2;
  color: var(--danger);
}

.notice.success {
  border: 1px solid rgba(8, 116, 67, 0.2);
  background: #effaf4;
  color: var(--success);
}

.admin-frame {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  padding: 12px clamp(16px, 4vw, 40px);
  backdrop-filter: blur(12px);
}

.topbar-title {
  display: grid;
  gap: 2px;
}

.topbar-title strong {
  font-size: 17px;
}

.topbar-title span {
  color: var(--muted);
  font-size: 13px;
}

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

.nav a {
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.nav a.active,
.nav a:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 40px) 48px;
}

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

.page-header h1,
.section h2,
.section h3 {
  margin: 0;
}

.page-header h1 {
  font-size: 30px;
  line-height: 1.15;
}

.page-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.section {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

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

.search-box {
  width: min(100%, 360px);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--surface);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.metric,
.panel,
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.metric {
  display: grid;
  gap: 8px;
  padding: 18px;
}

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

.metric strong {
  font-size: 24px;
}

.panel {
  padding: 18px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  background: #f1f5f7;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

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

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 750;
}

.status.active {
  background: #e8f7ef;
  color: var(--success);
}

.status.inactive {
  background: #f2f4f7;
  color: var(--muted);
}

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

.definition-list {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--border);
}

.definition-list dt,
.definition-list dd {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface);
}

.definition-list dt {
  color: var(--muted);
  font-weight: 750;
}

.definition-list dd {
  overflow-wrap: anywhere;
}

.code-block {
  overflow: auto;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #111827;
  color: #e5e7eb;
  font-size: 13px;
  line-height: 1.5;
}

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 22px;
  background: var(--surface);
  color: var(--muted);
}

@media (max-width: 720px) {
  .topbar,
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .definition-list {
    grid-template-columns: 1fr;
  }

  .definition-list dt {
    padding-bottom: 4px;
  }

  .definition-list dd {
    padding-top: 4px;
  }
}
