@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=IBM+Plex+Mono:wght@500;600&family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================================
   Insights Reporter — app design system (B5a)
   Shared by the logged-in app, auth pages, and system pages.
   The marketing landing page has its own landing.css and is untouched.
   ========================================================================== */

:root {
    --ink:        #181b22;
    --muted:      #5b6472;
    --bg:         #f4f6f9;
    --surface:    #ffffff;
    --surface-2:  #fafbfc;
    --border:     #e4e7ec;
    --border-2:   #eef1f4;

    --accent:      #1746a2;   /* brand blue, shared with the landing page */
    --accent-ink:  #0f2f6e;
    --accent-soft: #eaf0fb;

    --ok:    #0a7d33; --ok-soft:    #e7f4ec;
    --amber: #9a6700; --amber-soft: #fbf0d9;
    --bad:   #b00020; --bad-soft:   #fbe9ec;

    --header-bg: rgba(255,255,255,0.92);
    --radius:   0.6rem;
    --radius-sm:0.4rem;
    --shadow:   0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
    --shadow-2: 0 4px 12px rgba(16,24,40,.08);

    --display: "Fraunces", Georgia, "Times New Roman", serif;
    --sans:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono:    "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    /* a thin brand bar at the very top — a quiet "always-on watch" cue */
    border-top: 3px solid var(--accent);
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.2; color: var(--ink); }
h1 { font-size: 1.85rem; margin: 0 0 0.4rem; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; margin: 1.6rem 0 0.6rem; }
h3 { font-size: 1.05rem; margin: 0 0 0.35rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

p { margin: 0 0 0.9rem; }

.muted { color: var(--muted); }
.ok  { color: var(--ok);  font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
.tagline { font-size: 1.1rem; color: var(--muted); margin: 0 0 1rem; }
.eyebrow {
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--accent); margin: 0 0 0.35rem;
}

/* --- buttons --------------------------------------------------------------- */
.btn, button {
    font: 600 0.95rem/1 var(--sans);
    cursor: pointer;
}
.btn {
    display: inline-block;
    padding: 0.62rem 1.1rem;
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background .15s ease;
}
.btn:hover { background: var(--accent-ink); border-color: var(--accent-ink); text-decoration: none; }
.btn-block { display: block; width: 100%; text-align: center; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}

/* generic standalone button (logout, switch "Go", form submits not using .btn) */
form button:not(.btn) {
    padding: 0.55rem 0.95rem;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
form button:not(.btn):hover { border-color: var(--accent); color: var(--accent); }

/* ============================================================================
   APP SHELL (logged-in chrome)
   ========================================================================== */
.app-header {
    position: sticky; top: 0; z-index: 20;
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}
.app-header-inner {
    max-width: 64rem; margin: 0 auto;
    display: flex; align-items: center; gap: 1rem;
    padding: 0.7rem 1.25rem; flex-wrap: wrap;
}
.app-brand {
    display: inline-flex; align-items: center; gap: 0.55rem;
    font-family: var(--display); font-weight: 600; font-size: 1.05rem;
    color: var(--ink); text-decoration: none; white-space: nowrap;
}
.app-brand:hover { text-decoration: none; }
.app-mark {
    display: inline-grid; place-items: center;
    width: 1.7rem; height: 1.7rem; border-radius: 0.45rem;
    background: var(--accent); color: #fff;
    font: 700 0.8rem/1 var(--mono); letter-spacing: 0.02em;
}
.app-switch { display: inline-flex; align-items: center; gap: 0.4rem; margin-left: 0.25rem; }
.app-switch select {
    font: 500 0.9rem var(--sans); color: var(--ink);
    padding: 0.4rem 0.55rem; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--surface-2); max-width: 14rem;
}
.app-switch button { padding: 0.4rem 0.7rem; }
.app-spacer { flex: 1 1 auto; }
.app-nav { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.app-nav-link {
    padding: 0.4rem 0.7rem; border-radius: var(--radius-sm);
    color: var(--muted); font-weight: 500; text-decoration: none; font-size: 0.95rem;
}
.app-nav-link:hover { background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; }
.app-nav-link.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.app-user {
    display: inline-flex; align-items: center; gap: 0.6rem;
    padding-left: 0.8rem; margin-left: 0.3rem; border-left: 1px solid var(--border);
}
.app-user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.app-user-name { font-weight: 600; font-size: 0.9rem; }
.app-user-role { font-size: 0.74rem; color: var(--muted); }
.app-logout { display: inline; }
.app-logout button { padding: 0.4rem 0.7rem; font-size: 0.85rem; }

.app-main { max-width: 64rem; margin: 0 auto; padding: 2rem 1.25rem 3.5rem; }
.app-footer {
    max-width: 64rem; margin: 0 auto; padding: 1.5rem 1.25rem 2.5rem;
    color: var(--muted); font-size: 0.82rem; border-top: 1px solid var(--border-2);
}

/* page heading block */
.page-head { margin-bottom: 1.4rem; }

/* --- cards ----------------------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.2rem 1.3rem; margin: 0 0 1.2rem;
}
.card-quiet { background: var(--surface-2); box-shadow: none; }

/* --- locations + switcher (B5) --------------------------------------------- */
.loc-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.2rem 1.3rem; margin: 0 0 1.3rem;
}
.loc-label {
    margin: 0 0 0.25rem; font-size: 0.72rem; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.loc-name { margin: 0 0 0.9rem; font-family: var(--display); font-size: 1.35rem; font-weight: 600; }
.loc-switch { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.4rem; }
.loc-switch select {
    padding: 0.45rem 0.55rem; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font: inherit; background: var(--surface-2);
}
.loc-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.loc-list li {
    padding: 0.7rem 0.2rem; border-bottom: 1px solid var(--border-2);
    display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem;
}
.badge-current {
    margin-left: 0.4rem; padding: 0.12rem 0.5rem; border-radius: 999px;
    background: var(--ok-soft); color: var(--ok);
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}

/* --- pills / action links (admin/team/app) --------------------------------- */
.pill {
    display: inline-block; margin: 0 0 0.8rem; padding: 0.2rem 0.7rem;
    border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink);
    font-size: 0.74rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
}
.app-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.3rem 0; }
.action-link {
    display: inline-block; padding: 0.55rem 0.95rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--accent); font-weight: 600; text-decoration: none;
}
.action-link:hover { border-color: var(--accent); text-decoration: none; }

/* --- forms (shared) -------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 0.9rem; max-width: 26rem; margin: 0 0 1.5rem; }
.stack label, .field label, .label { font-weight: 600; font-size: 0.92rem; }
.stack input, .field input, input[type=text], input[type=email], input[type=password], select {
    width: 100%; padding: 0.6rem 0.7rem; font: inherit;
    color: var(--ink);
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
/* native dropdown menu items — keep readable in dark mode */
select option { background: var(--surface); color: var(--ink); }
/* header + switch selects too */
.app-switch select, .loc-switch select { color: var(--ink); }
.field { margin: 0 0 0.9rem; }
.form-error { color: var(--bad); background: var(--bad-soft); padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); margin: 0 0 1rem; }
.form-ok    { color: var(--ok);  background: var(--ok-soft);  padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); margin: 0 0 1rem; }
.form-note  { color: var(--muted); font-size: 0.88rem; margin: 0.5rem 0 0; }
.inline-logout button { padding: 0.5rem 0.9rem; }

/* --- auth pages (login/register/setup) ------------------------------------- */
.centre { max-width: 40rem; margin: 0 auto; padding: 3.5rem 1.25rem; }
.auth-card {
    max-width: 26rem; margin: 3.5rem auto; padding: 2rem 1.8rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-2);
}
.auth-card h1 { font-size: 1.5rem; }

/* --- system status table --------------------------------------------------- */
table.status { border-collapse: collapse; width: 100%; margin: 1rem 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.status th, table.status td { text-align: left; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border-2); vertical-align: top; }
table.status th { width: 12rem; color: var(--muted); font-weight: 600; }
table.status tr:last-child th, table.status tr:last-child td { border-bottom: 0; }

/* --- narrow screens -------------------------------------------------------- */
@media (max-width: 640px) {
    .app-header-inner { gap: 0.6rem; }
    .app-brand { font-size: 1rem; }
    .app-user { padding-left: 0.6rem; }
    .app-user-meta { display: none; }          /* keep just the logout on tiny screens */
    .app-switch select { max-width: 9rem; }
    .app-main { padding: 1.5rem 1.1rem 3rem; }
    h1 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ============================================================================
   DARK THEME (B7) — explicit [data-theme="dark"] + System (prefers dark)
   ========================================================================== */
[data-theme="dark"] {
    --ink:#e6e9ef; --muted:#9aa3b2; --bg:#10131a; --surface:#181c25; --surface-2:#1f2531;
    --border:#2a313d; --border-2:#222937;
    --accent:#6e9bff; --accent-ink:#9bb8ff; --accent-soft:#1b2740;
    --ok:#4ec77d; --ok-soft:#15301f; --amber:#d6a23a; --amber-soft:#322712; --bad:#ef6b7d; --bad-soft:#33191f;
    --header-bg: rgba(18,22,30,0.9);
    --shadow:0 1px 2px rgba(0,0,0,.35),0 1px 3px rgba(0,0,0,.45);
    --shadow-2:0 6px 18px rgba(0,0,0,.55);
}
@media (prefers-color-scheme: dark) {
    [data-theme="system"] {
        --ink:#e6e9ef; --muted:#9aa3b2; --bg:#10131a; --surface:#181c25; --surface-2:#1f2531;
        --border:#2a313d; --border-2:#222937;
        --accent:#6e9bff; --accent-ink:#9bb8ff; --accent-soft:#1b2740;
        --ok:#4ec77d; --ok-soft:#15301f; --amber:#d6a23a; --amber-soft:#322712; --bad:#ef6b7d; --bad-soft:#33191f;
        --header-bg: rgba(18,22,30,0.9);
        --shadow:0 1px 2px rgba(0,0,0,.35),0 1px 3px rgba(0,0,0,.45);
        --shadow-2:0 6px 18px rgba(0,0,0,.55);
    }
}

/* ============================================================================
   SETTINGS (B6/B7/B8)
   ========================================================================== */
.theme-options { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0; }
.theme-option {
    display: inline-flex; align-items: center; gap: 0.45rem;
    padding: 0.55rem 0.9rem; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--surface-2);
    cursor: pointer; font-weight: 500;
}
.theme-option.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.theme-option input { width: auto; margin: 0; }

.device-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.device-list li {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.75rem 0; border-bottom: 1px solid var(--border-2); flex-wrap: wrap;
}
.device-list li:last-child { border-bottom: 0; }
.device-meta { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.device-meta .muted { font-size: 0.85rem; }
.device-revoke { margin: 0; }
.device-revoke button { font-size: 0.85rem; }

/* --- Business details / fingerprint (B9) ----------------------------------- */
.detail-list { margin: 0; }
.detail-row {
    display: grid; grid-template-columns: 12rem 1fr; gap: 0.5rem 1rem;
    padding: 0.6rem 0; border-bottom: 1px solid var(--border-2);
}
.detail-row:last-child { border-bottom: 0; }
.detail-row dt { color: var(--muted); font-weight: 600; margin: 0; }
.detail-row dd { margin: 0; word-break: break-word; }
.field-row { display: flex; gap: 0.85rem; }
.field-row label { flex: 1 1 0; }
fieldset.socials {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 0.9rem 1rem; margin: 0; display: flex; flex-direction: column; gap: 0.7rem;
}
fieldset.socials legend { font-weight: 600; padding: 0 0.4rem; color: var(--muted); }
@media (max-width: 560px) {
    .detail-row { grid-template-columns: 1fr; gap: 0.1rem; }
    .field-row { flex-direction: column; gap: 0.85rem; }
}
