:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #172033;
    --muted: #657188;
    --line: #dce3ed;
    --primary: #135fe8;
    --primary-dark: #0d47b5;
    --success: #087a55;
    --success-bg: #e8f8f1;
    --danger: #b42318;
    --danger-bg: #fff0ee;
    --warning: #a15c00;
    --shadow: 0 12px 34px rgba(27, 46, 86, .08);
    --radius: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100%; color: var(--text); background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 18px; background: #10182a; color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 4px 32px; }
.brand span:last-child { display: flex; flex-direction: column; }
.brand strong { font-size: 18px; letter-spacing: -.02em; }
.brand small { color: #aeb9cd; font-size: 11px; }
.brand-mark { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(145deg, #2376ff, #0b49bd); color: #fff; font-weight: 800; letter-spacing: -.04em; box-shadow: 0 8px 20px rgba(19, 95, 232, .35); }
.brand-mark-large { width: 50px; height: 50px; border-radius: 15px; font-size: 18px; }
.nav { display: grid; gap: 6px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #cad3e4; font-size: 14px; transition: .15s ease; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-link span { width: 20px; color: #7e9fe5; font-size: 18px; }
.sidebar-footer { margin-top: auto; }
.user-card { display: flex; flex-direction: column; margin-bottom: 12px; padding: 14px; border: 1px solid rgba(255,255,255,.09); border-radius: 12px; background: rgba(255,255,255,.04); }
.user-card strong { font-size: 14px; }
.user-card span { color: #bdc7d9; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.user-card small { margin-top: 6px; color: #82aaff; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }

.main { min-width: 0; }
.topbar { height: 66px; display: flex; align-items: center; justify-content: flex-end; padding: 0 36px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.85); backdrop-filter: blur(12px); }
.topbar > div { display: flex; align-items: center; gap: 10px; }
.environment { padding: 4px 8px; border-radius: 6px; background: #edf3ff; color: #1452c4; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.request-reference { color: var(--muted); font-size: 13px; }
.menu-toggle { display: none; margin-right: auto; border: 0; background: transparent; font-size: 22px; }
.content { max-width: 1440px; margin: 0 auto; padding: 36px; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-header.compact { margin-bottom: 20px; }
.page-header h1 { margin: 5px 0 6px; font-size: clamp(28px, 3vw, 38px); line-height: 1.12; letter-spacing: -.035em; }
.page-header p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--primary); font-size: 13px; font-weight: 650; }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 5px 18px rgba(27,46,86,.04); }
.stat-card span { display: block; color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 6px; font-size: 30px; letter-spacing: -.04em; }
.table-card { overflow: hidden; }
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; text-align: left; vertical-align: middle; border-bottom: 1px solid #e8edf4; font-size: 13px; }
th { color: #758097; background: #f8fafc; font-size: 11px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.actions-column { min-width: 260px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.actions form { margin: 0; }
.error-detail { max-width: 310px; color: var(--danger) !important; }

.btn { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; font-size: 13px; transition: .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 7px 16px rgba(19,95,232,.18); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { border-color: var(--line); background: #fff; color: #37435a; }
.btn-ghost { border-color: rgba(130,150,184,.35); background: transparent; color: inherit; }
.btn-danger-ghost { border-color: #f2c7c3; background: #fff; color: var(--danger); }
.btn-small { min-height: 32px; padding: 6px 10px; font-size: 11px; }
.btn-large { min-height: 48px; padding: 12px 19px; }
.btn-block { width: 100%; }

.badge { display: inline-flex; align-items: center; gap: 5px; width: fit-content; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: #eef2f7; color: #566178; }
.alert { margin-bottom: 20px; padding: 13px 15px; border: 1px solid; border-radius: 10px; font-size: 13px; font-weight: 600; }
.alert-success { border-color: #b9e8d5; background: var(--success-bg); color: var(--success); }
.alert-error { border-color: #f0c1bc; background: var(--danger-bg); color: var(--danger); }

.empty-state { display: grid; place-items: center; min-height: 360px; padding: 48px 24px; border: 1px dashed #c9d4e3; border-radius: var(--radius); background: rgba(255,255,255,.65); text-align: center; }
.empty-state h1, .empty-state h2 { margin: 8px 0; letter-spacing: -.025em; }
.empty-state p { max-width: 570px; margin: 0 0 22px; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: #eaf1ff; color: var(--primary); font-size: 26px; font-weight: 800; }
.error-state .empty-icon { background: var(--danger-bg); color: var(--danger); }

.form-card { padding: 28px; }
.form-card-narrow { max-width: 720px; }
.form-section + .form-section { margin-top: 30px; padding-top: 28px; border-top: 1px solid var(--line); }
.section-heading { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 20px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.step { display: grid; place-items: center; flex: 0 0 30px; height: 30px; border-radius: 9px; background: #eaf1ff; color: var(--primary); font-size: 12px; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { display: grid; gap: 7px; }
.field > span { font-size: 12px; font-weight: 750; color: #344056; }
.field input, .field select { width: 100%; min-height: 45px; padding: 10px 12px; border: 1px solid #cdd6e3; border-radius: 9px; background: #fff; color: var(--text); outline: none; }
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(19,95,232,.12); }
.field small { color: var(--muted); font-size: 11px; }
.read-only-field { align-content: start; padding: 12px; border: 1px dashed #cbd6e4; border-radius: 9px; background: #f8fafc; }
.read-only-field strong { font-size: 13px; word-break: break-all; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.identity-summary { display: flex; flex-direction: column; margin-bottom: 20px; padding: 15px; border-radius: 10px; background: #f4f7fb; }
.identity-summary span { color: var(--muted); font-size: 13px; }

.login-page { background: #0c1424; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1.1fr) minmax(420px, .9fr); }
.login-presentation { display: flex; flex-direction: column; justify-content: space-between; padding: clamp(38px, 6vw, 82px); color: #fff; background: radial-gradient(circle at 20% 20%, rgba(31,105,255,.28), transparent 36%), linear-gradient(145deg, #101a30, #08101e); }
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 21px; font-weight: 800; }
.login-presentation h1 { max-width: 720px; margin: 15px 0; font-size: clamp(38px, 5vw, 66px); line-height: 1.02; letter-spacing: -.055em; }
.login-presentation p { max-width: 600px; color: #b9c6dc; font-size: 17px; }
.security-note { max-width: 520px; padding: 14px 16px; border: 1px solid rgba(255,255,255,.11); border-radius: 11px; background: rgba(255,255,255,.05); color: #cad5e7; font-size: 12px; }
.login-panel { display: grid; place-items: center; padding: 30px; background: #f4f7fb; }
.auth-card { width: min(460px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 30px 70px rgba(7,18,38,.12); }
.auth-heading { margin-bottom: 24px; }
.auth-heading h2 { margin: 7px 0 3px; font-size: 29px; letter-spacing: -.035em; }
.auth-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.auth-card .field { margin-bottom: 16px; }
.form-footnote { margin: 15px 0 0; color: var(--muted); text-align: center; font-size: 11px; }

@media (max-width: 960px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 50; left: -280px; width: 260px; transition: left .2s ease; box-shadow: 14px 0 35px rgba(0,0,0,.18); }
    .menu-open .sidebar { left: 0; }
    .menu-toggle { display: block; }
    .topbar { padding: 0 20px; }
    .content { padding: 25px 20px; }
    .login-layout { grid-template-columns: 1fr; }
    .login-presentation { min-height: 42vh; padding: 38px 28px; }
    .login-presentation h1 { font-size: 40px; }
    .security-note { display: none; }
}

@media (max-width: 700px) {
    .page-header { flex-direction: column; }
    .page-header > .btn { width: 100%; }
    .stats-grid, .form-grid { grid-template-columns: 1fr; }
    .form-card { padding: 20px; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .login-panel { padding: 18px; }
    .auth-card { padding: 25px 20px; }
    .login-presentation { min-height: 34vh; }
    .login-presentation h1 { font-size: 32px; }
}
