:root {
  color-scheme: light;
  --ink: #172329;
  --muted: #6e7d80;
  --line: #dfe8e5;
  --surface: #ffffff;
  --surface-soft: #f4f8f6;
  --canvas: #eef4f1;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-pale: #dff4ed;
  --warning: #b45309;
  --warning-pale: #fff5dd;
  --danger: #b42318;
  --danger-pale: #fff0ee;
  --success: #13795b;
  --success-pale: #e6f7ef;
  --shadow: 0 18px 50px rgba(32, 67, 57, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--canvas); font-size: 15px; line-height: 1.5; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(15, 118, 110, .28); outline-offset: 2px; }
[hidden] { display: none !important; }

.auth-layout { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 0%, #d9efe7, transparent 35%), var(--canvas); }
.auth-card { width: min(100%, 460px); padding: 44px; border: 1px solid rgba(15, 118, 110, .12); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.compact-card { width: min(100%, 500px); }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: #fff; background: var(--brand); font-weight: 800; letter-spacing: -.08em; }
.brand-mark.small { width: 32px; height: 32px; border-radius: 9px; font-size: 11px; }
.eyebrow { margin: 0 0 7px; color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; letter-spacing: -.035em; line-height: 1.15; }
h1 { margin-top: 18px; font-size: clamp(2.1rem, 5vw, 3.5rem); }
h2 { font-size: 1.65rem; }
h3 { font-size: 1.3rem; }
.lede { margin: 18px 0 28px; color: var(--muted); font-size: 1.05rem; }
.muted { margin: 8px 0 0; color: var(--muted); }
.optional { color: var(--muted); font-size: .85em; font-weight: 400; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; text-decoration: none; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--brand); }
.button-primary:hover { background: var(--brand-dark); }
.button-secondary { color: var(--brand-dark); border-color: #b9d7cf; background: #fff; }
.button-secondary:hover { border-color: var(--brand); background: var(--brand-pale); }
.button-ghost { min-height: 36px; padding: 7px 11px; color: var(--brand-dark); background: transparent; }
.button-wide { width: 100%; }
.button-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
.button-row > :only-child { margin-left: auto; }
.credential-metadata {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}
.credential-metadata strong, .credential-metadata small { display: block; margin-top: .25rem; }
.credential-metadata strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.credential-history { margin: .75rem 0 0; }
.button-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.button-danger:hover { background: #842018; }

.stack-form { display: grid; gap: 10px; }
.stack-form label, .tenant-control span { color: #425357; font-size: .88rem; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid #cbd9d5; border-radius: 10px; color: var(--ink); background: #fff; padding: 11px 12px; }
textarea { resize: vertical; font-family: "SFMono-Regular", Consolas, monospace; font-size: .88rem; }
input::placeholder, textarea::placeholder { color: #9aa9a6; }
.form-error { margin: 0; color: var(--danger); font-size: .9rem; }

.app-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; gap: 28px; padding: 22px 16px; color: #dcece8; background: #123d3b; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; color: #fff; font-size: .9rem; font-weight: 800; text-decoration: none; }
.main-nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: 10px; color: #bfdbd6; background: transparent; text-align: left; font-weight: 650; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.12); }
.sidebar-note { display: flex; gap: 10px; margin-top: auto; padding: 13px 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; color: #c9e1dc; font-size: .82rem; }
.sidebar-note small { display: inline-block; margin-top: 4px; color: #a7cac3; line-height: 1.35; }
.status-dot { flex: 0 0 8px; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: #64d49c; box-shadow: 0 0 0 4px rgba(100,212,156,.13); }
.nav-logout { margin-top: 0; color: #a7cac3; }
.main-content { min-width: 0; padding: 24px clamp(20px, 4vw, 60px) 60px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; max-width: 1240px; margin: 0 auto 38px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.tenant-role { color: var(--muted); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.permission-note { margin-bottom: 18px; }
.tenant-control { display: grid; gap: 3px; min-width: 175px; }
.tenant-control select { padding: 7px 9px; border-radius: 8px; font-size: .88rem; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--brand-dark); background: var(--brand-pale); font-size: .8rem; font-weight: 800; }
.page-view { max-width: 1240px; margin: 0 auto; }
.welcome-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.draft-badge { padding: 7px 10px; border-radius: 999px; color: #7d4b0a; background: var(--warning-pale); font-size: .78rem; font-weight: 750; white-space: nowrap; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card, .panel { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 6px 24px rgba(24, 60, 50, .035); }
.stat-card { display: grid; gap: 5px; padding: 18px; }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 700; }
.stat-card strong { font-size: 2rem; letter-spacing: -.06em; }
.stat-hint { color: #96a5a2; font-size: .76rem; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 22px; }
.panel { padding: 22px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.resource-list { display: grid; gap: 9px; }
.resource-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; }
.resource-item strong { display: block; }
.resource-item small { display: block; margin-top: 2px; color: var(--muted); }
.resource-state { padding: 5px 8px; border-radius: 999px; color: var(--success); background: var(--success-pale); font-size: .73rem; font-weight: 750; }
.empty-state { margin: 0; padding: 28px 12px; color: var(--muted); text-align: center; }
.guidance-panel { background: #f8fbfa; }
.steps-list { display: grid; gap: 18px; margin: 22px 0 0; padding: 0; list-style: none; }
.steps-list li { display: flex; gap: 12px; }
.steps-list li > span { display: grid; place-items: center; flex: 0 0 27px; width: 27px; height: 27px; border-radius: 50%; color: var(--brand-dark); background: var(--brand-pale); font-weight: 800; }
.steps-list strong, .steps-list small { display: block; }
.steps-list small { margin-top: 3px; color: var(--muted); }

.wizard-layout { display: grid; grid-template-columns: 245px minmax(0, 1fr); gap: 22px; align-items: start; }
.wizard-rail { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.wizard-rail li { display: flex; gap: 11px; padding: 12px 10px; border-radius: 11px; color: #879694; }
.wizard-rail li.active { color: var(--brand-dark); background: var(--brand-pale); }
.wizard-rail li.done { color: var(--success); }
.wizard-rail li > span { display: grid; place-items: center; flex: 0 0 27px; width: 27px; height: 27px; border: 1px solid currentColor; border-radius: 50%; font-size: .78rem; font-weight: 800; }
.wizard-rail strong, .wizard-rail small { display: block; }
.wizard-rail small { margin-top: 2px; color: var(--muted); font-size: .76rem; }
.wizard-panel { min-height: 470px; padding: clamp(22px, 4vw, 42px); border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.wizard-step { max-width: 680px; }
.wizard-step > h3 { margin-top: 5px; }
.wizard-step > .muted { margin-bottom: 26px; }
.inline-divider { display: flex; align-items: center; gap: 10px; margin: 22px 0; color: var(--muted); font-size: .85rem; }
.inline-divider::before, .inline-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.inline-form { display: flex; gap: 9px; }
.inline-form input { flex: 1; min-width: 0; }
.callout { display: grid; gap: 5px; margin: 18px 0; padding: 16px; border: 1px solid; border-radius: 12px; }
.callout span { color: var(--muted); font-size: .9rem; }
.callout-info { border-color: #b9d7cf; background: #f2fbf8; }
.callout-warning { border-color: #f2d49c; background: var(--warning-pale); }
.callout-success { border-color: #a8dfc4; background: var(--success-pale); }
.callout .button { justify-self: start; margin-top: 8px; }
.token-box { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px; border: 1px dashed #e1b760; border-radius: 9px; background: rgba(255,255,255,.7); }
.token-box code { flex: 1; overflow-wrap: anywhere; color: #754900; font-size: .8rem; }
.observation-result { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.field-pills { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.field-pill { padding: 5px 8px; border-radius: 999px; color: var(--brand-dark); background: var(--brand-pale); font-size: .78rem; }
.mapping-table { overflow-x: auto; margin: 20px 0; border: 1px solid var(--line); border-radius: 11px; }
.mapping-row { display: grid; grid-template-columns: minmax(130px, 1fr) 150px 80px; align-items: center; gap: 12px; min-width: 420px; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.mapping-row:last-child { border-bottom: 0; }
.mapping-row.header { color: var(--muted); background: var(--surface-soft); font-size: .76rem; font-weight: 800; text-transform: uppercase; }
.mapping-row code { font-size: .82rem; }
.mapping-row select { padding: 7px; font-size: .82rem; }
.mapping-row label { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: .8rem; }
.loading-state { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 160px; color: var(--muted); }
.spinner { width: 17px; height: 17px; border: 2px solid #c6d7d2; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.toast-region { position: fixed; z-index: 10; top: 20px; right: 20px; display: grid; gap: 8px; width: min(360px, calc(100vw - 40px)); }
.toast { padding: 12px 14px; border: 1px solid #b9d7cf; border-radius: 10px; color: var(--brand-dark); background: #f2fbf8; box-shadow: var(--shadow); font-size: .9rem; }
.toast.error { border-color: #f0b4ac; color: var(--danger); background: var(--danger-pale); }

@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 900px) { .app-shell { grid-template-columns: 1fr; } .sidebar { flex-direction: row; align-items: center; gap: 14px; padding: 12px 16px; } .main-nav { display: flex; flex: 1; } .sidebar-note, .nav-logout { display: none; } .nav-item { width: auto; } .stats-grid { grid-template-columns: repeat(2, 1fr); } .content-grid, .wizard-layout { grid-template-columns: 1fr; } .wizard-rail { display: flex; overflow-x: auto; gap: 3px; } .wizard-rail li { min-width: 145px; } .wizard-rail small { display: none; } }
@media (max-width: 600px) { .auth-card { padding: 30px 22px; } .main-content { padding: 18px 14px 40px; } .topbar, .welcome-row { align-items: flex-start; flex-direction: column; margin-bottom: 26px; } .topbar-actions { width: 100%; justify-content: space-between; } .tenant-control { flex: 1; } .stats-grid { gap: 9px; } .stat-card { padding: 13px; } .stat-card strong { font-size: 1.65rem; } .panel, .wizard-panel { padding: 17px; } .panel-heading, .button-row, .credential-metadata { align-items: stretch; flex-direction: column; } .button-row .button { width: 100%; } .inline-form { flex-direction: column; } .sidebar { overflow-x: auto; } .brand { flex: 0 0 auto; } }
