:root {
    --navy-950: #10172a;
    --navy-900: #16213e;
    --navy-800: #243254;
    --slate-700: #344158;
    --slate-600: #536078;
    --slate-500: #6d7890;
    --slate-300: #cdd4e0;
    --slate-200: #e2e7ef;
    --slate-100: #eef1f6;
    --slate-50: #f7f8fb;
    --white: #fff;
    --primary: #5367e8;
    --primary-dark: #4054d2;
    --primary-soft: #edf0ff;
    --green: #17865b;
    --green-soft: #e6f6ef;
    --amber: #a86509;
    --amber-soft: #fff3d8;
    --red: #c33f50;
    --red-dark: #a92d3e;
    --red-soft: #ffedf0;
    --violet: #7952c7;
    --shadow-sm: 0 1px 2px rgba(16, 23, 42, .04), 0 3px 10px rgba(16, 23, 42, .04);
    --shadow-md: 0 14px 34px rgba(16, 23, 42, .11);
    --radius-sm: 9px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    min-width: 320px;
    background: var(--slate-50);
    color: var(--navy-950);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.shell {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    padding: 34px 0 64px;
}

.page-header {
    margin-bottom: 30px;
    padding: 0 2px;
}

.dashboard-header { margin-bottom: 38px; }

.topbar, .heading-row, .card-topline, .card-actions, .dialog-header,
.dialog-actions, .form-footer, .toolbar {
    display: flex;
    align-items: center;
}
.session-actions { display: flex; align-items: center; gap: 8px; }
.session-actions form { margin: 0; }
.back-row { display: flex; justify-content: flex-start; margin: -38px 0 34px; }

.topbar {
    justify-content: space-between;
    min-height: 42px;
    margin-bottom: 54px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--navy-900);
    font-weight: 750;
    letter-spacing: -.015em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 10px;
    background: var(--navy-900);
    color: var(--white);
    font-size: 12px;
    letter-spacing: .02em;
}

.heading-row {
    justify-content: space-between;
    gap: 24px;
    align-items: end;
}

.heading-row h1 {
    margin: 4px 0 7px;
    color: var(--navy-950);
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.08;
    letter-spacing: -.045em;
}

.eyebrow {
    margin: 0;
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.eyebrow-danger { color: var(--red); }

.subtitle {
    max-width: 660px;
    margin: 0;
    color: var(--slate-600);
    font-size: 16px;
}

.header-actions { flex: 0 0 auto; gap: 8px; }

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 750;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-primary { background: var(--primary); color: var(--white); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { border-color: #cfd6fa; background: var(--primary-soft); color: var(--primary-dark); }
.button-secondary:hover { border-color: #aeb9f6; }
.button-quiet { border-color: var(--slate-200); background: var(--white); color: var(--slate-700); }
.button-quiet:hover:not(:disabled) { border-color: var(--slate-300); background: var(--slate-50); }
.button-danger { background: var(--red); color: var(--white); }
.button-danger:hover { background: var(--red-dark); }
.button-danger-quiet { border-color: #f2c9d0; background: var(--red-soft); color: var(--red); }

.status-pill, .badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .035em;
}

.status-pill {
    gap: 7px;
    border: 1px solid #cbe9dd;
    padding: 7px 11px;
    background: var(--green-soft);
    color: var(--green);
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #27a570; box-shadow: 0 0 0 3px rgba(39, 165, 112, .13); }

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

.utility-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    min-height: 118px;
    align-items: center;
    gap: 18px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 22px;
    background: var(--white);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.utility-card:hover { transform: translateY(-2px); border-color: #c5cdec; box-shadow: var(--shadow-md); }

.utility-icon {
    display: grid;
    width: 50px;
    height: 50px;
    place-items: center;
    border-radius: 15px;
    font-size: 13px;
    font-weight: 850;
}

.utility-icon-blue { background: #e9efff; color: #4160c8; }
.utility-icon-violet { background: #f2ebff; color: var(--violet); font-size: 21px; }
.utility-icon-amber { background: var(--amber-soft); color: var(--amber); }
.utility-icon-green { background: var(--green-soft); color: var(--green); }
.utility-icon-support { background: #e7f7f2; color: #13745b; }
.utility-icon-admin { background: var(--red-soft); color: var(--red); }
.utility-icon-user-view { background: #eaf2ff; color: #315ca8; }
.utility-copy { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.utility-copy strong { font-size: 17px; letter-spacing: -.015em; }
.utility-copy span { color: var(--slate-600); font-size: 13px; }
.utility-arrow { color: var(--slate-500); font-size: 19px; transition: transform .18s ease; }
.utility-card:hover .utility-arrow { transform: translateX(3px); color: var(--primary); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }

.card, .panel {
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.card { min-width: 0; padding: 20px; }
.user-card { transition: border-color .16s ease, box-shadow .16s ease; }
.user-card.is-selected { border-color: #9ba8f2; box-shadow: 0 0 0 3px rgba(83, 103, 232, .1), var(--shadow-sm); }
.card-topline { min-height: 25px; justify-content: space-between; gap: 12px; }
.card-title { margin: 20px 0 1px; font-size: 19px; line-height: 1.25; letter-spacing: -.02em; }
.code-title { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.card-id { max-width: 52%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.card-actions { gap: 8px; margin-top: 19px; padding-top: 16px; border-top: 1px solid var(--slate-100); }
.card-actions .button { flex: 1; }
.muted { margin: 0; color: var(--slate-500); font-size: 13px; }
.break-word { overflow-wrap: anywhere; }

.badge { padding: 5px 9px; text-transform: capitalize; }
.badge-group { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.user-selector { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 8px; background: var(--primary-soft); color: var(--primary-dark); font-size: 11px; font-weight: 800; cursor: pointer; }
.user-selector:has(input:disabled) { background: var(--slate-100); color: var(--slate-500); cursor: not-allowed; opacity: .7; }
.user-selector input { width: 14px; height: 14px; margin: 0; accent-color: var(--primary); }
.badge-success { background: var(--green-soft); color: var(--green); }
.badge-danger { background: var(--red-soft); color: var(--red); }
.badge-warning { background: var(--amber-soft); color: var(--amber); }
.badge-neutral { background: var(--slate-100); color: var(--slate-600); }
.badge-subscription-subscribed { background: var(--green-soft); color: var(--green); }
.badge-subscription-not-subscribed { background: var(--slate-100); color: var(--slate-600); }
.badge-subscription-unavailable { background: var(--amber-soft); color: var(--amber); }

.data-list { margin: 20px 0 0; }
.data-list div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--slate-100); }
.data-list dt { color: var(--slate-500); }
.data-list dd { margin: 0; color: var(--slate-700); font-weight: 700; text-align: right; }
.revenuecat-spend[data-state="available"] { color: var(--green); }
.revenuecat-spend[data-state="loading"] { color: var(--slate-500); font-weight: 600; }
.revenuecat-spend[data-state="unavailable"] { color: var(--amber); font-weight: 600; }
.customer-country[data-state="loading"] { color: var(--slate-500); font-weight: 600; }
.customer-country[data-state="unavailable"] { color: var(--amber); font-weight: 600; }
.value-yes { color: var(--green) !important; }
.value-no { color: var(--slate-500) !important; }

.content-narrow { width: min(720px, 100%); }
.administrator-add-panel { margin-bottom: 22px; }
.administrator-grid form { width: 100%; }
.panel { padding: clamp(20px, 4vw, 32px); }
.form-stack { display: grid; gap: 20px; }
.form-grid { display: grid; gap: 16px; }
.form-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; }
.field label { color: var(--slate-700); font-size: 13px; font-weight: 750; }
.field-hint { margin-top: -5px; color: var(--slate-500); font-size: 12px; }

.field input, .field textarea, .search-field input {
    width: 100%;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--white);
    color: var(--navy-950);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.field input, .field textarea { padding: 10px 12px; }
.field textarea { resize: vertical; }
.field input[readonly] { background: var(--slate-100); color: var(--slate-600); }
.field input:focus, .field textarea:focus, .search-field:focus-within { border-color: #8997ed; box-shadow: 0 0 0 3px rgba(83, 103, 232, .13); }
.form-footer { justify-content: flex-end; padding-top: 3px; }

.notice { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; border: 1px solid; border-radius: var(--radius-sm); padding: 12px 14px; font-weight: 650; }
.notice-success { border-color: #cbe9dd; background: var(--green-soft); color: var(--green); }
.notice-icon { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; background: var(--green); color: var(--white); font-size: 12px; }
.notice-warning { border-color: #f2d9a3; background: var(--amber-soft); color: var(--amber); }
.notice-warning .notice-icon { background: var(--amber); }
.notice-danger { border-color: #f2c9d0; background: var(--red-soft); color: var(--red); }
.notice-danger .notice-icon { background: var(--red); }
.readonly-notice { align-items: flex-start; }
.readonly-notice .notice-icon { flex: 0 0 auto; }

.user-view-search-panel { margin: 22px auto 0; }
.user-view-nav {
    display: flex;
    gap: 8px;
    margin: 20px 0;
    padding-bottom: 4px;
    overflow-x: auto;
    scrollbar-width: thin;
}
.user-view-nav-item {
    flex: 0 0 auto;
    border: 1px solid var(--slate-200);
    border-radius: 999px;
    padding: 7px 12px;
    background: var(--white);
    color: var(--slate-600);
    font-size: 12px;
    font-weight: 750;
    text-decoration: none;
}
.user-view-nav-item:hover { border-color: var(--slate-300); color: var(--primary-dark); }
.user-view-nav-item.is-active { border-color: #aeb9f6; background: var(--primary-soft); color: var(--primary-dark); }
.user-view-summary-grid { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(0, 1.2fr); gap: 16px; }
.user-view-summary { min-width: 0; padding: 24px; }
.user-view-summary .data-list { margin-top: 14px; }
.user-view-record-panel { padding: clamp(18px, 3vw, 28px); }
.user-view-section-heading { align-items: flex-start; margin-bottom: 18px; }
.user-view-section-heading h2 { margin: 3px 0 0; font-size: 24px; letter-spacing: -.025em; }
.user-view-record-list { display: grid; gap: 9px; }
.user-view-record {
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    background: var(--slate-50);
    overflow: hidden;
}
.user-view-record summary {
    display: flex;
    min-height: 58px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
}
.user-view-record summary::-webkit-details-marker { display: none; }
.user-view-record summary > span:first-child { display: grid; min-width: 0; gap: 2px; }
.user-view-record summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-view-record summary small { color: var(--slate-500); }
.user-view-record[open] summary { border-bottom: 1px solid var(--slate-200); background: var(--white); }
.readonly-json {
    max-width: 100%;
    max-height: 560px;
    margin: 0;
    padding: 16px;
    overflow: auto;
    background: var(--navy-950);
    color: #edf1ff;
    font: 12px/1.55 ui-monospace, "SFMono-Regular", Consolas, monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.user-view-summary > .readonly-json { margin-top: 14px; border-radius: var(--radius-sm); }
.user-view-empty { padding: 40px 18px; }

.toolbar { justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.search-field { display: flex; width: min(480px, 100%); align-items: center; gap: 8px; border: 1px solid var(--slate-300); border-radius: var(--radius-sm); padding: 0 12px; background: var(--white); box-shadow: var(--shadow-sm); }
.search-field input { border: 0; padding: 10px 0; box-shadow: none !important; }
.search-icon { color: var(--slate-500); font-size: 19px; }
.result-count { flex: 0 0 auto; color: var(--slate-500); font-size: 13px; }
.result-count strong { color: var(--slate-700); }
.selection-count { min-width: 68px; color: var(--primary-dark); font-size: 13px; font-weight: 750; text-align: right; }
.user-filter-row { display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)); gap: 9px; margin: -6px 0 16px; }
.user-filter-row label { display: grid; gap: 4px; color: var(--slate-500); font-size: 11px; font-weight: 750; }
.user-filter-row input, .user-filter-row select { min-width: 0; border: 1px solid var(--slate-300); border-radius: 9px; padding: 8px 9px; background: var(--white); color: var(--navy-950); }

.pagination-controls {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 28px 0 8px;
    text-align: center;
}
.load-more-button { min-width: 170px; }
.load-more-status { margin: 0; color: var(--slate-500); font-size: 12px; }
.pull-indicator {
    min-height: 27px;
    border-radius: 999px;
    padding: 5px 11px;
    color: var(--slate-500);
    font-size: 12px;
    font-weight: 750;
    opacity: .75;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.pull-indicator.is-ready { background: var(--primary-soft); color: var(--primary-dark); opacity: 1; transform: scale(1.03); }

.empty-state { grid-column: 1 / -1; border: 1px dashed var(--slate-300); border-radius: var(--radius-md); padding: 54px 20px; text-align: center; }
.empty-state h2 { margin: 9px 0 3px; font-size: 18px; }
.empty-state p { margin: 0; color: var(--slate-500); }
.empty-icon { display: inline-grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: var(--primary-soft); color: var(--primary); font-size: 20px; font-weight: 800; }

.metrics-section { margin-bottom: 38px; }
.section-title-row { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.section-title-row h2 { margin: 3px 0 0; font-size: 21px; letter-spacing: -.025em; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.metric-card { display: grid; min-height: 112px; align-content: center; gap: 7px; border: 1px solid var(--slate-200); border-radius: var(--radius-md); padding: 17px; background: var(--white); box-shadow: var(--shadow-sm); }
.metric-card > span { color: var(--slate-500); font-size: 12px; font-weight: 700; }
.metric-card strong { color: var(--navy-950); font-size: clamp(21px, 2.5vw, 29px); letter-spacing: -.035em; }
.metric-card small { color: var(--slate-500); font-size: 10px; line-height: 1.35; }

.record-panel { border: 1px solid var(--slate-200); border-radius: var(--radius-md); background: var(--white); box-shadow: var(--shadow-sm); overflow: hidden; }
.event-list, .timeline-list { display: grid; }
.event-row, .timeline-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 15px 17px; border-bottom: 1px solid var(--slate-100); }
.event-row:last-child, .timeline-row:last-child { border-bottom: 0; }
.event-icon, .timeline-dot { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary-dark); font-weight: 850; }
.event-copy { display: grid; min-width: 0; gap: 3px; }
.event-copy strong { overflow-wrap: anywhere; }
.event-copy span, .event-row time, .timeline-row time { color: var(--slate-500); font-size: 12px; }
.checklist { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.checklist li { border: 1px solid var(--slate-200); border-radius: var(--radius-sm); padding: 13px 15px; background: var(--white); }
.checklist code { overflow-wrap: anywhere; }

.dialog {
    width: min(520px, calc(100% - 28px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    border: 0;
    border-radius: var(--radius-lg);
    padding: 25px;
    background: var(--white);
    color: var(--navy-950);
    box-shadow: 0 26px 70px rgba(10, 15, 30, .28);
}

.dialog-small { width: min(440px, calc(100% - 28px)); }
.dialog::backdrop { background: rgba(16, 23, 42, .58); backdrop-filter: blur(2px); }
.dialog-header { justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.dialog-header h2 { margin: 3px 0 0; font-size: 22px; letter-spacing: -.025em; }
.dialog-copy { margin: 0; color: var(--slate-600); }
.broadcast-warning { margin: -5px 0 20px; border: 1px solid #f2d9a3; border-radius: var(--radius-sm); padding: 11px 13px; background: var(--amber-soft); color: #7b4b08; font-size: 13px; }
.dialog-actions { justify-content: flex-end; gap: 8px; margin-top: 25px; }
.icon-button { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--white); color: var(--slate-600); font-size: 22px; line-height: 1; cursor: pointer; }
.icon-button:hover { background: var(--slate-50); color: var(--navy-900); }

[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(83, 103, 232, .28); outline-offset: 2px; }

@media (max-width: 700px) {
    .shell { width: min(100% - 28px, 1120px); padding-top: 20px; }
    .topbar { margin-bottom: 38px; }
    .back-row { margin: -24px 0 28px; }
    .brand > span:last-child { display: none; }
    .heading-row { align-items: stretch; flex-direction: column; }
    .header-actions { align-items: stretch; flex-direction: column; }
    .header-actions .button { width: 100%; }
    .utility-grid, .form-grid-two { grid-template-columns: 1fr; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .section-title-row { align-items: flex-start; flex-direction: column; }
    .user-view-summary-grid { grid-template-columns: 1fr; }
    .utility-card { min-height: 106px; padding: 18px; }
    .card-grid { grid-template-columns: 1fr; }
    .card-topline { align-items: flex-start; }
    .badge-group { max-width: 72%; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar-actions { flex-wrap: wrap; justify-content: space-between; }
    .user-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .result-count { padding-left: 2px; }
    .dialog { padding: 20px; }
}

@media (max-width: 430px) {
    .metric-grid { grid-template-columns: 1fr; }
    .event-row, .timeline-row { grid-template-columns: auto minmax(0, 1fr); }
    .event-row time, .timeline-row time { grid-column: 2; }
}

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