/*
 * Codex — administration styles.
 * Plain CSS served from public/ (no build step, no external fonts or CDNs).
 */

:root {
    --navy-950: #0a1430;
    --navy-900: #0f1f3d;
    --navy-800: #16294d;
    --navy-700: #1f3a6b;
    --blue-600: #1f5fcc;
    --blue-500: #2f6fe0;
    --blue-100: #dbe7ff;
    --blue-50: #eef4ff;

    --ink: #0f172a;
    --text: #1e293b;
    --muted: #5b6b82;
    --border: #dbe3ef;
    --border-strong: #c3cfe0;
    --surface: #ffffff;
    --background: #f3f6fb;

    --green-700: #0d6e46;
    --green-50: #e6f5ed;
    --amber-700: #8a4b00;
    --amber-50: #fff3df;
    --red-700: #b42318;
    --red-50: #fdecea;
    --slate-600: #475569;
    --slate-100: #eef1f5;

    --focus: #2f6fe0;
    --focus-on-dark: #9cc1ff;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 31, 61, 0.06);
    --shadow: 0 1px 3px rgba(15, 31, 61, 0.08), 0 8px 24px rgba(15, 31, 61, 0.06);

    --sidebar-width: 264px;
    /* Side padding of the top bar and page content: grows a little on wide screens. */
    --gutter: clamp(24px, 2.4vw, 48px);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; color: var(--ink); line-height: 1.25; }

p { margin: 0; }

a { color: var(--blue-600); }

svg { flex-shrink: 0; }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 16px;
    /* Far enough up that its shadow does not show at the top of the page. */
    top: -120px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--navy-900);
    font-weight: 600;
    box-shadow: var(--shadow);
}

.skip-link:focus { top: 16px; }

.muted { color: var(--muted); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:disabled { cursor: not-allowed; opacity: 0.7; }

.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-700); }

.btn-ghost {
    min-height: 40px;
    padding: 0 14px;
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--navy-800);
}
.btn-ghost:hover { background: var(--blue-50); border-color: var(--blue-100); }

.btn-block { width: 100%; }

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--navy-800);
    cursor: pointer;
}

/* ---------- Forms ---------- */

.field { margin-bottom: 18px; }

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--ink);
}

.input {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    /* 16px or larger stops iOS Safari from zooming in when a field is focused. */
    font-size: 16px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input:hover { border-color: #9fb0c8; }

.input:focus-visible {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(47, 111, 224, 0.28);
}

.input[aria-invalid="true"] { border-color: var(--red-700); }

.field-error {
    margin-top: 6px;
    color: var(--red-700);
    font-size: 14px;
}

.password-field { position: relative; }

/* An input followed by a fixed, non-editable suffix (e.g. "_nurix"). */
.input-with-suffix { display: flex; align-items: stretch; }

.input-with-suffix .input { flex: 1 1 auto; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }

.input-suffix {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-left: 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--slate-100);
    color: var(--slate-600);
    font-size: 16px;
    white-space: nowrap;
}

.password-field .input { padding-right: 84px; }

.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    min-width: 66px;
    height: 34px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--blue-50);
    color: var(--navy-700);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.password-toggle:hover { background: var(--blue-100); }

/* ---------- Alerts ---------- */

.alert {
    margin-bottom: 20px;
    padding: 12px 14px;
    border: 1px solid;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.alert ul { margin: 6px 0 0; padding-left: 18px; }

.alert-error { background: var(--red-50); border-color: #f5c2bd; color: var(--red-700); }
.alert-success { background: var(--green-50); border-color: #b5e2c9; color: var(--green-700); }

/* ---------- Brand ---------- */

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(145deg, var(--blue-500), var(--blue-600));
    color: #fff;
}

.brand-name { display: block; font-weight: 700; font-size: 17px; letter-spacing: 0.01em; }
.brand-tagline { display: block; font-size: 12px; color: #a9bbd9; }

/* ---------- Sign-in page ---------- */

.auth {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 100vh;
    /* Dynamic viewport height: excludes mobile browser toolbars where supported. */
    min-height: 100dvh;
}

.auth-aside {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
    padding: 48px;
    color: #dbe5f5;
    background:
        radial-gradient(circle at 85% 15%, rgba(47, 111, 224, 0.35), transparent 45%),
        radial-gradient(circle at 10% 90%, rgba(47, 111, 224, 0.18), transparent 40%),
        linear-gradient(160deg, var(--navy-900), var(--navy-950));
}

.auth-aside h2 { color: #fff; font-size: 30px; max-width: 440px; }

.auth-aside p { margin-top: 14px; max-width: 460px; color: #b9c7de; }

.auth-points { margin: 28px 0 0; padding: 0; list-style: none; display: grid; gap: 14px; }

.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: #dbe5f5; }

.auth-points svg { margin-top: 3px; color: #7fb0ff; }

.auth-footnote { font-size: 13px; color: #8ea2c4; }

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    background: var(--surface);
}

.auth-card { width: 100%; max-width: 400px; }

/* Sign-in pages: navy behind the page, so pull-to-refresh / overscroll and
   any space below the last section match the navy panel instead of showing
   a light grey band that looks like the page stopped part way. */
.auth-page { background: var(--navy-950); }

/* Logo above the form, shown only on phones (where the navy panel moves below the form). */
.auth-mobile-brand { display: none; }
.auth-mobile-brand.brand { color: var(--navy-900); }
.auth-mobile-brand .brand-tagline { color: var(--muted); }

.auth-card h1 { font-size: 26px; }

.auth-card .lead { margin: 8px 0 28px; color: var(--muted); }

.auth-help { margin-top: 22px; font-size: 14px; color: var(--muted); text-align: center; }

/* ---------- Admin shell ---------- */

.shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 22px 16px;
    background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
    color: #c9d6ec;
}

.sidebar :focus-visible { outline-color: var(--focus-on-dark); }

.sidebar .brand { padding: 4px 8px 22px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }

.nav { margin-top: 18px; flex: 1; }

.nav-heading {
    margin: 0 10px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7f93b5;
}

.nav ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #c9d6ec;
    text-decoration: none;
    font-weight: 500;
}

a.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.nav-link[aria-current="page"] {
    background: rgba(47, 111, 224, 0.22);
    color: #fff;
    box-shadow: inset 3px 0 0 #7fb0ff;
}

.nav-link.is-disabled { color: #7f93b5; cursor: default; }

.nav-badge {
    margin-left: auto;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #a9bbd9;
    font-size: 11px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
    color: #7f93b5;
}

/* overflow-x: clip is a safety net: anything that still ends up too wide is
   cut at the edge instead of letting the whole page scroll sideways. Unlike
   hidden, clip creates no scroll box, so the sticky top bar keeps working. */
.main { display: flex; flex-direction: column; min-width: 0; overflow-x: clip; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 68px;
    padding: 12px var(--gutter);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border);
}

/* A long page title shortens with "…" instead of pushing the account menu off screen. */
.topbar-title { min-width: 0; overflow: hidden; font-size: 19px; text-overflow: ellipsis; white-space: nowrap; }

.menu-toggle { display: none; }

.topbar-user { display: flex; align-items: center; gap: 14px; margin-left: auto; }

.user-meta { text-align: right; line-height: 1.3; }
.user-name { display: block; font-weight: 600; color: var(--ink); }
.user-role { display: block; font-size: 12px; color: var(--muted); }

.avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--navy-800);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

/* The content area uses the full width next to the sidebar (it was capped at
   1200px, which left a blank band on the right of wide screens). Grids
   inside it add columns as space allows; forms and text keep readable widths
   through their own rules. */
.content { width: 100%; padding: 32px var(--gutter); }

.content:focus { outline: none; }

/* ---------- Dashboard ---------- */

.page-intro { margin-bottom: 26px; }

.eyebrow {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--blue-600);
}

.page-intro h2 { margin-top: 6px; font-size: 26px; }

.page-intro p:last-child { margin-top: 6px; color: var(--muted); }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    position: relative;
    display: flex;
    gap: 16px;
    padding: 22px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: var(--tone, var(--blue-600));
}

.stat-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--tone-soft, var(--blue-50));
    color: var(--tone, var(--blue-600));
}

.stat-label { font-size: 14px; font-weight: 600; color: var(--muted); }
.stat-value { display: block; margin-top: 2px; font-size: 32px; font-weight: 700; line-height: 1.15; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-hint { margin-top: 4px; font-size: 13px; color: var(--muted); }

.tone-navy { --tone: var(--navy-700); --tone-soft: var(--blue-50); }
.tone-green { --tone: var(--green-700); --tone-soft: var(--green-50); }
.tone-amber { --tone: var(--amber-700); --tone-soft: var(--amber-50); }

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.panel-header h3 { font-size: 16px; }

/* Narrow panels: the action button moves under the heading instead of squeezing it. */
.panel-header { flex-wrap: wrap; }
.panel-header .btn { white-space: nowrap; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: var(--blue-50);
    color: var(--blue-600);
}

.empty-state h4 { margin: 0; font-size: 16px; color: var(--ink); }
.empty-state p { margin-top: 6px; max-width: 420px; color: var(--muted); }

/* position: relative keeps absolutely positioned content (the .sr-only
   caption, "Actions" heading and "Edit <name>" button text) inside the
   scrolling box. Without it those elements were placed against the page,
   at their spot inside the wide table, and widened the whole page: phones
   then scrolled sideways and zoomed out. */
.table-wrap {
    position: relative;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

.table { width: 100%; border-collapse: collapse; font-size: 14px; }

.table th {
    padding: 12px 22px;
    background: #f8fafd;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.table td { padding: 14px 22px; border-bottom: 1px solid var(--border); white-space: nowrap; }

.table tbody tr:last-child td { border-bottom: 0; }

.table code { font-size: 13px; color: var(--slate-600); }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-active { background: var(--green-50); color: var(--green-700); }
.badge-provisioning { background: var(--blue-50); color: var(--blue-600); }
.badge-suspended { background: var(--amber-50); color: var(--amber-700); }
.badge-archived { background: var(--slate-100); color: var(--slate-600); }

/* ---------- Company management ---------- */

.content > .alert { margin-bottom: 22px; }
.alert-info { background: var(--blue-50); border-color: var(--blue-100); color: var(--navy-700); }
/* Survey demo preview: sample data must never pass for genuine claims. */
.badge-demo { background: var(--amber-50); color: var(--amber-700); border: 1px solid #efc583; }

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page-header h2 { margin-top: 4px; font-size: 24px; overflow-wrap: anywhere; }
.page-header .muted { margin-top: 6px; }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }

.header-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.header-actions form { margin: 0; }

.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--navy-800); }
.btn-secondary:hover { background: var(--blue-50); border-color: var(--blue-100); }
span.btn[aria-disabled="true"] { opacity: 0.5; cursor: default; }
.btn-success { background: var(--green-700); color: #fff; }
.btn-success:hover { background: #0a5737; }
.btn-warning { background: var(--surface); border-color: #efc583; color: var(--amber-700); }
.btn-warning:hover { background: var(--amber-50); }
.btn-danger-outline { background: var(--surface); border-color: #f0b5af; color: var(--red-700); }
.btn-danger-outline:hover { background: var(--red-50); }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 14px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
}

.toolbar .field { margin: 0; }
.toolbar .field-grow { flex: 1 1 240px; }
.toolbar .field-status { flex: 0 1 220px; }
.toolbar-actions { display: flex; gap: 8px; }

select.input {
    appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6b82' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.input[readonly] { background: #f5f7fb; color: var(--muted); }

.row-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.row-link:hover { color: var(--blue-600); text-decoration: underline; }
.cell-stack { display: grid; gap: 2px; }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }

.badge-none, .badge-disabled { background: var(--slate-100); color: var(--slate-600); }
.badge-pending { background: var(--amber-50); color: var(--amber-700); }
.badge-ready { background: var(--green-50); color: var(--green-700); }
.badge-failed { background: var(--red-50); color: var(--red-700); }
.badge { text-transform: none; }

.empty-action { margin-top: 16px; }

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    font-size: 14px;
}

.pagination-links { display: flex; align-items: center; gap: 10px; }
.pagination-page { color: var(--muted); }

/* The form card is a size container: its field grid picks the number of
   columns from the card's own width (not the screen's), so a form inside a
   side panel stays compact while a full-width form on a large monitor uses
   three or four columns instead of two very long fields. Browsers without
   container queries keep two columns. */
.form-card { padding: 24px 22px; container-type: inline-size; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 20px;
}

@container (min-width: 1180px) {
    .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@container (min-width: 1800px) {
    .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.form-grid .span-2 { grid-column: 1 / -1; }
.field-hint { margin-top: 6px; font-size: 13px; color: var(--muted); }
.optional { font-weight: 400; color: var(--muted); }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 6px;
}

.layout-two {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    align-items: start;
    gap: 20px;
}

.stack { display: grid; gap: 20px; }
.panel-body { padding: 20px 22px; }

.details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
    margin: 0;
    padding: 20px 22px;
}

.details-compact { padding: 4px 0 18px; }
.details .span-2 { grid-column: 1 / -1; }
.details dt { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.details dd { margin: 4px 0 0; color: var(--ink); overflow-wrap: anywhere; }

.check-list { margin: 0 0 18px; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 14px; }
.check-list li { display: flex; align-items: center; gap: 10px; }
.state-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.state-yes .state-dot { background: var(--green-700); }
.state-no .state-dot { background: var(--red-700); }
.state-unknown .state-dot { background: #d9a441; }

.mapping-form { padding-top: 18px; border-top: 1px solid var(--border); }
.mapping-form h4 { margin: 0; font-size: 15px; color: var(--ink); }
.mapping-form > .field-hint { margin: 4px 0 16px; }
.mapping-form .credential-note { margin-bottom: 16px; }
.login-note { padding-top: 0; font-size: 14px; }
.input:disabled { background: #f5f7fb; color: var(--muted); cursor: not-allowed; }

.activity { margin: 0; padding: 0; list-style: none; }
.activity li { display: grid; gap: 2px; padding: 12px 22px; border-bottom: 1px solid var(--border); }
.activity li:last-child { border-bottom: 0; }
.activity-action { font-weight: 600; color: var(--ink); }
.activity-meta { font-size: 13px; color: var(--muted); }

.stat-link { display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 600; text-decoration: none; }
.stat-link:hover { text-decoration: underline; }

@media (max-width: 1100px) {
    .layout-two { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 700px) {
    .form-grid, .details { grid-template-columns: minmax(0, 1fr); }
    .toolbar .field-status { flex: 1 1 100%; }
    .toolbar-actions { width: 100%; }
    .toolbar-actions .btn { flex: 1; }
    .header-actions { width: 100%; }
    .header-actions > * { flex: 1 1 auto; }
    .header-actions .btn { width: 100%; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
    .shell { grid-template-columns: minmax(0, 1fr); }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        width: min(var(--sidebar-width), 86vw);
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.2s ease, visibility 0.2s;
    }

    .sidebar.is-open { transform: none; visibility: visible; box-shadow: var(--shadow); }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 30;
        background: rgba(10, 20, 48, 0.45);
    }

    .menu-toggle { display: inline-flex; }

    :root { --gutter: 20px; }

    .content { padding-top: 24px; padding-bottom: 32px; }
}

/* Tablets in portrait (iPad mini to iPad Pro 13") and narrow tablets: one
   centred column on the navy background, with the brand information above
   the form, which sits in a white card. */
@media (min-width: 601px) and (max-width: 900px) and (min-height: 501px),
       (min-width: 601px) and (max-width: 1100px) and (orientation: portrait) and (min-height: 501px) {
    .auth {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 32px;
        padding: 56px 40px;
        background:
            radial-gradient(circle at 85% 10%, rgba(47, 111, 224, 0.35), transparent 45%),
            radial-gradient(circle at 10% 90%, rgba(47, 111, 224, 0.18), transparent 40%),
            linear-gradient(160deg, var(--navy-900), var(--navy-950));
    }

    .auth-aside {
        justify-content: flex-start;
        gap: 0;
        width: 100%;
        max-width: 600px;
        padding: 0;
        background: none;
        text-align: center;
    }

    .auth-aside > .brand { justify-content: center; margin-bottom: 28px; text-align: left; }
    .auth-aside h2 { max-width: none; font-size: 28px; }
    .auth-aside p { margin-left: auto; margin-right: auto; }
    .auth-points { display: inline-grid; margin-top: 22px; text-align: left; }
    .auth-footnote { display: none; }

    .auth-main {
        display: block;
        flex: none;
        width: 100%;
        max-width: 480px;
        padding: 36px 40px;
        border-radius: var(--radius-lg);
        box-shadow: 0 24px 48px rgba(4, 10, 30, 0.35);
    }

    .auth-card { max-width: none; }
}

/* Phones (and short landscape screens): the sign-in form comes first with a
   compact logo, followed by the full product information on the navy panel.
   Rows size to their content; the last row fills the remaining height. */
@media (max-width: 600px), (max-height: 500px) {
    .auth { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
    .auth-main { order: -1; align-items: flex-start; padding: 24px 20px 32px; }
    .auth-mobile-brand { display: flex; margin-bottom: 24px; }
    .auth-aside { justify-content: flex-start; gap: 20px; padding: 32px 20px 36px; }
    .auth-aside > .brand { display: none; }
    .auth-aside h2 { max-width: none; font-size: 21px; }
    .auth-points { margin-top: 20px; }
    .auth-card h1 { font-size: 22px; }
    .auth-card .lead { margin-bottom: 20px; }
}

/* Phones in landscape: very little height, so tighten the form. */
@media (max-height: 500px) {
    .auth-main { padding-top: 14px; }
    .auth-mobile-brand { margin-bottom: 12px; }
    .auth-card .lead { display: none; }
    .auth-card h1 { margin-bottom: 14px; font-size: 20px; }
    .auth-card .field { margin-bottom: 12px; }
}

@media (max-width: 600px) {
    :root { --gutter: 16px; }
    .user-meta { display: none; }
    .topbar { gap: 10px; }
    /* Phones: the title may take two lines before it is shortened. */
    .topbar-title {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        font-size: 17px;
        line-height: 1.25;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .page-intro h2 { font-size: 22px; }
    .stat-value { font-size: 28px; }
    .table th, .table td { padding: 12px 16px; }
}

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

/* Company (client) area: same shell as the admin area. */
.nav-heading-spaced { margin-top: 22px; }
.stat-value-text { margin-top: 8px; font-size: 15px; line-height: 1.4; }
.details-single { grid-template-columns: minmax(0, 1fr); }
.user-meta .user-name, .user-meta .user-role { overflow-wrap: anywhere; }
.sidebar-footer { overflow-wrap: anywhere; }
.sidebar-company { display: block; color: #c9d6ec; font-weight: 600; }
.toolbar .field-date { flex: 0 1 170px; }
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { text-decoration: underline; }
@media (max-width: 700px) {
    .toolbar .field-date { flex: 1 1 calc(50% - 7px); }
}
.form-section-title { margin: 26px 0 12px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 15px; }
.form-section-title:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.verify-form { margin: 14px 0 4px; }
.verify-form .field-hint { margin-top: 6px; }
.checkbox { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; cursor: pointer; }
.checkbox input { margin-top: 3px; }

/* Client account menu (top right). */
.account-menu { position: relative; }
.account-toggle { display: flex; align-items: center; gap: 12px; padding: 4px 6px 4px 10px; border: 1px solid transparent; border-radius: 999px; background: none; color: inherit; font: inherit; cursor: pointer; text-align: right; }
.account-toggle:hover, .account-toggle[aria-expanded="true"] { border-color: var(--border); background: var(--surface); }
.account-toggle:focus-visible { outline: 3px solid var(--focus, #7fb0ff); outline-offset: 2px; }
.account-caret { color: var(--muted); transition: transform 0.15s; }
.account-toggle[aria-expanded="true"] .account-caret { transform: rotate(180deg); }
.account-dropdown { position: absolute; top: calc(100% + 8px); right: 0; z-index: 50; min-width: 230px; max-width: calc(100vw - 32px); padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm, 8px); background: var(--surface, #fff); box-shadow: var(--shadow, 0 10px 30px rgba(15, 23, 42, 0.12)); }
.account-dropdown[hidden] { display: none; }
.account-dropdown-header { margin: 0 0 6px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); line-height: 1.3; overflow-wrap: anywhere; }
.account-dropdown form { margin: 0; }
.account-item { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 6px; background: none; color: var(--ink); font: inherit; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; }
.account-item:hover, .account-item:focus-visible { background: var(--blue-50, #eef4ff); outline: none; }
.account-item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus, #7fb0ff); }
.account-item[aria-current="page"] { font-weight: 700; }
.account-signout { color: var(--red-700, #b42318); }
.form-card-narrow { max-width: 560px; }

/* Client survey dashboard. */
.dashboard-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.dashboard-head .page-intro { margin-bottom: 0; }
.dashboard-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.range-filter { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.range-option { padding: 6px 12px; border-radius: 999px; color: var(--slate-600); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.range-option:hover { background: var(--slate-100); color: var(--ink); }
.range-option[aria-current="true"] { background: var(--navy-800); color: #fff; }
.kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-grid .stat-card { min-height: 128px; }
.tone-blue { --tone: var(--blue-600); --tone-soft: var(--blue-50); }
.tone-red { --tone: var(--red-700); --tone-soft: var(--red-50); }
.tone-slate { --tone: var(--slate-600); --tone-soft: var(--slate-100); }
.chart-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 20px; margin-bottom: 20px; }
.chart-grid .panel, .dashboard-head + .panel { margin-bottom: 0; }
.chart-range { font-size: 12px; }
.chart-empty { padding: 32px 0; text-align: center; }
.panel-note { margin: 0; padding: 0 22px 18px; color: var(--muted); font-size: 13px; }
.donut-wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 22px; }
.donut { width: 170px; height: 170px; transform: rotate(0deg); }
.donut-track { stroke: var(--slate-100); }
.donut-total { font-size: 8px; font-weight: 700; fill: var(--ink); text-anchor: middle; }
.donut-caption { font-size: 3.2px; fill: var(--muted); text-anchor: middle; }
.legend { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; min-width: 170px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legend strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.seg-pending { stroke: #d48a00; } .seg-bg-pending { background: #d48a00; }
.seg-ongoing { stroke: var(--blue-600); } .seg-bg-ongoing { background: var(--blue-600); }
.seg-completed { stroke: var(--green-700); } .seg-bg-completed { background: var(--green-700); }
.seg-disputed { stroke: #7a4fc9; } .seg-bg-disputed { background: #7a4fc9; }
.seg-other { stroke: #64748b; } .seg-bg-other { background: #64748b; }
.seg-unset { stroke: #c7d0dc; } .seg-bg-unset { background: #c7d0dc; }
/* Trend chart: the SVG (bars only) stretches to the panel; the numbers and
   axis labels are HTML positioned by percentage, so text is never squashed
   on phones or stretched on wide monitors. */
.trend { padding-top: 18px; }
.trend-plot { position: relative; height: 200px; }
.trend-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.trend-axis { stroke: var(--border); stroke-width: 1; }
.trend-bar { fill: var(--blue-600); }
.trend-bar:hover { fill: var(--navy-800); }
.trend-value { position: absolute; transform: translate(-50%, -4px); font-size: 11px; font-weight: 700; line-height: 1; color: var(--ink); white-space: nowrap; pointer-events: none; }
.trend-labels { position: relative; height: 18px; margin-top: 8px; }
.trend-label { position: absolute; top: 0; transform: translateX(-50%); font-size: 11px; line-height: 18px; color: var(--muted); white-space: nowrap; }
.chart-summary { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.survey-badge-pending { background: var(--amber-50); color: var(--amber-700); }
.survey-badge-ongoing { background: var(--blue-50); color: var(--blue-600); }
.survey-badge-completed { background: var(--green-50); color: var(--green-700); }
.survey-badge-disputed { background: #f1ebfb; color: #5b3a9a; }
.survey-badge-other, .survey-badge-unset { background: var(--slate-100); color: var(--slate-600); }
/* Very wide screens: all six figures in one row. */
@media (min-width: 2200px) { .kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .chart-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
    .kpi-grid { grid-template-columns: minmax(0, 1fr); }
    .dashboard-controls { width: 100%; }
    .range-filter { width: 100%; justify-content: space-between; }
    .range-option { padding: 6px 9px; font-size: 12px; }
    .trend-plot { height: 160px; }
    /* Narrow: every other axis label, and no per-bar numbers when bars are thin. */
    .trend-label:nth-child(even) { display: none; }
    .trend-dense .trend-value { display: none; }
}
.date-filter { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 3px 3px 3px 6px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.date-filter.is-active { border-color: var(--navy-800); box-shadow: inset 0 0 0 1px var(--navy-800); }
.date-filter .input-sm { width: auto; min-width: 0; height: 32px; padding: 4px 8px; border: 0; background: transparent; font-size: 13px; }
.date-filter .input-sm:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-radius: 6px; }
.date-filter-sep { color: var(--muted); font-size: 13px; }
.date-filter .btn-sm { border-radius: 999px; }
@media (max-width: 560px) {
    .date-filter { width: 100%; border-radius: 12px; padding: 6px; }
    .date-filter .input-sm { flex: 1 1 120px; }
    .date-filter .btn-sm { flex: 1 1 100%; }
}

/* User group module checkboxes and read-only form values. */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 20px; margin-top: 4px; }
.module-grid .checkbox { margin: 0; }
.input-static { margin: 0; padding: 10px 0; }
fieldset.field { border: 0; padding: 0; min-width: 0; }

/* ---------- Client user portal ---------- */

/* Sign-out button styled as a sidebar link. */
button.nav-link {
    width: 100%;
    border: 0;
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

button.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.survey-badge-in_progress { background: var(--blue-50); color: var(--blue-600); }

.portal-welcome { margin-bottom: 20px; }

.portal-filter { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 22px 16px; }

.portal-filter a[aria-current="page"] { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }

.role-list { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
