/* The [hidden] attr must beat display:grid/flex rules (e.g. .login-wrap),
   or toggling .hidden in JS does nothing. */
[hidden] { display: none !important; }

/* Restora Admin Console — navy/teal, dependency-free */
:root {
  --navy: #0b2545;
  --navy-2: #102e4f;
  --teal: #33c4b3;
  --teal-dk: #1ba596;
  --ink: #14202e;
  --slate: #4a5a6a;
  --muted: #76889a;
  --line: #e4e9ef;
  --bg: #f5f8fb;
  --surface: #ffffff;
  --danger: #d9534f;
  --warn: #d97706;
  --ok: #2d7a4f;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(11,37,69,0.10);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.5; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }
a { color: var(--teal-dk); }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--navy); }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--navy); color: var(--teal); font-weight: 800; }
.brand-sub { color: var(--teal-dk); font-weight: 700; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; }
.login-card .brand { margin-bottom: 6px; }
.login-hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 18px; }
.login-card label { font-size: 0.78rem; font-weight: 700; color: var(--slate); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.login-card input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; }
.login-card input:focus { border-color: var(--teal); }
.login-card button { margin-top: 18px; background: var(--teal); color: #04231f; font-weight: 700; border: none; border-radius: 999px; padding: 12px; }
.login-card button:hover { background: var(--teal-dk); color: #fff; }
.error { color: var(--danger); font-size: 0.85rem; margin-top: 12px; }

/* ── App shell ── */
#appView { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; gap: 6px; }
.sidebar .brand { color: #fff; margin-bottom: 22px; }
.sidebar .brand-sub { color: var(--teal); }
.nav-item { text-align: left; background: transparent; color: rgba(255,255,255,0.75); border: none; padding: 11px 14px; border-radius: 9px; font-weight: 600; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--teal); color: #04231f; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,0.12); }
.whoami { font-size: 0.78rem; color: rgba(255,255,255,0.6); word-break: break-all; }
.link-btn { background: none; border: none; color: var(--teal); text-align: left; font-weight: 600; padding: 0; }

.main { padding: 28px 32px; overflow: auto; }
h1 { font-size: 1.5rem; color: var(--navy); margin-bottom: 4px; }
.sub { color: var(--muted); margin-bottom: 22px; font-size: 0.92rem; }
h2 { font-size: 1.05rem; color: var(--navy); margin: 22px 0 12px; }

/* ── Cards / metrics ── */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.metric .k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.metric .v { font-size: 1.7rem; font-weight: 800; color: var(--navy); margin-top: 4px; }
.metric .v.small { font-size: 1.15rem; }

/* ── Tables ── */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.toolbar input { flex: 1; min-width: 200px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
th { background: #f0f4f8; color: var(--slate); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover { background: #f7fafc; cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }
.muted { color: var(--muted); }
.right { text-align: right; }

/* ── Pills ── */
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.pill.ok { background: #eaf5ef; color: var(--ok); }
.pill.warn { background: #fef3e2; color: var(--warn); }
.pill.danger { background: #fdecea; color: var(--danger); }
.pill.neutral { background: #eef1f4; color: var(--slate); }

/* ── Buttons ── */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--navy); border-radius: 9px; padding: 8px 14px; font-weight: 600; font-size: 0.85rem; }
.btn:hover { background: #f0f4f8; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #04231f; }
.btn.primary:hover { background: var(--teal-dk); color: #fff; }
.btn.danger { background: #fff; border-color: #f0c8c6; color: var(--danger); }
.btn.danger:hover { background: #fdecea; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Drawer ── */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(11,37,69,0.35); }
.drawer-panel { position: absolute; top: 0; right: 0; height: 100%; width: min(560px, 94vw); background: var(--bg); box-shadow: var(--shadow); overflow: auto; padding: 24px; }
.drawer-panel h1 { font-size: 1.25rem; }
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 0.9rem; }
.kv .key { color: var(--muted); }
.kv .val { font-weight: 600; text-align: right; }
.close-x { float: right; background: none; border: none; font-size: 1.3rem; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 0.78rem; font-weight: 700; color: var(--slate); }
.field input, .field select, .field textarea { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: none; }
.inline { display: flex; gap: 8px; align-items: end; }
.inline .field { flex: 1; margin-bottom: 0; }

/* ── Toast ── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 600; font-size: 0.9rem; z-index: 100; }
.toast.err { background: var(--danger); }

@media (max-width: 720px) {
  #appView { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .sidebar nav { display: flex; gap: 4px; }
  .sidebar-foot { margin: 0 0 0 auto; border: none; padding: 0; flex-direction: row; gap: 12px; align-items: center; }
}
