:root {
    --blue-050: #f4f9fc;
    --blue-100: #dcecf4;
    --blue-300: #94c3db;
    --blue-500: #008cb5;
    --petrol-700: #00546d;
    --navy-900: #0b0a1e;
    --white: #ffffff;
    --line: #dbe7ed;
    --muted: #6c7f88;
    --success: #1f8b68;
    --shadow: 0 24px 70px rgba(11, 44, 61, .13);
    --radius-lg: 24px;
    --radius-md: 14px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--navy-900);
    background: var(--blue-050);
    font-family: Montserrat, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
a { color: inherit; }

.eyebrow {
    margin: 0 0 9px;
    color: var(--blue-500);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(380px, 46%) 1fr;
}

.auth-brand {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 58px clamp(42px, 7vw, 110px);
    color: var(--petrol-700);
    background: var(--blue-300);
}

.auth-brand::before,
.auth-brand::after {
    content: '';
    position: absolute;
    border: 1px solid rgba(255, 255, 255, .38);
    border-radius: 999px;
}

.auth-brand::before { width: 420px; height: 420px; right: -240px; top: 15%; }
.auth-brand::after { width: 260px; height: 260px; right: -100px; top: 28%; }

.brand-logo { position: relative; width: 210px; height: auto; z-index: 1; }

.auth-brand h1 {
    position: relative;
    max-width: 570px;
    margin: 0;
    color: var(--navy-900);
    font-size: clamp(36px, 5vw, 68px);
    line-height: 1.03;
    letter-spacing: -.045em;
    z-index: 1;
}

.brand-copy {
    position: relative;
    max-width: 520px;
    margin: 24px 0 0;
    font-size: 17px;
    line-height: 1.75;
    z-index: 1;
}

.brand-foot { position: relative; margin: 0; font-size: 13px; font-weight: 600; z-index: 1; }

.auth-content {
    display: grid;
    place-items: center;
    padding: 40px;
    background: var(--white);
}

.auth-card { width: min(100%, 460px); }
.card-heading { margin-bottom: 34px; }
.card-heading h2 { margin: 0 0 12px; font-size: 36px; letter-spacing: -.035em; }
.card-heading > p:last-child { margin: 0; color: var(--muted); line-height: 1.65; }

.form-stack { display: grid; gap: 20px; }
.field { display: grid; gap: 8px; }
.field > span { color: var(--petrol-700); font-size: 13px; font-weight: 700; }
.field input, .field select {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    color: var(--navy-900);
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fbfdfe;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus { border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(0, 140, 181, .1); }
.field select { appearance: none; background: #fbfdfe; }
.field-error { color: #b52b45; font-size: 12px; line-height: 1.45; }
.check-row { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--blue-500); }

.button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 18px;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
}
.button-primary { min-height: 54px; color: var(--white); background: var(--petrol-700); box-shadow: 0 12px 24px rgba(0, 84, 109, .19); }
.button-primary:hover { background: var(--blue-500); }
.button-wide { width: 100%; justify-content: space-between; padding: 0 20px; }
.button-secondary { color: var(--petrol-700); background: var(--blue-100); }
.support-copy { margin: 30px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px 1fr; }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 34px 24px 22px;
    color: var(--white);
    background: var(--petrol-700);
}
.sidebar-brand { display: flex; align-items: center; gap: 14px; margin: 0 8px 45px; text-decoration: none; }
.sidebar-brand img { width: 132px; filter: brightness(0) invert(1); }
.sidebar-brand span { padding-left: 13px; border-left: 1px solid rgba(255,255,255,.3); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-nav { display: grid; gap: 6px; }
.nav-label { margin: 24px 12px 7px; color: rgba(255,255,255,.52); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.area-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 5px; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; background: rgba(11,10,30,.12); }
.area-switch-item { min-height: 36px; display: grid; place-items: center; padding: 0 8px; color: rgba(255,255,255,.72); border-radius: 8px; font-size: 10px; font-weight: 700; text-align: center; text-decoration: none; }
.area-switch-item:hover { color: var(--white); background: rgba(255,255,255,.1); }
.area-switch-item.active { color: var(--petrol-700); background: var(--white); }
.nav-item { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border-radius: 10px; font-size: 13px; font-weight: 600; text-decoration: none; }
.nav-item.active { color: var(--petrol-700); background: var(--white); }
.nav-item.muted { color: rgba(255,255,255,.68); cursor: default; }
.nav-icon { width: 22px; font-size: 17px; text-align: center; }
.sidebar-user { margin-top: auto; display: flex; align-items: center; gap: 11px; padding: 18px 10px 0; border-top: 1px solid rgba(255,255,255,.15); }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; color: var(--petrol-700); border-radius: 50%; background: var(--blue-300); font-weight: 700; }
.sidebar-user strong, .sidebar-user span { display: block; }
.sidebar-user strong { max-width: 140px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user span { margin-top: 4px; color: rgba(255,255,255,.6); font-size: 10px; }

.app-main { min-width: 0; }
.topbar { min-height: 112px; display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 24px clamp(28px, 5vw, 64px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.84); }
.topbar h1 { margin: 0; font-size: clamp(23px, 3vw, 34px); letter-spacing: -.035em; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.topbar-actions form { margin: 0; }
.text-link { color: var(--petrol-700); font-size: 12px; font-weight: 700; text-decoration: none; }
.content { padding: clamp(28px, 5vw, 64px); }
.notice { margin-bottom: 24px; padding: 14px 18px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.notice.success { color: #146348; background: #dcf4eb; }

.hero-panel {
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
    overflow: hidden;
    padding: clamp(30px, 5vw, 58px);
    color: var(--petrol-700);
    border-radius: var(--radius-lg);
    background: var(--blue-300);
    box-shadow: var(--shadow);
}
.hero-panel h2 { max-width: 650px; margin: 16px 0 12px; color: var(--navy-900); font-size: clamp(28px, 4vw, 46px); letter-spacing: -.045em; }
.hero-panel p { max-width: 680px; margin: 0; line-height: 1.7; }
.status-pill { display: inline-flex; padding: 8px 12px; color: var(--petrol-700); border-radius: 999px; background: rgba(255,255,255,.64); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.hero-mark { flex: 0 0 auto; color: rgba(255,255,255,.72); font-size: clamp(46px, 7vw, 92px); font-weight: 700; letter-spacing: -.07em; transform: rotate(-5deg); }
.hero-mark span { color: var(--blue-500); }
.user-hero { background: linear-gradient(135deg, #b8d9e9, var(--blue-300)); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 24px; }
.stats-grid.three { grid-template-columns: repeat(3, 1fr); }
.stat-card { min-height: 190px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--white); }
.stat-icon { width: 42px; height: 42px; display: grid; place-items: center; color: var(--petrol-700); border-radius: 11px; background: var(--blue-100); font-size: 20px; }
.stat-card p { margin: 22px 0 7px; color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-card strong { display: block; font-size: 30px; }
.stat-card small { display: block; margin-top: 5px; color: #9aabb3; font-size: 10px; }
.module-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 24px; padding: 34px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--white); }
.module-panel h2 { margin: 0; font-size: 23px; }
.module-panel > p { margin: 0; color: var(--muted); line-height: 1.75; }

.management-card { margin-bottom: 24px; padding: 30px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--white); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 26px; }
.section-heading h2 { margin: 0; font-size: 23px; }
.section-heading > p { max-width: 480px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.user-form { display: grid; grid-template-columns: 1fr 1fr 1.5fr 180px auto; align-items: end; gap: 16px; }
.user-form .button { min-height: 52px; }
.module-access { grid-column: 1 / -1; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.module-access legend { padding: 0 6px; color: var(--petrol-700); font-size: 11px; font-weight: 700; }
.module-access p { margin-bottom: 12px; color: var(--muted); font-size: 10px; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.checkbox-grid label { display: inline-flex; align-items: center; gap: 7px; color: var(--petrol-700); font-size: 11px; font-weight: 600; cursor: pointer; }
.checkbox-grid input { width: 16px; height: 16px; accent-color: var(--petrol-700); }
.count-pill, .role-pill, .state-pill { display: inline-flex; align-items: center; border-radius: 999px; font-size: 10px; font-weight: 700; }
.count-pill { padding: 8px 12px; color: var(--petrol-700); background: var(--blue-100); }
.role-pill { padding: 6px 10px; color: #4c6170; background: #edf2f5; }
.role-pill.admin { color: var(--petrol-700); background: var(--blue-100); }
.state-pill { gap: 6px; color: var(--success); }
.state-pill::before { width: 7px; height: 7px; content: ''; border-radius: 50%; background: currentColor; }
.state-pill.locked { color: #b52b45; }
.table-wrap { overflow-x: auto; }
.user-table { width: 100%; border-collapse: collapse; text-align: left; }
.user-table th { padding: 12px 14px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.user-table td { padding: 17px 14px; border-bottom: 1px solid #edf2f5; font-size: 12px; vertical-align: middle; }
.user-table td:first-child strong, .user-table td:first-child span { display: block; }
.user-table td:first-child span { margin-top: 5px; color: var(--muted); font-size: 10px; }
.actions-heading { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.row-actions form { margin: 0; }
.action-button { display: inline-flex; min-height: 34px; padding: 0 11px; align-items: center; color: var(--petrol-700); border: 1px solid var(--line); border-radius: 8px; background: var(--white); cursor: pointer; font-size: 10px; font-weight: 700; text-decoration: none; }
.action-button:hover { background: var(--blue-050); }
.action-button.danger { color: #b52b45; }
.action-button:disabled { opacity: .35; cursor: not-allowed; }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .hero-mark { display: none; }
    .user-form { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { min-height: 330px; padding: 36px 28px; }
    .auth-brand h1 { font-size: 38px; }
    .brand-copy { display: none; }
    .auth-content { padding: 42px 24px; }
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 20px; }
    .sidebar-brand { margin-bottom: 18px; }
    .sidebar-nav, .sidebar-user { display: none; }
    .topbar { align-items: flex-start; padding: 24px; }
    .topbar-actions { flex-direction: column; align-items: flex-end; gap: 10px; }
    .content { padding: 24px; }
    .module-panel { grid-template-columns: 1fr; }
    .section-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
    .stats-grid, .stats-grid.three { grid-template-columns: 1fr; }
    .hero-panel { min-height: auto; padding: 28px; }
    .topbar { flex-direction: column; }
    .topbar-actions { width: 100%; flex-direction: row; justify-content: space-between; align-items: center; }
    .user-form { grid-template-columns: 1fr; }
}
