/* ───────────────────────────────────────────────
   larauna-control — Mission Control styles.
   House aesthetic (matches the larauna admin): warm light canvas, coral accent,
   Space Grotesk display + DM Sans body, 12px radius, quiet borders.
─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --bg: #FBFAF8; --bg-2: #F5F3EF; --bg-card: #FFFFFF;
  --border: #ECE7DF; --border-2: #E3DDD2;
  --accent: #FF5C2B; --accent-2: #FF4D6D; --accent-ink: #D6410F;
  --text: #17140F; --text-2: #514B43; --text-3: #8A8378;
  --green: #1f9d55; --green-bg: rgba(31,157,85,.12);
  --red: #d23b2f; --red-bg: rgba(210,59,47,.12);
  --amber: #c17d11; --amber-bg: rgba(193,125,17,.14);
  --blue: #2f6fed; --blue-bg: rgba(47,111,237,.12);
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', var(--font);
  --radius: 12px;
  --shadow: 0 8px 30px rgba(23,20,15,.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
.ic { display: inline-flex; vertical-align: middle; flex-shrink: 0; }

/* ── login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(120% 90% at 50% -10%, #FFF3EE, var(--bg) 60%); }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: flex; align-items: center; justify-content: center; color: #fff; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.login-card h1 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
.login-card p.sub { color: var(--text-3); font-size: .875rem; margin-top: -8px; }
.err { color: var(--red); font-size: .85rem; min-height: 1em; }

/* ── layout ── */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 22px 16px; gap: 6px; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 12px 18px; }
.nav-head { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); padding: 12px 12px 4px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius); font-size: .9rem; font-weight: 500; color: var(--text-2); cursor: pointer; border: 1px solid transparent; transition: all .15s; }
.nav-link:hover, .nav-link.active { background: rgba(255,92,43,.10); color: var(--accent-ink); border-color: rgba(255,92,43,.20); }
.nav-link.active .ic { color: var(--accent-ink); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.side-foot .muted { font-size: .72rem; color: var(--text-3); padding: 0 12px; }

.main { flex: 1; min-width: 0; padding: 30px 34px 60px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; }
.page-sub { color: var(--text-3); font-size: .9rem; margin-top: 3px; }

/* ── buttons ── */
.btn { font-family: var(--font); font-size: .875rem; font-weight: 600; border-radius: 10px; padding: 9px 15px; border: 1px solid var(--border-2); background: var(--bg-card); color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; transition: all .15s; }
.btn:hover { border-color: var(--text-3); color: var(--text); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none; box-shadow: 0 4px 14px rgba(255,92,43,.25); }
.btn-primary:hover { color: #fff; filter: brightness(1.04); }
.btn-danger { color: var(--red); border-color: rgba(210,59,47,.3); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn-sm { padding: 6px 11px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: default; }

/* ── cards / panels ── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; }
.grid { display: grid; gap: 16px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 17px; }
.stat .n { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; line-height: 1; }
.stat .l { font-size: .78rem; color: var(--text-3); margin-top: 6px; text-transform: uppercase; letter-spacing: .04em; }
.stat.ok .n { color: var(--green); } .stat.down .n { color: var(--red); } .stat.degraded .n, .stat.stale .n { color: var(--amber); } .stat.drift .n { color: var(--blue); }

/* ── client list ── */
.client-row { display: flex; align-items: center; gap: 16px; padding: 16px 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all .15s; }
.client-row:hover { border-color: var(--border-2); box-shadow: var(--shadow); }
.client-row .cr-main { flex: 1; min-width: 0; }
.client-row .cr-name { font-weight: 600; display: flex; align-items: center; gap: 9px; }
.client-row .cr-sub { font-size: .82rem; color: var(--text-3); margin-top: 3px; }
.client-row .cr-meta { text-align: right; font-size: .8rem; color: var(--text-3); white-space: nowrap; }

/* ── health badge / status dot ── */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.badge .ic { width: 13px; height: 13px; }
.hb-ok { background: var(--green-bg); color: var(--green); }
.hb-down { background: var(--red-bg); color: var(--red); }
.hb-degraded, .hb-stale { background: var(--amber-bg); color: var(--amber); }
.hb-unknown, .hb-paused { background: var(--bg-2); color: var(--text-3); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot.ok { background: var(--green); } .dot.down { background: var(--red); } .dot.degraded, .dot.stale { background: var(--amber); } .dot.unknown, .dot.paused { background: #C9C2B6; } .dot.drift { background: var(--blue); }
.drift-tag { background: var(--blue-bg); color: var(--blue); }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--bg-2); color: var(--text-2); border: 1px solid var(--border); }
.chip.src-package { background: var(--bg-2); color: var(--text-2); }
.chip.src-grant { background: rgba(255,92,43,.12); color: var(--accent-ink); border-color: rgba(255,92,43,.25); }
.chip.src-dependency { background: var(--blue-bg); color: var(--blue); border-color: rgba(47,111,237,.25); }
.chip.cat-sales { color: #b5471f; } .chip.cat-ai { color: #6d3bd2; } .chip.cat-security { color: #1f7a5c; } .chip.cat-analytics { color: #2f6fed; } .chip.cat-support { color: #b06a12; } .chip.cat-ops { color: var(--text-2); }
.chip.beta { background: var(--amber-bg); color: var(--amber); border-color: rgba(193,125,17,.25); }

/* ── feature toggle grid (the core screen) ── */
.feat-grid { display: flex; flex-direction: column; gap: 0; }
.feat-row { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--border); }
.feat-row:last-child { border-bottom: none; }
.feat-row.off { opacity: .58; }
.feat-ico { width: 34px; height: 34px; border-radius: 9px; background: var(--bg-2); display: flex; align-items: center; justify-content: center; color: var(--text-2); flex-shrink: 0; }
.feat-info { flex: 1; min-width: 0; }
.feat-name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feat-desc { font-size: .8rem; color: var(--text-3); margin-top: 2px; }
.feat-side { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.feat-ver { font-size: .74rem; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* iOS switch (house .switch) */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .sl { position: absolute; inset: 0; background: #D9D2C6; border-radius: 24px; transition: .2s; cursor: pointer; }
.switch .sl:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .sl { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.switch input:checked + .sl:before { transform: translateX(18px); }
.switch input:disabled + .sl { opacity: .55; cursor: default; }

/* ── detail layout ── */
.detail-cols { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-3); } .kv .v { font-weight: 500; text-align: right; }
.section-title { font-family: var(--font-display); font-size: 1.02rem; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.back-link { color: var(--text-3); font-size: .85rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; margin-bottom: 10px; }
.back-link:hover { color: var(--accent-ink); }

/* logs */
.log-item { display: flex; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border); font-size: .84rem; }
.log-item:last-child { border-bottom: none; }
.log-when { color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: .78rem; min-width: 132px; }
.log-ev { font-weight: 600; }
.log-detail { color: var(--text-2); }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .74rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.input, select.input, textarea.input { width: 100%; background: var(--bg-card); border: 1px solid var(--border-2); border-radius: 10px; padding: 10px 13px; color: var(--text); font-family: var(--font); font-size: .9rem; }
.input:focus { outline: none; border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(23,20,15,.42); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50; }
.modal { background: var(--bg-card); border-radius: 16px; width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; padding: 26px; box-shadow: 0 20px 60px rgba(23,20,15,.2); }
.modal h3 { font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 4px; }
.modal .mh { display: flex; justify-content: space-between; align-items: start; margin-bottom: 16px; }
.modal .x { cursor: pointer; color: var(--text-3); }
.keybox { background: #17140F; color: #F5F3EF; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; padding: 12px 14px; border-radius: 10px; word-break: break-all; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.keybox button { background: rgba(255,255,255,.14); color: #fff; border: none; border-radius: 7px; padding: 5px 10px; cursor: pointer; font-size: .76rem; font-weight: 600; }
.warn-note { background: var(--amber-bg); color: var(--amber); font-size: .82rem; padding: 10px 12px; border-radius: 9px; display: flex; gap: 8px; align-items: flex-start; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #17140F; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: .875rem; font-weight: 500; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 60; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: var(--red); }

.empty { text-align: center; color: var(--text-3); padding: 40px; font-size: .9rem; }
.muted { color: var(--text-3); }
.warn-line { color: var(--amber); font-size: .82rem; display: flex; gap: 7px; align-items: flex-start; padding: 4px 0; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }

/* responsive */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; gap: 4px; }
  .side-brand { padding: 4px 8px; } .nav-head { display: none; } .side-foot { flex-direction: row; margin: 0 0 0 auto; border: none; padding: 0; } .side-foot .muted { display: none; }
  .nav-link { padding: 8px 10px; font-size: .82rem; }
  .main { padding: 20px 16px 50px; }
  .detail-cols { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
}
