/* ============================================================
   NGAA MANAGER PORTAL - main stylesheet
   Locked palette (calm, non-shouting, Flutter/Material-flavoured):
     deep indigo  #455799   -> primary / trust
     lavender     #b295c9   -> soft accent / gradient partner
     rose pink    #e2a9ca   -> warmth accent
     pale rose    #FEE5EE   -> surfaces / hero blush
     peach        #FFE0B9   -> highlight / optimism
   Warm near-white canvas, soft indigo ink, gentle elevation.
   ============================================================ */
:root {
    --primary: #455799;
    --primary-700: #37457d;
    --primary-900: #2a3563;
    --primary-100: #eaedf7;
    --primary-050: #f3f5fb;

    --lavender: #b295c9;
    --pink: #e2a9ca;
    --rose: #fee5ee;
    --peach: #ffe0b9;

    --ink: #2b2a40;
    --ink-soft: #5b5875;
    --muted: #8f8ba8;
    --line: #e9e6f0;
    --bg: #faf8fb;
    --card: #ffffff;

    --ok: #3f7d63;   --ok-bg: #e6f2ea;
    --warn: #a9772f;  --warn-bg: #fbeed7;
    --bad: #b0556a;   --bad-bg: #fbe4ea;
    --info: #4a5d9c;  --info-bg: #eaedf7;

    --radius: 18px;
    --radius-sm: 12px;
    --shadow-sm: 0 1px 2px rgba(43,42,64,.05);
    --shadow: 0 2px 6px rgba(43,42,64,.05), 0 14px 34px rgba(69,87,153,.10);
    --shadow-lg: 0 24px 60px rgba(69,87,153,.18);
    --grad: linear-gradient(135deg, var(--primary) 0%, var(--lavender) 100%);
    --grad-soft: linear-gradient(135deg, var(--rose) 0%, var(--primary-050) 55%, #fff 100%);
    --sidebar-w: 258px;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { display: block; }
h1, h2, h3 { letter-spacing: -.01em; }

/* ---------- Auth / login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.auth-hero { position: relative; overflow: hidden; background: var(--grad); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.auth-hero::after, .auth-hero::before { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.auth-hero::before { width: 380px; height: 380px; background: radial-gradient(circle, rgba(254,229,238,.55), transparent 70%); top: -120px; right: -80px; }
.auth-hero::after { width: 320px; height: 320px; background: radial-gradient(circle, rgba(255,224,185,.5), transparent 70%); bottom: -130px; left: -70px; }
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero h1 { font-size: 32px; margin: 8px 0 0; font-weight: 750; }
.auth-hero p { color: #eef0fb; max-width: 46ch; font-size: 16px; opacity: .95; }
.auth-hero .logo { height: 76px; width: auto; background: #fff; border-radius: 18px; padding: 12px 18px; box-shadow: 0 12px 32px rgba(23, 30, 60, .25); }
.auth-hero .hero-tag { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; width: max-content; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--grad-soft); }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 34px; box-shadow: var(--shadow-lg); }
.auth-card h2 { margin: 0 0 6px; font-size: 23px; color: var(--ink); }
.auth-card .sub { color: var(--ink-soft); margin: 0 0 24px; }

/* ---------- Layout / shell ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--primary-900); color: #d9dcf0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 200px; background: linear-gradient(160deg, rgba(178,149,201,.22), transparent); pointer-events: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.08); position: relative; }
.brand img { height: 36px; }
.brand strong { display: block; font-size: 16px; color: #fff; font-weight: 700; }
.brand small { color: #b9bfe0; font-size: 12px; }
.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; position: relative; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8f97c4; padding: 10px 14px 6px; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: #d3d7ee; font-weight: 500; transition: background .15s, color .15s; }
.nav-item .nav-ico { width: 18px; height: 18px; filter: brightness(0) invert(1); opacity: .72; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.is-active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 var(--pink); }
.nav-item.is-active .nav-ico { opacity: 1; }
.sidebar-foot { padding: 14px 20px; font-size: 12px; color: #8f97c4; border-top: 1px solid rgba(255,255,255,.08); }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 68px; background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 26px; position: sticky; top: 0; z-index: 5; }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-100); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.content { padding: 26px; max-width: 1280px; width: 100%; }

/* ---------- Cards / grids ---------- */
.grid { display: grid; gap: 18px; }
.grid-stats { grid-template-columns: repeat(auto-fill, minmax(218px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 16px; font-size: 16px; color: var(--ink); }
.stat { position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--grad); border-radius: 4px; }
.stat .label { color: var(--ink-soft); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 750; margin-top: 8px; color: var(--ink); }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 21px; }
.page-head .desc { color: var(--ink-soft); margin: 4px 0 0; font-size: 14px; }

/* ---------- Buttons ---------- */
.btn { border: 1px solid var(--primary); background: var(--primary); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 650; cursor: pointer; font-size: 14px; box-shadow: var(--shadow-sm); transition: background .15s, transform .05s, box-shadow .15s; }
.btn:hover { background: var(--primary-700); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--primary); border-color: var(--line); box-shadow: none; }
.btn-ghost:hover { background: var(--primary-050); }
.btn-soft { background: var(--primary-100); color: var(--primary-700); border-color: transparent; box-shadow: none; }
.btn-soft:hover { background: var(--primary-050); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 7px; font-weight: 600; }
.field input, .field select, .field textarea {
    width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; font-size: 15px; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--lavender); box-shadow: 0 0 0 4px var(--primary-100); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.error-text { color: var(--bad); font-size: 13px; margin-top: 4px; min-height: 16px; }
.field label .req { color: var(--bad); }
.field-error { display: block; color: var(--bad); font-size: 12px; line-height: 1.45; margin-top: 5px; }
.field-error:empty { display: none; }
.field input.invalid, .field select.invalid { border-color: var(--bad); background: #fffafb; }
/* Same signal, set by shared/js/validation.js rather than by the page. */
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--bad); }

/* ---------- Credential handover ---------- */
.hos-result {
    border: 1px solid var(--ok-bg); background: #f7fbf8; border-radius: 14px;
    padding: 16px; margin-bottom: 20px;
}
.hos-result[hidden] { display: none; }
.hos-result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.hos-result-head strong { font-size: 14px; color: var(--ok); }
.hos-result dl { margin: 0 0 12px; display: grid; gap: 9px; }
.hos-result dl > div { display: grid; grid-template-columns: 104px 1fr; gap: 10px; align-items: baseline; }
.hos-result dt { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.hos-result dd { margin: 0; font-size: 13px; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.hos-result .mono { font-family: ui-monospace, Consolas, monospace; font-weight: 650; }
.hos-warn { margin: 0 0 12px; font-size: 12px; color: var(--warn); background: var(--warn-bg); padding: 8px 10px; border-radius: 9px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { color: var(--ink-soft); font-weight: 600; background: var(--primary-050); }
.table th:first-child { border-top-left-radius: 12px; }
.table th:last-child { border-top-right-radius: 12px; }
.table tr:hover td { background: var(--primary-050); }
.table .link { color: var(--primary); font-weight: 600; }

/* ---------- Badges / status ---------- */
.badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 650; text-transform: capitalize; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #eef0f4; color: var(--ink-soft); }

/* ---------- States ---------- */
.loading { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); padding: 24px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; color: var(--ink-soft); padding: 44px 20px; background: var(--card); border: 1px dashed var(--lavender); border-radius: var(--radius); }
.empty-state.error { color: var(--bad); border-color: var(--bad-bg); background: var(--bad-bg); }
.banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 50; max-width: 90vw; }
.banner[data-kind="warn"] { background: var(--warn); }
.banner[data-kind="error"] { background: var(--bad); }
.banner[data-kind="success"] { background: var(--ok); }
.banner.hidden { display: none; }

/* ---------- Charts ---------- */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap canvas { max-height: 260px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 13px; color: var(--ink-soft); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.muted { color: var(--muted); }
.mt { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .form-row { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; }
}
