:root {
    --brand-yellow: #ffd42a;
    --brand-yellow-strong: #f2bd00;
    --brand-yellow-soft: #fff7d5;
    --brand-ink: #2e2d31;
    --brand-ink-soft: #535156;
    --brand-paper: #f7f6f1;
    --brand-white: #ffffff;
    --brand-line: #e8e5da;
    --brand-success: #24745b;
    --brand-danger: #b33a3a;
    --shadow-sm: 0 1px 2px rgba(46, 45, 49, .05), 0 8px 24px rgba(46, 45, 49, .06);
    --shadow-lg: 0 24px 70px rgba(25, 24, 27, .16);
    --radius-sm: .75rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    background: var(--brand-paper);
    color: var(--brand-ink);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

button, select { cursor: pointer; }

a { color: inherit; }

.app-shell { display: grid; grid-template-columns: 17rem minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    background: var(--brand-ink);
    color: white;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 1.25rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand-card {
    align-items: center;
    background: white;
    border-radius: var(--radius-md);
    display: flex;
    gap: .8rem;
    min-height: 4.5rem;
    overflow: hidden;
    padding: .7rem .85rem;
}

.brand-card img { display: block; height: 3.1rem; object-fit: contain; width: 4.9rem; }

.brand-card-text { color: var(--brand-ink); line-height: 1.05; }
.brand-card-text strong { display: block; font-size: 1rem; letter-spacing: -.02em; }
.brand-card-text span { color: #737077; display: block; font-size: .68rem; margin-top: .28rem; text-transform: uppercase; letter-spacing: .08em; }

.sidebar-label { color: #99969d; font-size: .68rem; font-weight: 700; letter-spacing: .13em; margin: 2rem .75rem .7rem; text-transform: uppercase; }
.sidebar-nav { display: grid; gap: .4rem; }
.sidebar-link {
    align-items: center;
    border-radius: var(--radius-sm);
    color: #cfccd2;
    display: flex;
    font-size: .9rem;
    font-weight: 650;
    gap: .75rem;
    padding: .8rem .85rem;
    text-decoration: none;
}
.sidebar-link svg { height: 1.15rem; width: 1.15rem; }
.sidebar-link.active { background: var(--brand-yellow); color: var(--brand-ink); }
.sidebar-link.disabled { cursor: default; opacity: .48; }
.sidebar-footer { border-top: 1px solid #444248; color: #aaa7ae; font-size: .75rem; line-height: 1.5; margin-top: auto; padding: 1rem .75rem 0; }
.sidebar-footer strong { color: white; display: block; }

.app-workspace { min-width: 0; }
.topbar { align-items: center; background: rgba(247, 246, 241, .92); border-bottom: 1px solid var(--brand-line); display: flex; justify-content: space-between; min-height: 5rem; padding: 1rem clamp(1.25rem, 3vw, 2.5rem); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.topbar-title { font-size: .8rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.environment-badge { align-items: center; background: #e8f4ee; border: 1px solid #c8e3d7; border-radius: 999px; color: var(--brand-success); display: inline-flex; font-size: .72rem; font-weight: 750; gap: .45rem; padding: .42rem .7rem; }
.environment-badge::before { background: currentColor; border-radius: 50%; content: ""; height: .45rem; width: .45rem; }

.page-container { margin: 0 auto; max-width: 92rem; padding: clamp(1.5rem, 3vw, 2.75rem); }
.page-heading { align-items: flex-end; display: flex; gap: 1.5rem; justify-content: space-between; margin-bottom: 1.75rem; }
.eyebrow { color: #8b6c00; font-size: .72rem; font-weight: 800; letter-spacing: .14em; margin: 0 0 .55rem; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.9rem, 3vw, 2.8rem); letter-spacing: -.045em; line-height: 1.05; margin-bottom: .65rem; }
h2 { font-size: 1.12rem; letter-spacing: -.02em; }
h3 { font-size: .95rem; }
.page-intro, .muted { color: #6f6c73; line-height: 1.6; }
.page-intro { margin: 0; max-width: 48rem; }
.muted { font-size: .86rem; }

.stats-grid { display: grid; gap: 1rem; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 1.5rem; }
.stat-card { background: var(--brand-white); border: 1px solid var(--brand-line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 1.15rem; position: relative; overflow: hidden; }
.stat-card::before { background: var(--brand-yellow); content: ""; height: 100%; left: 0; position: absolute; top: 0; width: .26rem; }
.stat-label { color: #76737a; display: block; font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.stat-value { display: block; font-size: 1.85rem; font-weight: 800; letter-spacing: -.05em; margin-top: .3rem; }

.panel-grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(18rem, .75fr) minmax(0, 1.65fr); margin-bottom: 1.25rem; }
.panel { background: var(--brand-white); border: 1px solid var(--brand-line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 1.25rem; overflow: hidden; }
.panel-grid .panel { margin-bottom: 0; }
.panel-header { align-items: flex-start; border-bottom: 1px solid var(--brand-line); display: flex; gap: 1rem; justify-content: space-between; padding: 1.25rem 1.35rem; }
.panel-header h2 { margin-bottom: .25rem; }
.panel-header p { margin-bottom: 0; }
.panel-body { padding: 1.35rem; }

.form-stack { display: grid; gap: .95rem; }
.form-row { display: grid; gap: .9rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: .42rem; }
.field label { font-size: .76rem; font-weight: 750; }
.field input, .field select, .compact-select {
    background: white;
    border: 1px solid #d9d5c9;
    border-radius: .72rem;
    color: var(--brand-ink);
    min-height: 2.75rem;
    outline: none;
    padding: .65rem .75rem;
    width: 100%;
}
.field input:focus, .field select:focus, .compact-select:focus { border-color: var(--brand-yellow-strong); box-shadow: 0 0 0 3px rgba(255, 212, 42, .22); }
.field-error { color: var(--brand-danger); font-size: .75rem; margin: 0; }

.button { align-items: center; background: var(--brand-yellow); border: 1px solid var(--brand-yellow); border-radius: .72rem; color: var(--brand-ink); display: inline-flex; font-weight: 800; gap: .5rem; justify-content: center; min-height: 2.75rem; padding: .65rem 1rem; }
.button:hover { background: var(--brand-yellow-strong); border-color: var(--brand-yellow-strong); }
.button-secondary { background: var(--brand-ink); border-color: var(--brand-ink); color: white; }
.button-danger { background: white; border-color: #eccaca; color: var(--brand-danger); }
.button-success { background: white; border-color: #bcdccd; color: var(--brand-success); }

.notice { align-items: center; background: #eaf7f0; border: 1px solid #c4e5d4; border-radius: var(--radius-md); color: #1e684f; display: flex; font-weight: 650; gap: .65rem; margin-bottom: 1.25rem; padding: .9rem 1rem; }
.notice::before { content: "✓"; font-weight: 900; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { color: #77747b; font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
th, td { border-bottom: 1px solid #efede6; padding: .95rem 1rem; text-align: left; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.user-cell { align-items: center; display: flex; gap: .75rem; }
.avatar { align-items: center; background: var(--brand-yellow-soft); border: 1px solid #f3df8b; border-radius: 50%; display: inline-flex; flex: 0 0 auto; font-size: .78rem; font-weight: 850; height: 2.35rem; justify-content: center; text-transform: uppercase; width: 2.35rem; }
.user-cell strong { display: block; font-size: .88rem; }
.user-cell span { color: #77747b; font-size: .76rem; }
.role-list { align-items: center; display: flex; flex-wrap: wrap; gap: .4rem; }
.tag { background: #f1efe8; border: 0; border-radius: 999px; color: #58555b; font-size: .72rem; font-weight: 700; padding: .38rem .62rem; }
.tag:hover { background: #ffe8e8; color: var(--brand-danger); }
.compact-select { font-size: .75rem; min-height: 2.1rem; padding: .35rem .5rem; width: auto; }
.empty-state { color: #77747b; padding: 2.5rem 1rem; text-align: center; }

.split-forms { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1.5rem; }
.mini-form { background: #faf9f5; border: 1px solid var(--brand-line); border-radius: var(--radius-md); padding: 1rem; }
.mini-form h3 { margin-bottom: .8rem; }
.mini-form .form-stack { gap: .7rem; }
.roles-grid { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.role-card { border: 1px solid var(--brand-line); border-radius: var(--radius-md); overflow: hidden; }
.role-card-header { background: var(--brand-ink); color: white; padding: .9rem 1rem; }
.role-card-header h3 { margin-bottom: .18rem; }
.role-code { color: #aaa7ae; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .7rem; }
.permission-list { display: grid; gap: .2rem; padding: .65rem; }
.permission-option { align-items: center; border-radius: .6rem; cursor: pointer; display: flex; font-size: .78rem; gap: .55rem; padding: .5rem; }
.permission-option:hover { background: var(--brand-yellow-soft); }
.permission-option input { accent-color: var(--brand-yellow-strong); height: 1rem; width: 1rem; }

.landing { background: var(--brand-ink); display: grid; min-height: 100vh; overflow: hidden; place-items: center; position: relative; }
.landing::before { background: var(--brand-yellow); border-radius: 50%; content: ""; height: 34rem; position: absolute; right: -12rem; top: -18rem; width: 34rem; }
.landing::after { border: 1px solid rgba(255,255,255,.08); border-radius: 50%; bottom: -20rem; content: ""; height: 40rem; left: -15rem; position: absolute; width: 40rem; }
.landing-card { background: white; border-radius: 2rem; box-shadow: var(--shadow-lg); display: grid; grid-template-columns: minmax(17rem, .85fr) minmax(20rem, 1.25fr); margin: 2rem; max-width: 66rem; overflow: hidden; position: relative; width: calc(100% - 4rem); z-index: 1; }
.landing-brand { align-items: center; background: #f9f8f4; display: flex; justify-content: center; padding: clamp(2rem, 6vw, 4rem); }
.landing-brand img { display: block; max-width: 21rem; width: 100%; }
.landing-content { display: flex; flex-direction: column; justify-content: center; padding: clamp(2rem, 6vw, 5rem); }
.landing-content h1 { font-size: clamp(2.4rem, 5vw, 4.4rem); max-width: 9ch; }
.landing-content .page-intro { font-size: 1rem; max-width: 34rem; }
.landing-status { align-items: center; display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 2rem; }
.status-chip { background: #f2f1ec; border-radius: 999px; color: #68656b; font-size: .75rem; font-weight: 700; padding: .5rem .75rem; }
.status-chip.online { background: #e5f4ec; color: var(--brand-success); }
.status-chip.online::before { content: "●"; margin-right: .4rem; }
.landing-note { border-left: 3px solid var(--brand-yellow); color: #77747b; font-size: .78rem; line-height: 1.55; margin-top: 2rem; padding-left: .8rem; }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-grid { grid-template-columns: 1fr; }
    .roles-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { height: auto; min-height: 0; padding: .75rem; position: static; }
    .brand-card { max-width: 16rem; }
    .sidebar-label, .sidebar-footer { display: none; }
    .sidebar-nav { display: flex; margin-top: .65rem; overflow-x: auto; }
    .sidebar-link { flex: 0 0 auto; }
    .sidebar-link.disabled { display: none; }
    .topbar { min-height: 4rem; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .form-row, .split-forms, .roles-grid { grid-template-columns: 1fr; }
    .landing-card { grid-template-columns: 1fr; margin: 1rem; width: calc(100% - 2rem); }
    .landing-brand { padding: 1.5rem; }
    .landing-brand img { max-width: 13rem; }
    .landing-content { padding: 2rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 1.45rem; }
    .page-container { padding: 1rem; }
    .environment-badge { font-size: .65rem; }
}
