:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --line: #d7dde8;
  --primary: #155eef;
  --primary-dark: #0f47b8;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #067647;
  --success-bg: #ecfdf3;
  --warning: #8a6116;
  --warning-bg: #fffaeb;
  --shadow: 0 18px 48px rgba(16, 24, 40, 0.22);
}

* {
  box-sizing: border-box;
}

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

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

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  background: #101828;
  color: #ffffff;
  border-bottom: 1px solid #24314a;
}

.brand {
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-links a,
.link-button {
  border: 0;
  border-radius: 6px;
  color: #d6e2f5;
  background: transparent;
  padding: 8px 10px;
  font: inherit;
  cursor: pointer;
}

.nav-links a.active,
.nav-links a:hover,
.link-button:hover {
  background: #24314a;
  color: #ffffff;
}

.language-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d6e2f5;
  font-size: 14px;
}

.language-control span {
  white-space: nowrap;
}

.language-select {
  width: auto;
  min-height: 34px;
  min-width: 110px;
  border: 1px solid #344054;
  border-radius: 6px;
  background: #101828;
  color: #ffffff;
  padding: 6px 30px 6px 10px;
  font: inherit;
  cursor: pointer;
}

.language-select:focus {
  outline: 3px solid rgba(21, 94, 239, 0.18);
  border-color: #7aa2ff;
}

main {
  width: min(1160px, calc(100% - 32px));
  margin: 28px auto;
}

.auth-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  width: min(420px, calc(100% - 32px));
  margin: 0 auto;
}

.auth-box,
.section,
.modal-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.auth-box {
  width: 100%;
  padding: 26px;
}

.auth-language-control {
  color: #344054;
}

.auth-language-control .language-select {
  background: #ffffff;
  color: var(--text);
  border-color: var(--line);
}

.page-head,
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-head {
  margin: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.message {
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.message.notice {
  background: var(--success-bg);
  color: var(--success);
  border-color: #abefc6;
}

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

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

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

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

th {
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f8fafc;
}

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

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

button,
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  padding: 8px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

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

button.secondary,
.button.secondary {
  background: #ffffff;
  color: #344054;
  border-color: var(--line);
}

button.secondary:hover,
.button.secondary:hover {
  background: #f8fafc;
}

button.danger,
.button.danger {
  background: #ffffff;
  color: var(--danger);
  border-color: #fecdca;
}

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

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.status.on {
  color: var(--success);
  background: var(--success-bg);
}

.status.off {
  color: var(--warning);
  background: var(--warning-bg);
}

form {
  margin: 0;
}

.form-grid {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 20px;
}

.form-grid.single {
  grid-template-columns: 1fr;
  padding: 20px 0;
}

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

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

.field.is-disabled label {
  color: var(--muted);
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.field-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.field-help {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #eaf1ff;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
}

.field-help::before {
  content: "";
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #101828;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
}

.field-help::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(300px, calc(100vw - 48px));
  padding: 10px 12px;
  border-radius: 8px;
  background: #101828;
  color: #ffffff;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 2;
}

.field-help:hover::before,
.field-help:hover::after,
.field-help:focus-visible::before,
.field-help:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

label {
  color: #344054;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

input::placeholder {
  color: #98a2b3;
}

input:focus,
select:focus {
  outline: 3px solid rgba(21, 94, 239, 0.18);
  border-color: var(--primary);
}

input[disabled],
select[disabled] {
  background: #f2f4f7;
  color: #98a2b3;
  border-color: #d0d5dd;
  cursor: not-allowed;
}

.field-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #344054;
  cursor: pointer;
}

.check-field input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 20px 20px;
  flex-wrap: wrap;
}

.auth-box .form-actions {
  padding: 0;
}

.empty,
.loading {
  padding: 24px 20px;
  color: var(--muted);
}

.details-cell {
  max-width: 360px;
  white-space: normal;
  word-break: break-word;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 40, 0.45);
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  width: min(780px, 100%);
  max-height: min(780px, calc(100vh - 36px));
  overflow: auto;
  box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .nav-links {
    justify-content: flex-start;
  }

  main {
    width: min(100% - 20px, 1160px);
    margin: 18px auto;
  }

  .page-head,
  .modal-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

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