:root {
    --ink: #182230;
    --muted: #718096;
    --line: #e8edf2;
    --surface: #ffffff;
    --canvas: #f5f7fa;
    --primary: #3659d9;
    --primary-soft: #edf1ff;
    --sidebar: #17233b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    display: flex;
    width: 264px;
    flex-direction: column;
    color: #d3dbea;
    background: var(--sidebar);
}

.brand {
    display: flex;
    min-height: 78px;
    align-items: center;
    gap: 12px;
    padding: 16px 21px;
    border-bottom: 1px solid rgb(255 255 255 / 8%);
    color: white;
}

.brand:hover { color: white; }
.brand strong, .brand small, .user-meta strong, .user-meta small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand small { margin-top: 2px; color: #94a3b8; font-size: 11px; }

.brand-mark {
    display: inline-grid;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 12px;
    color: white;
    background: linear-gradient(135deg, #617ff5, #394fc4);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .03em;
}

.brand-image { width: 38px; height: 38px; flex: 0 0 38px; }
.login-logo { width: 48px; height: 48px; }

.side-nav { overflow-y: auto; flex: 1; padding: 13px 11px 20px; }
.side-nav::-webkit-scrollbar { width: 5px; }
.side-nav::-webkit-scrollbar-thumb { border-radius: 5px; background: #394660; }

.nav-link {
    display: flex;
    min-height: 37px;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    padding: 7px 10px;
    border-radius: 7px;
    color: #b6c2d5;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-link:hover { color: white; background: rgb(255 255 255 / 7%); }
.nav-link.active { color: white; background: #304477; }
.nav-icon { display: inline-grid; width: 21px; flex: 0 0 21px; place-items: center; color: #8fa9f6; font-size: 11px; font-weight: 700; }
.nav-section { margin: 17px 10px 6px; color: #8290a8; font-size: 9px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.nav-divider { height: 1px; margin: 12px 9px 5px; background: rgb(255 255 255 / 9%); }

.sidebar-bottom {
    display: flex;
    min-height: 68px;
    align-items: center;
    gap: 9px;
    padding: 11px 15px;
    border-top: 1px solid rgb(255 255 255 / 8%);
}

.user-avatar { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 50%; color: #dce5ff; background: #3b4d70; font-weight: 700; }
.user-meta { min-width: 0; }
.user-meta strong { overflow: hidden; color: white; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { margin-top: 3px; color: #94a3b8; font-size: 10px; }
.icon-button { display: grid; width: 30px; height: 30px; place-items: center; border: 0; border-radius: 7px; color: #8a97aa; background: transparent; font-size: 18px; }
.icon-button:hover { color: white; background: rgb(255 255 255 / 8%); }

.main-content { min-height: 100vh; margin-left: 264px; }
.topbar { position: sticky; z-index: 10; top: 0; display: flex; min-height: 70px; align-items: center; justify-content: space-between; padding: 10px 34px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 94%); backdrop-filter: blur(12px); }
.topbar-title span, .topbar-title strong { display: block; }
.topbar-title span { margin-bottom: 2px; color: var(--muted); font-size: 10px; }
.topbar-title strong { font-size: 14px; font-weight: 650; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.portal-badge, .scaffold-badge { padding: 6px 9px; border: 1px solid #e4e9f4; border-radius: 5px; color: #50628d; background: #f6f8ff; font-size: 9px; font-weight: 750; letter-spacing: .07em; }
.topbar-date { color: var(--muted); font-size: 11px; }
.menu-toggle { display: none; border: 0; color: var(--ink); background: transparent; font-size: 19px; }
.page-content { max-width: 1480px; margin: 0 auto; padding: 30px 34px 60px; }
.welcome-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.eyebrow { margin-bottom: 7px; color: #7484a6; font-size: 10px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.welcome-row h1 { margin: 0 0 8px; font-size: clamp(22px, 2.4vw, 29px); font-weight: 680; letter-spacing: -.035em; }
.welcome-row p { font-size: 13px; }

.btn { border-radius: 7px; font-size: 12px; font-weight: 600; }
.btn-primary { border-color: var(--primary); background: var(--primary); }
.btn-primary:hover { border-color: #2948c2; background: #2948c2; }
.form-label { margin-bottom: 6px; color: #435067; font-size: 11px; font-weight: 650; }
.form-control, .form-select { min-height: 39px; border-color: #dfe5ec; border-radius: 6px; font-size: 12px; }
.form-control:focus, .form-select:focus { border-color: #7890ed; box-shadow: 0 0 0 .2rem rgb(54 89 217 / 12%); }
textarea.form-control { min-height: 90px; }
.alert { border: 0; border-radius: 8px; font-size: 12px; }

.metric-row { margin-bottom: 32px; }
.metric-card { display: flex; min-height: 132px; flex-direction: column; justify-content: center; padding: 19px 21px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 600; }
.metric-card strong { margin-top: 8px; font-size: 28px; font-weight: 700; letter-spacing: -.04em; }
.metric-card strong.metric-text { overflow: hidden; font-size: 20px; text-overflow: ellipsis; white-space: nowrap; }
.metric-card small { margin-top: 3px; color: #8a96a8; font-size: 10px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-heading h2 { margin: 0 0 4px; font-size: 17px; font-weight: 680; }
.section-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.subtle-count { color: #7d8999; font-size: 10px; }
.module-group { margin: 0 0 27px; }
.module-group > h3 { margin: 0 0 11px; color: #586780; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.module-card { display: flex; min-height: 91px; align-items: flex-start; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); transition: border-color .15s, transform .15s, box-shadow .15s; }
.module-card:hover { transform: translateY(-2px); border-color: #c9d4f7; box-shadow: 0 7px 20px rgb(34 55 95 / 6%); }
.module-icon { display: grid; width: 33px; height: 33px; flex: 0 0 33px; place-items: center; border-radius: 8px; color: var(--primary); background: var(--primary-soft); font-size: 12px; font-weight: 750; }
.module-card-copy { min-width: 0; flex: 1; }
.module-card-copy strong { display: block; margin: 1px 0 5px; font-size: 12px; font-weight: 680; }
.module-card-copy small { display: block; color: var(--muted); font-size: 10px; line-height: 1.45; }
.module-arrow { margin: 3px 0 0 auto; color: #98a4b7; font-size: 16px; }

.content-card { height: 100%; padding: 21px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.card-title { margin: 0 0 7px; font-size: 14px; font-weight: 700; }
.card-description { margin: 0 0 19px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.table-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.table { margin-bottom: 0; font-size: 11px; }
.table thead th { padding: 10px 9px; border-bottom-color: var(--line); color: #7d899b; font-size: 9px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.table tbody td { padding: 12px 9px; border-color: #f0f2f5; color: #59667a; }
.role-chip, .status-chip { display: inline-block; padding: 4px 7px; border-radius: 5px; color: #53617a; background: #f0f2f6; font-size: 9px; font-weight: 650; white-space: nowrap; }
.status-completed { color: #24804e; background: #e8f7ef; }
.status-in_progress { color: #9a6a13; background: #fff5df; }
.status-open { color: #52617a; background: #eef1f5; }
.status-record { display: inline-block; }
.record-list { margin-top: -3px; }
.record-row { display: flex; gap: 12px; padding: 15px 0; border-top: 1px solid #eef1f4; }
.record-status { width: 3px; flex: 0 0 3px; border-radius: 3px; background: #b3bdcc; }
.record-status.status-in_progress { background: #e5ae43; }
.record-status.status-completed { background: #47a978; }
.record-copy { min-width: 0; flex: 1; }
.record-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.record-title-row strong { font-size: 12px; font-weight: 650; }
.record-copy p { margin: 8px 0; color: #566378; font-size: 11px; line-height: 1.55; }
.record-copy small { display: block; margin-top: 7px; color: #8a96a7; font-size: 9px; }
.record-delete { align-self: flex-start; }
.danger-icon:hover { color: #bf3434; background: #fff1f1; }
.empty-state { display: flex; min-height: 210px; flex-direction: column; align-items: center; justify-content: center; color: #6f7c90; text-align: center; }
.empty-state strong { margin-top: 10px; color: #334054; font-size: 13px; }
.empty-state p { margin: 5px 0 0; font-size: 11px; }
.empty-icon { display: grid; width: 37px; height: 37px; place-items: center; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-size: 19px; }
.module-welcome { margin-bottom: 17px; }
.module-note { margin-bottom: 20px; color: #496183; background: #eef5ff; font-size: 11px; }
.page-empty { min-height: 60vh; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: radial-gradient(ellipse at 18% 0%, #e8edff, transparent 47%), var(--canvas); }
.login-card { width: min(100%, 410px); padding: 36px; border: 1px solid #e6eaf0; border-radius: 14px; background: white; box-shadow: 0 16px 50px rgb(27 43 75 / 8%); }
.login-card h1 { font-weight: 700; letter-spacing: -.03em; }

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.sidebar-open { transform: translateX(0); box-shadow: 12px 0 30px rgb(20 30 55 / 22%); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: inline-grid; width: 35px; height: 35px; place-items: center; }
    .topbar { justify-content: flex-start; gap: 12px; padding: 10px 20px; }
    .topbar-right { margin-left: auto; }
    .page-content { padding: 24px 20px 45px; }
}

@media (max-width: 575px) {
    .topbar-date { display: none; }
    .page-content { padding: 20px 14px 36px; }
    .welcome-row { align-items: flex-start; flex-direction: column; }
    .login-card { padding: 27px 23px; }
}
