/* ============================================================
   CyberNest Gateway — control plane
   Brand guide: Orange #F05A28 · Green #19A974 · Dark Slate #1F2933
                Tagline grey #8A929B · Montserrat
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
    --brand: #F05A28;
    --brand-dark: #C7431A;
    --brand-soft: #FFE9DC;
    --accent: #19A974;
    --accent-dark: #12805A;
    --accent-soft: #DCF3EA;
    --sidebar: #1F2933;
    --sidebar-2: #161d24;
    --sidebar-text: #b9c0c7;
    --grey: #8A929B;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --border: #e6e8eb;
    --text: #1F2933;
    --muted: #6b7280;
    --danger: #dc2626;
    --ok: #19A974;
    --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; font-weight: 600; margin: 0 0 .75rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.mono, .mono * { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }

/* Shell */
.app-shell { display: flex; min-height: 100vh; }
.content { flex: 1; padding: 2rem 2.5rem; max-width: 1180px; }

/* Sidebar */
.sidebar { width: 240px; flex: 0 0 240px; background: var(--sidebar); color: var(--sidebar-text); padding: 1.1rem 0; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 0 1.15rem 1.15rem; color: #fff; }
.brand svg { width: 30px; height: 30px; flex: 0 0 auto; }
.brand-mark { color: var(--brand); font-size: 1.6rem; }   /* legacy text mark */
.brand-text { font-weight: 700; line-height: 1.1; font-size: 1rem; }
.brand-text small { display: block; color: var(--grey); font-weight: 500; font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; margin-top: 3px; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list li a {
    display: block; padding: .55rem 1.15rem; color: var(--sidebar-text);
    border-left: 3px solid transparent; font-size: .875rem; font-weight: 500;
}
.nav-list li a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.nav-list li a.active { color: #fff; background: rgba(240,90,40,.16); border-left-color: var(--brand); }
.nav-group { padding: 1rem 1.15rem .3rem; font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--grey); font-weight: 600; }

/* Cards / stats */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .9rem; margin: 1.5rem 0; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.1rem; box-shadow: 0 1px 2px rgba(31,41,51,.04); }
.stat-num { display: block; font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: .76rem; font-weight: 500; }
.stat.accent .stat-num { color: var(--brand); }
.stat.good .stat-num { color: var(--accent-dark); }
.stat.warn .stat-num { color: var(--danger); }

/* Dashboard navigation tiles */
.nav-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .9rem; margin: 1rem 0 1.75rem; }
.nav-card {
    display: block; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
    padding: 1rem 1.1rem; color: var(--text); box-shadow: 0 1px 2px rgba(31,41,51,.04);
    border-top: 3px solid var(--brand); transition: transform .12s, box-shadow .12s;
}
.nav-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(31,41,51,.10); }
.nav-card .nc-title { font-weight: 600; display: flex; align-items: center; gap: .45rem; }
.nav-card .nc-desc { color: var(--muted); font-size: .78rem; margin-top: .3rem; line-height: 1.45; }
.nav-card .nc-count { float: right; font-size: .74rem; color: var(--brand); font-weight: 700; }
.nav-card.accent { border-top-color: var(--accent); }
.nav-card.accent .nc-count { color: var(--accent-dark); }

.section-title { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--grey); font-weight: 700; margin: 1.75rem 0 .5rem; }
.crumb { font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.crumb a { color: var(--muted); } .crumb a:hover { color: var(--brand); }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; margin: 1rem 0; box-shadow: 0 1px 2px rgba(31,41,51,.04); }

/* Tables */
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table.grid th, table.grid td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
table.grid th { background: #f2f4f6; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: #fafbfc; }
table.grid.compact th, table.grid.compact td { padding: .4rem .6rem; }
table.grid th.num, table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.on { background: var(--brand-soft); }
table.grid tr.row-blocked { background: #fef2f2; }

/* Forms */
.form-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.form-grid label, .form-row label { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; color: var(--muted); font-weight: 500; }
.form-grid label.check { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); }
input, select, textarea { padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input.narrow { max-width: 120px; }

/* Buttons */
.btn { background: var(--brand); color: #fff; border: none; padding: .5rem .9rem; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; font-size: .84rem; }
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.subtle { background: #eef0f2; color: var(--text); font-weight: 500; }
.btn.subtle:hover { background: #e2e5e8; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.btn.ghost:hover { background: #f2f4f6; }

/* Tags / badges / alerts */
.tag { display: inline-block; background: #eef0f2; color: var(--muted); padding: .1rem .55rem; border-radius: 20px; font-size: .7rem; font-weight: 600; }
.tag-on { background: var(--accent-soft); color: var(--accent-dark); }
.tag-brand { background: var(--brand-soft); color: var(--brand-dark); }
.chips { display: flex; gap: .4rem; margin-bottom: .75rem; flex-wrap: wrap; }
.badge { padding: .1rem .5rem; border-radius: 6px; font-size: .72rem; font-weight: 600; }
.badge-block { background: #fee2e2; color: var(--danger); }
.badge-redact { background: #e0e7ff; color: #4338ca; }
.badge-pseudonymize { background: #ede9fe; color: #6d28d9; }
.badge-mask { background: #cffafe; color: #0e7490; }
.badge-flag { background: #fef9c3; color: #a16207; }
.badge-allow { background: #f1f5f9; color: var(--muted); }
.alert { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: .8rem 1rem; border-radius: 10px; margin: 1rem 0; }
.err { color: var(--danger); margin-left: .6rem; }
.saved { color: var(--ok); }

/* Models: inline endpoint probe result */
.test-ok, .test-fail { font-size: .82rem; }
.test-ok { background: var(--accent-soft); color: var(--accent-dark); }
.test-fail { background: #fef2f2; color: var(--danger); word-break: break-word; }

/* Auth: sidebar user + logout */
.nav-user { margin-top: auto; padding: 1rem 1.15rem 0; border-top: 1px solid rgba(255,255,255,.08); }
.nav-user-name { display: block; color: #fff; font-size: .8rem; margin-bottom: .5rem; }
.signout { background: transparent; border: 1px solid rgba(255,255,255,.22); color: var(--sidebar-text); padding: .35rem .7rem; border-radius: 7px; cursor: pointer; font: inherit; font-size: .78rem; }
.signout:hover { background: rgba(255,255,255,.08); color: #fff; }

/* Login */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center;
               background: linear-gradient(135deg,#1F2933 0%,#2b3742 55%,#1F2933 100%); }
.login-card { background: var(--panel); border-radius: 16px; padding: 2.25rem 2rem; width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-brand { color: var(--text); font-weight: 700; margin-bottom: 1rem; text-align: center; }
.login-brand .brand-mark { color: var(--brand); }
.login-brand small { display: block; color: var(--muted); font-weight: 500; font-size: .76rem; }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: .5rem; margin-bottom: 1.25rem; }
.login-logo svg { width: 56px; height: 56px; }
.login-name { font-weight: 700; font-size: 1.15rem; }
.login-name .sec { color: var(--accent); }
.login-sub { color: var(--muted); font-size: .78rem; }
.login-foot { text-align: center; color: var(--grey); font-size: .66rem; margin-top: 1.1rem; letter-spacing: .12em; text-transform: uppercase; }
.login-card h1 { font-size: 1.05rem; font-weight: 600; margin-bottom: 1.1rem; text-align: center; }
.login-card label { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; color: var(--muted); margin-bottom: .9rem; font-weight: 500; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; margin-top: .4rem; padding: .65rem; }
.login-card .validation-message { color: var(--danger); font-size: .78rem; }

/* Tabs */
.tabs { display: flex; gap: .3rem; margin: 1rem 0; }
.tab { background: transparent; border: 1px solid var(--border); padding: .45rem .9rem; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; color: var(--muted); }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Provider editor (NestGovAI-style two-column form) */
.editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.9rem; }
@media (max-width: 860px) { .editor-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1.1rem; }
.field > label, .field > span.lbl { font-size: .82rem; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; }
.field .hint { font-size: .72rem; color: var(--grey); }
.chips-tools { display: flex; align-items: center; gap: .6rem; margin-top: .1rem; }
.chips-wrap { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; max-height: 260px; overflow-y: auto; padding: .15rem; }
.chip { border: 1px solid var(--border); border-radius: 20px; padding: .22rem .66rem; font-size: .76rem; cursor: pointer; background: #fff; color: var(--text); white-space: nowrap; }
.chip:hover { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.adv { border-top: 1px solid var(--border); margin-top: .5rem; padding-top: .5rem; }
.adv > summary { cursor: pointer; font-weight: 600; font-size: .84rem; color: var(--brand-dark); list-style: none; }
.adv > summary::-webkit-details-marker { display: none; }
.adv > summary::before { content: "▸ "; color: var(--brand); }
.adv[open] > summary::before { content: "▾ "; }
.adv[open] > summary { margin-bottom: 1rem; }

/* Progress bar (quota usage) */
.bar { height: 7px; background: #eef0f2; border-radius: 20px; overflow: hidden; margin-top: .35rem; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 20px; }
.bar.warn > span { background: var(--brand); }
.bar.over > span { background: var(--danger); }
