:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f3f6fb;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.topbar {
  min-height: 86px;
  padding: 18px clamp(20px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: white;
  background: linear-gradient(135deg, #075985, #0f766e);
}
.topbar h1, .panel-heading h2, .dialog-heading h2 { margin: 2px 0 0; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .13em; opacity: .75; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.shell { width: min(1400px, calc(100% - 32px)); margin: 24px auto 56px; }
.notice {
  padding: 14px 16px;
  border: 1px solid #fde68a;
  border-radius: 14px;
  background: #fffbeb;
  color: #854d0e;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.stats article {
  padding: 18px;
  border: 1px solid #e3e9f2;
  border-radius: 16px;
  background: white;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .04);
}
.stats span { display: block; color: #64748b; font-size: 13px; }
.stats strong { display: block; margin-top: 4px; font-size: 30px; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.tab {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  color: #475569;
  background: #e9eef6;
  font-weight: 700;
  white-space: nowrap;
}
.tab.active { color: white; background: #0f766e; }

.panel {
  display: none;
  margin-top: 8px;
  padding: 22px;
  border: 1px solid #e3e9f2;
  border-radius: 18px;
  background: white;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .05);
}
.panel.active { display: block; }
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.toolbar input { flex: 1; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  color: #172033;
  background: white;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(13, 148, 136, .15); border-color: #0f766e; }

.button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  color: white;
  background: #0f766e;
  font-weight: 750;
  text-decoration: none;
}
.button:hover { filter: brightness(.96); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button-secondary { color: #0f172a; background: #e7edf5; }
.topbar .button-secondary { background: rgba(255,255,255,.92); }
.button-danger { color: #b91c1c; background: #fee2e2; }
.button-small { padding: 7px 9px; font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid #edf1f6; vertical-align: middle; }
th { color: #64748b; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
td { font-size: 14px; }
td a { color: #0369a1; word-break: break-all; }
.actions { display: flex; gap: 7px; }
.empty { padding: 28px; text-align: center; color: #64748b; }
.badge, .status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}
.badge-active, .status-ok { color: #166534; background: #dcfce7; }
.badge-inactive { color: #991b1b; background: #fee2e2; }
.status-loading { color: #854d0e; background: #fef3c7; }
.status-error { color: #991b1b; background: #fee2e2; }

dialog {
  width: min(650px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}
dialog::backdrop { background: rgba(15, 23, 42, .58); }
dialog form { padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; font-size: 25px; background: #eef2f7; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 750; color: #334155; }
.checkbox-field { flex-direction: row; align-items: center; padding-top: 26px; }
.checkbox-field input { width: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.preview-tree { display: grid; gap: 14px; }
.preview-page { border: 1px solid #dce4ee; border-radius: 14px; padding: 16px; }
.preview-page h3 { margin: 0 0 12px; }
.preview-category { margin-top: 10px; padding-left: 14px; border-left: 3px solid #99f6e4; }
.preview-category h4 { margin: 0 0 7px; }
.preview-category ul { margin: 0; padding-left: 20px; }
.preview-category li { margin: 5px 0; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100% - 40px));
  padding: 13px 16px;
  border-radius: 12px;
  color: white;
  background: #172033;
  box-shadow: 0 12px 35px rgba(15, 23, 42, .24);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #b91c1c; }

@media (max-width: 780px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 16px; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .toolbar { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
}
