:root {
  --ink: #201c1d;
  --paper: #f4f3f2;
  --panel: #ffffff;
  --panel-2: #f0eeee;
  --line: #e4e0e0;
  --line-strong: #cfc9c9;
  --muted: #756f70;
  --brand: #ed7b18;
  --brand-2: #d6532b;
  --brand-soft: rgba(237, 123, 24, .13);
  --on-brand: #ffffff;
  --green: #1f7a52;
  --red: #c0392f;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --shadow: 0 10px 28px rgba(32, 28, 29, .08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-family: "Archivo", "IBM Plex Sans", sans-serif; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--brand-2); }
.muted { color: var(--muted); }
button, input, select { font: inherit; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }

/* ============ AUTH ============ */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-panel {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 26px;
  box-shadow: var(--shadow);
}
.auth-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--ink); color: var(--brand);
  font-family: "Archivo", sans-serif; font-weight: 800; font-size: 18px;
  box-shadow: inset 0 -3px 0 var(--brand);
}
.brand-mark-sm { width: 34px; height: 34px; border-radius: var(--r-sm); font-size: 15px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup > div { display: grid; }
.brand-lockup strong { font-family: "Archivo", sans-serif; }
.brand-lockup small { color: var(--muted); font-size: 11px; font-weight: 600; }
.auth-title { font-size: 22px; margin-bottom: 4px; }
.auth-sub { font-size: 14px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 6px; color: var(--brand-2); font-weight: 800; text-transform: uppercase; font-size: 11.5px; letter-spacing: .04em; }

.field { display: block; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field + .field, .field + .form-error { margin-top: 14px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input { padding-left: 42px; }
.input-icon { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.input-action {
  position: absolute; right: 6px; background: none; border: 0; color: var(--muted);
  padding: 8px; cursor: pointer; display: grid; place-items: center; border-radius: var(--r-sm);
}
.input-action:hover { color: var(--ink); background: var(--panel-2); }

input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=number], select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.form-error {
  display: flex; align-items: center; gap: 8px; color: var(--red); font-size: 13px;
  background: rgba(192, 57, 47, .08); padding: 10px 12px; border-radius: var(--r-md); margin-top: 14px;
}
.form-error:empty { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--r-md); padding: 12px 18px;
  font-size: 15px; font-weight: 600; color: var(--ink); background: var(--panel-2);
  cursor: pointer; transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(0.97); }
.btn-block { width: 100%; margin-top: 18px; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line-strong); }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); background: var(--panel-2); }

.segmented { display: inline-flex; padding: 3px; gap: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.seg { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.seg.is-active, .language-row .is-active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.language-row { display: flex; gap: 3px; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-md); width: fit-content; }
.language-row button { border: 0; border-radius: 9px; padding: 7px 13px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }

.auth-foot { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.powered { font-size: 12px; text-align: center; }
.form-note, .link-note { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; text-align: center; }

/* ============ APP SHELLS ============ */
.admin-shell { height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); overflow: hidden; }
.admin-rail { padding: 20px 14px; background: var(--ink); color: #fff; overflow-y: auto; display: flex; flex-direction: column; }
.admin-rail .brand-lockup { padding: 0 6px; }
.admin-rail .brand-lockup strong, .admin-rail .brand-lockup small { color: #fff; }
.admin-rail .brand-lockup small { color: rgba(255,255,255,.6); }
.admin-rail nav { display: grid; gap: 2px; margin-top: 24px; flex: 1; }
.admin-rail a { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.72); text-decoration: none; padding: 10px 11px; border-radius: var(--r-md); font-size: 13.5px; font-weight: 600; }
.admin-rail a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-rail a.is-active { background: var(--brand); color: #201c1d; }
.rail-foot { display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.12); }
.rail-foot a, .rail-foot button { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.6); text-decoration: none; padding: 9px 11px; border-radius: var(--r-md); font-size: 13px; font-weight: 600; background: none; border: 0; cursor: pointer; text-align: left; width: 100%; }
.rail-foot a:hover, .rail-foot button:hover { background: rgba(255,255,255,.08); color: #fff; }

.admin-main { min-width: 0; padding: 26px clamp(20px, 4vw, 46px); overflow: auto; }
.admin-main > header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.admin-main h1 { font-size: 24px; }
.environment-badge { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); color: var(--muted); font-size: 12.5px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(31,122,82,.12); display: inline-block; flex: none; }

.admin-grid { margin-top: 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.metric { padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); }
.metric strong { display: block; font-size: 22px; font-family: "Archivo", sans-serif; }
.metric span { color: var(--muted); font-size: 12.5px; }
.admin-note { color: var(--muted); font-size: 13px; }
.admin-error { color: var(--red); }

.inline-form { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin: 16px 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); }
.inline-form input, .inline-form select { width: auto; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 10px; background: #fff; color: var(--ink); }
.inline-form button, .data-table button { border: 0; border-radius: var(--r-sm); padding: 8px 13px; cursor: pointer; font-weight: 600; background: var(--brand); color: var(--on-brand); font-size: 13px; }
.data-table button { padding: 5px 9px; font-size: 12px; margin-right: 5px; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.data-table th, .data-table td { text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--line); font-size: 13px; }
.data-table th { background: var(--panel-2); color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 10.5px; letter-spacing: .04em; }
.data-table tr:last-child td { border-bottom: 0; }

/* ============ LEGAL / STATIC PAGES ============ */
.legal-page { min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; }
.legal-card { max-width: 620px; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 32px; box-shadow: var(--shadow); }
.legal-card h1 { font-size: 26px; margin-bottom: 8px; }
.legal-card h2 { font-size: 14px; margin: 22px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--brand-2); }
.legal-card p, .legal-card li { color: var(--ink); font-size: 14px; line-height: 1.6; }
.legal-card ul { padding-left: 18px; margin: 0; }
.legal-card .brand-mark { margin-bottom: 16px; }

@media (max-width: 820px) {
  .admin-shell { height: auto; min-height: 100vh; grid-template-columns: 1fr; overflow: visible; }
  .admin-rail { position: static; padding: 14px; }
  .admin-rail nav { display: flex; gap: 4px; margin-top: 14px; overflow-x: auto; padding-bottom: 4px; }
  .admin-rail nav a { flex: none; }
  .rail-foot { display: flex; gap: 4px; border-top: 0; padding-top: 8px; }
  .rail-foot a, .rail-foot button { width: auto; flex: none; }
  .admin-main { overflow: visible; }
}
