/* StackHangar prototype — shared styles. Screens may add page-specific CSS
   in their own <style> block but should reuse these tokens and components. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #15181e;
  --muted: #5d6573;
  --accent: #2f5bea;
  --accent-ink: #ffffff;
  --accent-soft: #e8eeff;
  --danger: #c8322b;
  --danger-soft: #fdecea;
  --warn: #a05a00;
  --warn-soft: #fff3df;
  --ok: #1f7a43;
  --ok-soft: #e5f5eb;
  --info: #2f5bea;
  --info-soft: #e8eeff;
  --hygiene: #5d6573;
  --hygiene-soft: #eef0f3;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2a2f3a;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --accent: #6d8dff;
    --accent-ink: #0f1115;
    --accent-soft: #1d2747;
    --danger: #ff6b62;
    --danger-soft: #3a1a19;
    --warn: #f0b04f;
    --warn-soft: #362812;
    --ok: #4cc77d;
    --ok-soft: #14301f;
    --info: #6d8dff;
    --info-soft: #1d2747;
    --hygiene: #9aa3b2;
    --hygiene-soft: #232833;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a21; --surface-2: #1e222b; --border: #2a2f3a;
  --text: #e8eaee; --muted: #9aa3b2; --accent: #6d8dff; --accent-ink: #0f1115;
  --accent-soft: #1d2747; --danger: #ff6b62; --danger-soft: #3a1a19;
  --warn: #f0b04f; --warn-soft: #362812; --ok: #4cc77d; --ok-soft: #14301f;
  --info: #6d8dff; --info-soft: #1d2747; --hygiene: #9aa3b2; --hygiene-soft: #232833;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 4px 8px 16px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 13px;
}
.nav-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text);
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-count {
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
  background: var(--danger); color: #fff;
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.main { padding: 24px 32px 48px; max-width: 1080px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* Standalone pages (onboarding, approval, email) without the sidebar */
.solo { min-height: 100vh; display: grid; place-items: start center; padding: 48px 16px; }
.solo-card { width: 100%; max-width: 520px; }

/* ---------- Components ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.expired { background: var(--danger-soft); color: var(--danger); }
.badge.soon { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.hygiene { background: var(--hygiene-soft); color: var(--hygiene); }
.badge.prod { background: var(--danger-soft); color: var(--danger); }
.badge.staging { background: var(--warn-soft); color: var(--warn); }
.badge.dev { background: var(--hygiene-soft); color: var(--hygiene); }

.banner { border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--border); background: var(--surface-2); }
.banner.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.banner.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.banner.info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.banner.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 13px; }
.input, select.input, textarea.input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; width: 100%;
}
textarea.input { font-family: var(--mono); font-size: 12.5px; min-height: 160px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.secret { font-family: var(--mono); letter-spacing: 0.08em; color: var(--muted); }

.provider-icon {
  width: 28px; height: 28px; border-radius: 7px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
}

.steps { display: flex; gap: 6px; margin-bottom: 20px; }
.steps span { flex: 1; height: 4px; border-radius: 99px; background: var(--border); }
.steps span.done { background: var(--accent); }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); }

.kbd { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); }

/* Lock chip in sidebar */
.lock-chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12.5px; }
.lock-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.unlocked .lock-dot { background: var(--ok); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 16, 0.5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 420px; }

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 600; z-index: 60; box-shadow: var(--shadow);
}

/* Prototype-only annotation */
.proto-note {
  border: 1px dashed var(--accent); color: var(--accent); background: var(--accent-soft);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12.5px;
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; padding: 10px 16px; gap: 2px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .brand { padding: 4px 8px 4px 0; width: 100%; }
  .nav-link { padding: 6px 8px; }
  .sidebar-foot { margin-top: 0; width: 100%; flex-direction: row; }
  .main { padding: 16px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
