:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f0f3f6;
  --text: #111827;
  --muted: #667085;
  --line: #dfe4ea;
  --brand: #0f766e;
  --brand-strong: #0b5f59;
  --danger: #b42318;
  --warning: #b54708;
  --shadow: 0 20px 50px rgba(15, 23, 42, .08);
  --radius: 20px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); letter-spacing: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
h1, h2 { margin: 0; line-height: 1.1; }
h1 { font-size: 30px; }
h2 { font-size: 18px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 18px; background: rgba(255,255,255,.86); border-right: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: flex; gap: 12px; align-items: center; padding: 8px 10px 24px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: var(--brand); font-weight: 800; }
.brand small { display: block; color: var(--muted); margin-top: 3px; }
.nav { display: grid; gap: 6px; }
.nav a { padding: 12px 14px; border-radius: 14px; color: var(--muted); font-weight: 650; }
.nav a:hover, .nav a.active { background: var(--surface-soft); color: var(--text); }
.main { min-width: 0; padding: 28px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 24px; }
.eyebrow { display: block; color: var(--brand); text-transform: uppercase; font-size: 12px; font-weight: 800; margin-bottom: 8px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.user-chip { padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric, .panel, .login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric { padding: 22px; min-height: 122px; display: grid; align-content: space-between; }
.metric span { color: var(--muted); font-weight: 650; }
.metric strong { font-size: 30px; }
.metric.warning strong { color: var(--warning); }
.metric.danger strong { color: var(--danger); }
.content-grid { display: grid; gap: 18px; }
.content-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.connect-grid { margin-bottom: 18px; }
.connect-card { display: grid; gap: 18px; align-content: space-between; }
.connect-card p { color: var(--muted); line-height: 1.55; margin: 10px 0 0; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.link-button { border: 0; background: transparent; color: var(--brand); font-weight: 800; cursor: pointer; padding: 6px 0; }
.help-dialog > div { padding: 22px; }
.steps { margin: 0; padding-left: 22px; color: var(--text); display: grid; gap: 9px; }
.code-block { overflow-x: auto; margin: 0; padding: 14px; border-radius: 14px; background: var(--surface-soft); border: 1px solid var(--line); color: var(--text); font-size: 13px; line-height: 1.5; }
.panel { padding: 18px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.panel-head a { color: var(--brand); font-weight: 750; }
.toolbar { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.search { display: flex; gap: 10px; width: min(100%, 520px); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 999px; background: #e8f5f3; color: var(--brand-strong); font-weight: 750; font-size: 12px; }
.badge.danger { background: #fee4e2; color: var(--danger); }

.button { border: 0; min-height: 42px; padding: 0 16px; border-radius: 13px; font-weight: 800; cursor: pointer; transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--brand); color: #fff; box-shadow: 0 12px 26px rgba(15,118,110,.22); }
.button.secondary { background: var(--surface-soft); color: var(--text); }
.button.danger { background: #fee4e2; color: var(--danger); }
.button.small { min-height: 34px; padding: 0 11px; border-radius: 10px; }
.button.full { width: 100%; }

input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 13px; min-height: 44px; padding: 10px 12px; background: #fff; color: var(--text); outline: none; }
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(15,118,110,.12); }
label { display: grid; gap: 8px; color: var(--muted); font-weight: 700; }
.check { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.check input { width: 18px; min-height: 18px; }
.form-grid { display: grid; gap: 14px; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input, .inline-form select { width: 120px; min-height: 36px; }
.actions-cell { min-width: 520px; display: grid; gap: 8px; }

.dialog { border: 0; border-radius: 24px; padding: 0; width: min(720px, calc(100vw - 24px)); box-shadow: 0 35px 90px rgba(15,23,42,.25); }
.wizard-form { max-height: min(86vh, 920px); overflow: auto; }
.wizard-section { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb, var(--surface-soft) 38%, transparent); }
.description-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.html-editor { min-height: 220px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.html-preview { display: none; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); line-height: 1.55; }
.html-preview.active { display: block; }
.image-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.image-preview img, .thumb { width: 58px; height: 58px; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-soft); }
.thumb.empty { display: grid; place-items: center; color: var(--muted); }
.dialog::backdrop { background: rgba(15,23,42,.42); backdrop-filter: blur(6px); }
.dialog form { padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head button { border: 0; background: var(--surface-soft); border-radius: 999px; padding: 8px 12px; cursor: pointer; }
.flash-stack { display: grid; gap: 10px; margin-bottom: 18px; }
.flash { border-radius: 14px; padding: 12px 14px; background: #e8f5f3; color: var(--brand-strong); font-weight: 700; }
.flash.error, .flash.danger { background: #fee4e2; color: var(--danger); }

.auth-body { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 22px; }
.auth-shell { width: min(100%, 460px); }
.login-card { padding: 28px; display: grid; gap: 22px; }
.login-card p { color: var(--muted); margin: 10px 0 0; line-height: 1.55; }

@media (max-width: 1020px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .main { padding: 18px; }
  .metric-grid, .content-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .topbar, .toolbar, .top-actions { align-items: stretch; flex-direction: column; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid, .content-grid.two, .split { grid-template-columns: 1fr; }
  .panel { overflow-x: auto; }
  .inline-form { flex-wrap: wrap; }
  .actions-cell { min-width: 360px; }
}

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg: #101418; --surface: #171d22; --surface-soft: #222a31; --text: #f4f7fb; --muted: #a2acb8; --line: #2b343d; --shadow: 0 20px 50px rgba(0,0,0,.22); }
  input, textarea, select { background: #11171c; }
  .sidebar { background: rgba(23,29,34,.88); }
}
