@import url('https://fonts.bunny.net/css?family=instrument-sans:400,500,600,700');

:root {
    --blue-950: #133875;
    --blue-900: #17499c;
    --blue-800: #1f57ae;
    --blue-700: #2c66bd;
    --blue-100: #eaf1fc;
    --ink: #17243a;
    --muted: #687994;
    --line: #e2e8f2;
    --surface: #ffffff;
    --canvas: #f3f6fb;
    --success: #17855b;
    --success-bg: #eaf8f2;
    --danger: #c2414d;
    --danger-bg: #fff0f1;
    --warning: #a86613;
    --warning-bg: #fff7e6;
    --sidebar-width: 264px;
    --sidebar-compact: 84px;
    font-family: 'Instrument Sans', Arial, sans-serif;
    color: var(--ink);
    background: var(--canvas);
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.icon { display: block; flex: 0 0 auto; }

.admin-shell { min-height: 100vh; padding-left: var(--sidebar-width); transition: padding-left .25s ease; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; display: flex; width: var(--sidebar-width); flex-direction: column; overflow: hidden; color: #fff; background: linear-gradient(155deg, #2d66b9 0%, #17499c 55%, #143d82 100%); box-shadow: 8px 0 28px rgba(24, 61, 130, .12); transition: width .25s ease, transform .25s ease; }
.sidebar-brand { display: flex; min-height: 86px; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 18px; border-bottom: 1px solid rgba(255,255,255,.13); }
.brand-link { display: flex; min-width: 0; align-items: center; gap: 12px; text-decoration: none; }
.brand-link img { width: 72px; height: 43px; object-fit: contain; }
.brand-copy, .user-copy { display: grid; min-width: 0; gap: 2px; white-space: nowrap; }
.brand-copy strong { font-size: 15px; font-weight: 700; }
.brand-copy small, .user-copy small { color: rgba(255,255,255,.68); font-size: 11px; }
.sidebar-collapse, .mobile-menu { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border: 0; border-radius: 6px; color: inherit; background: rgba(255,255,255,.1); cursor: pointer; }
.sidebar-collapse:hover { background: rgba(255,255,255,.18); }
.sidebar-nav { flex: 1; padding: 20px 14px; overflow-y: auto; }
.nav-label { margin: 0 12px 8px; color: rgba(255,255,255,.54); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.nav-item { display: flex; height: 48px; align-items: center; gap: 14px; margin-bottom: 5px; padding: 0 14px; border-radius: 7px; color: rgba(255,255,255,.76); font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: background .15s ease, color .15s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.1); }
.nav-item.is-active { color: var(--blue-900); background: #fff; box-shadow: 0 8px 22px rgba(10, 40, 98, .17); }
.nav-divider { height: 1px; margin: 18px 5px; background: rgba(255,255,255,.13); }
.sidebar-footer { padding: 16px 14px 18px; border-top: 1px solid rgba(255,255,255,.13); }
.sidebar-user { display: flex; align-items: center; gap: 11px; padding: 0 8px 14px; }
.user-avatar { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; background: rgba(255,255,255,.13); font-weight: 700; }
.user-copy strong { max-width: 155px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; }
.sidebar-footer form { margin: 0; }
.logout-button { display: flex; width: 100%; height: 42px; align-items: center; gap: 14px; padding: 0 13px; border: 0; border-radius: 6px; color: rgba(255,255,255,.76); background: transparent; cursor: pointer; white-space: nowrap; }
.logout-button:hover { color: #fff; background: rgba(255,255,255,.1); }

.admin-workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; height: 86px; align-items: center; padding: 0 32px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); box-shadow: 0 2px 10px rgba(24,48,87,.04); backdrop-filter: blur(10px); }
.mobile-menu { display: none; color: var(--blue-900); background: var(--blue-100); }
.topbar-title { display: grid; gap: 3px; }
.topbar-title span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.topbar-title strong { font-size: 22px; line-height: 1.1; }
.topbar-user { display: flex; align-items: center; gap: 11px; margin-left: auto; padding-left: 24px; border-left: 1px solid var(--line); }
.topbar-user > span:last-child { display: grid; gap: 1px; }
.topbar-user strong { max-width: 170px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user small { color: var(--muted); font-size: 11px; }
.topbar-avatar { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; color: var(--blue-900); background: var(--blue-100); }
.admin-main { width: min(100%, 1500px); margin: 0 auto; padding: 30px 32px 48px; }
.sidebar-overlay { display: none; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.page-header h1 { margin: 0; font-size: clamp(24px, 3vw, 32px); line-height: 1.2; }
.page-header p { max-width: 680px; margin: 7px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.page-actions, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel { padding: 24px; border: 1px solid rgba(220,228,240,.8); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px rgba(32,55,90,.06); }
.panel + .panel { margin-top: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.panel-heading h2 { margin: 0; font-size: 18px; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border: 1px solid var(--blue-900); border-radius: 6px; color: #fff; background: var(--blue-900); font-size: 13px; font-weight: 700; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer; transition: transform .15s ease, background .15s ease, box-shadow .15s ease; }
.button:hover { background: var(--blue-800); box-shadow: 0 6px 15px rgba(23,73,156,.18); transform: translateY(-1px); }
.button.secondary { border-color: #ccd7e7; color: var(--ink); background: #fff; }
.button.secondary:hover { border-color: #aebed5; background: #f7f9fc; box-shadow: none; }
.button.warn { border-color: var(--warning); background: var(--warning); }
.button.danger { border-color: var(--danger); background: var(--danger); }
.button.small { min-height: 34px; padding: 0 11px; font-size: 12px; }
.text-link { color: var(--blue-900); font-size: 13px; font-weight: 700; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.download-menu { position: relative; flex: 0 0 auto; }
.download-menu summary { list-style: none; }
.download-menu summary::-webkit-details-marker { display: none; }
.download-menu[open] summary { border-color: #aebed5; background: #f7f9fc; }
.download-options { position: absolute; top: calc(100% + 7px); left: 0; z-index: 25; display: grid; width: 158px; padding: 6px; border: 1px solid #d7e0ee; border-radius: 7px; background: #fff; box-shadow: 0 14px 30px rgba(24,48,87,.14); }
.download-options a { display: flex; min-height: 34px; align-items: center; padding: 0 10px; border-radius: 5px; color: #34445d; font-size: 12px; font-weight: 700; text-decoration: none; }
.download-options a:hover { color: var(--blue-900); background: var(--blue-100); }

.dashboard-hero { position: relative; min-height: 220px; overflow: hidden; padding: 30px 34px; border-radius: 8px; color: #fff; background: linear-gradient(125deg, #3469b8 0%, #17499c 65%, #14397c 100%); box-shadow: 0 12px 25px rgba(20,61,130,.18); }
.dashboard-hero::after { position: absolute; width: 280px; height: 280px; right: -72px; bottom: -130px; border: 45px solid rgba(255,255,255,.08); border-radius: 50%; content: ''; }
.hero-date { display: flex; align-items: center; gap: 9px; color: rgba(255,255,255,.78); font-size: 13px; font-weight: 600; }
.hero-copy { position: relative; z-index: 1; margin-top: 30px; }
.hero-copy span { color: rgba(255,255,255,.8); font-size: 15px; }
.hero-copy strong { display: block; margin-top: 4px; font-size: 52px; line-height: 1; }
.hero-mark { position: absolute; right: 42px; bottom: 27px; display: grid; width: 116px; height: 116px; place-items: center; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; color: #fff; background: rgba(255,255,255,.1); }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.stat-card { min-height: 145px; padding: 22px; border: 1px solid rgba(220,228,240,.8); border-radius: 8px; background: #fff; box-shadow: 0 8px 20px rgba(32,55,90,.06); }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 6px; color: var(--blue-800); background: var(--blue-100); }
.stat-icon.green { color: var(--success); background: var(--success-bg); }
.stat-icon.amber { color: var(--warning); background: var(--warning-bg); }
.stat-card strong { display: block; margin-top: 26px; font-size: 31px; line-height: 1; }

.alert { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 20px; padding: 14px 16px; border: 1px solid; border-radius: 7px; font-size: 13px; line-height: 1.5; }
.alert-success { border-color: #b9e2d0; color: #126b49; background: var(--success-bg); }
.alert-error { border-color: #f0c8cc; color: #a8323f; background: var(--danger-bg); }
.alert ul { margin: 5px 0 0; padding-left: 18px; }
.filters, .fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.filters { grid-template-columns: repeat(2, minmax(180px, 260px)) auto; align-items: end; margin-bottom: 22px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: #f8fafd; }
.filter-actions { display: flex; grid-column: 1 / -1; flex-wrap: nowrap; align-items: center; gap: 8px; }
.bulk-card-form { display: flex; align-items: end; justify-content: flex-start; gap: 16px; margin: -6px 0 22px; padding: 16px 18px; border: 1px solid #cbd9ef; border-radius: 7px; background: var(--blue-100); }
.bulk-valid-until { width: min(100%, 250px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; box-shadow: none; }
.field { display: grid; align-content: start; gap: 7px; min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field label, .field-label { color: #34445d; font-size: 12px; font-weight: 700; }
.field input, .field select { width: 100%; min-width: 0; height: 43px; padding: 0 12px; border: 1px solid #cbd6e5; border-radius: 6px; outline: none; color: var(--ink); background: #fff; font-size: 14px; transition: border .15s ease, box-shadow .15s ease; }
.field input[type=file] { height: auto; padding: 9px 10px; }
.field input:focus, .field select:focus { border-color: var(--blue-700); box-shadow: 0 0 0 3px rgba(44,102,189,.13); }
.field small, .muted { color: var(--muted); font-size: 12px; line-height: 1.5; }
.check { display: flex; min-height: 43px; align-items: center; gap: 9px; margin-top: 22px; color: #34445d; font-size: 13px; font-weight: 600; }
.check input { width: 17px; height: 17px; accent-color: var(--blue-900); }
.form-footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 13px; white-space: nowrap; }
th { color: var(--muted); background: #f8fafd; font-size: 10px; font-weight: 700; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfe; }
.employee-cell { display: flex; align-items: center; gap: 11px; }
.employee-mini-avatar { display: grid; width: 36px; height: 36px; place-items: center; overflow: hidden; border-radius: 50%; color: var(--blue-900); background: var(--blue-100); font-weight: 700; }
.employee-mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.employee-cell strong { display: block; }
.employee-cell small { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 5px; font-size: 10px; font-weight: 700; line-height: 1; }
.badge.active { color: var(--success); background: var(--success-bg); }
.badge.inactive { color: var(--danger); background: var(--danger-bg); }
.badge.demo { color: var(--warning); background: var(--warning-bg); }
.badge.neutral { color: #52647f; background: #edf1f6; }
.pagination { margin-top: 18px; }
.pagination nav > div:first-child { display: none; }
.pagination nav > div:last-child { display: flex; align-items: center; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 12px; }
.pagination svg { width: 17px; }
.pagination a, .pagination span { text-decoration: none; }

.profile-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; }
.profile-main { display: flex; min-width: 0; align-items: center; gap: 16px; }
.profile-avatar { display: grid; width: 72px; height: 72px; flex: 0 0 auto; place-items: center; overflow: hidden; border-radius: 50%; color: var(--blue-900); background: var(--blue-100); font-size: 24px; font-weight: 700; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-main h1 { margin: 0; font-size: 25px; overflow-wrap: anywhere; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0 10px; color: var(--muted); font-size: 13px; }
.profile-actions { justify-content: flex-end; }
.status-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.card-list { display: grid; gap: 12px; }
.card-row { padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: #fbfcfe; }
.card-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.card-meta strong { font-size: 14px; }
.card-details { display: flex; flex-wrap: wrap; gap: 5px 16px; margin-top: 6px; color: var(--muted); font-size: 12px; }
.token { max-width: 100%; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: #4b5d78; font-size: 11px; }
.card-row .actions { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.empty-state { padding: 28px; color: var(--muted); text-align: center; }

.admin-shell.is-collapsed { padding-left: var(--sidebar-compact); }
.admin-shell.is-collapsed .sidebar { width: var(--sidebar-compact); }
.admin-shell.is-collapsed .sidebar-brand { justify-content: center; padding-inline: 12px; }
.admin-shell.is-collapsed .brand-link { display: none; }
.admin-shell.is-collapsed .brand-copy, .admin-shell.is-collapsed .user-copy, .admin-shell.is-collapsed .nav-item span, .admin-shell.is-collapsed .nav-label, .admin-shell.is-collapsed .logout-button span { display: none; }
.admin-shell.is-collapsed .sidebar-collapse { width: 46px; height: 42px; color: var(--blue-900); background: #fff; box-shadow: 0 7px 17px rgba(7,36,91,.18); }
.admin-shell.is-collapsed .sidebar-collapse svg { transform: rotate(180deg); }
.admin-shell.is-collapsed .sidebar-nav { padding: 20px 12px 18px; }
.admin-shell.is-collapsed .nav-item { width: 52px; height: 52px; justify-content: center; margin: 0 auto 8px; padding: 0; }
.admin-shell.is-collapsed .sidebar-user { justify-content: center; padding-inline: 0; }
.admin-shell.is-collapsed .logout-button { width: 52px; justify-content: center; margin: auto; padding: 0; }

@media (max-width: 1120px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .admin-shell, .admin-shell.is-collapsed { padding-left: 0; }
    .sidebar, .admin-shell.is-collapsed .sidebar { width: min(86vw, 290px); transform: translateX(-105%); }
    .admin-shell.is-mobile-open .sidebar { transform: translateX(0); }
    .admin-shell.is-collapsed.is-mobile-open .sidebar { transform: translateX(0); }
    .sidebar-brand, .admin-shell.is-collapsed .sidebar-brand { justify-content: space-between; padding: 17px 18px; }
    .admin-shell.is-collapsed .brand-link { display: flex; }
    .admin-shell.is-collapsed .brand-link img { width: 72px; }
    .admin-shell.is-collapsed .brand-copy, .admin-shell.is-collapsed .user-copy, .admin-shell.is-collapsed .nav-item span, .admin-shell.is-collapsed .nav-label, .admin-shell.is-collapsed .logout-button span { display: grid; }
    .admin-shell.is-collapsed .nav-item span, .admin-shell.is-collapsed .logout-button span { display: inline; }
    .sidebar-collapse, .admin-shell.is-collapsed .sidebar-collapse { display: none; }
    .admin-shell.is-collapsed .sidebar-nav { padding: 20px 14px; }
    .admin-shell.is-collapsed .nav-item { width: auto; height: 48px; justify-content: flex-start; margin: 0 0 5px; padding: 0 14px; }
    .admin-shell.is-collapsed .sidebar-user { justify-content: flex-start; padding: 0 8px 14px; }
    .admin-shell.is-collapsed .logout-button { width: 100%; justify-content: flex-start; margin: 0; padding: 0 13px; }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 35; display: block; border: 0; visibility: hidden; opacity: 0; background: rgba(10,24,48,.48); transition: opacity .2s, visibility .2s; }
    .admin-shell.is-mobile-open .sidebar-overlay { visibility: visible; opacity: 1; }
    .topbar { height: 72px; gap: 13px; padding: 0 16px; }
    .mobile-menu { display: grid; }
    .topbar-title span { display: none; }
    .topbar-title strong { max-width: 48vw; overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
    .topbar-user { padding-left: 0; border-left: 0; }
    .topbar-user > span:last-child { display: none; }
    .topbar-avatar { width: 36px; height: 36px; }
    .admin-main { padding: 22px 16px 38px; }
    .page-header { align-items: stretch; flex-direction: column; gap: 15px; }
    .page-header h1 { font-size: 25px; }
    .page-actions .button { flex: 1; }
    .panel { padding: 18px; }
    .dashboard-hero { min-height: 205px; padding: 25px; }
    .hero-copy { margin-top: 30px; }
    .hero-copy strong { font-size: 45px; }
    .hero-mark { right: 20px; bottom: 24px; width: 88px; height: 88px; opacity: .62; }
    .hero-mark .icon { width: 46px; height: 46px; }
    .stats-grid { gap: 12px; }
    .stat-card { min-height: 130px; padding: 17px; }
    .stat-card strong { margin-top: 22px; }
    .filters, .fields { grid-template-columns: 1fr; }
    .filters { align-items: stretch; padding: 15px; }
    .filter-actions { align-items: stretch; }
    .bulk-card-form { align-items: stretch; flex-direction: column; }
    .bulk-valid-until, .bulk-card-form .button { width: 100%; }
    .field-full { grid-column: auto; }
    .check { margin-top: 0; }
    .profile-summary { grid-template-columns: 1fr; }
    .profile-main { align-items: flex-start; }
    .profile-avatar { width: 60px; height: 60px; }
    .profile-main h1 { font-size: 21px; }
    .profile-actions { justify-content: flex-start; }
    .card-meta { align-items: flex-start; flex-direction: column; }
    .card-row .actions .button, .card-row .actions form, .card-row .actions .download-menu { flex: 1 1 calc(50% - 8px); }
    .download-menu summary { width: 100%; }
    .card-row .actions form .button { width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: 112px; }
    .stat-card strong { margin-top: 14px; }
    .dashboard-hero { min-height: 188px; }
    .hero-mark { display: none; }
    .page-actions, .form-footer { align-items: stretch; flex-direction: column-reverse; }
    .page-actions .button, .form-footer .button { width: 100%; }
    .profile-main { flex-direction: column; }
    .card-row .actions .button, .card-row .actions form, .card-row .actions .download-menu { flex-basis: 100%; }
    .download-options { position: static; width: 100%; margin-top: 6px; box-shadow: none; }
}

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

.admin-auth-body { min-height: 100svh; background: linear-gradient(135deg, #eaf0f9, #f7f9fc 48%, #e8eff9); }
.admin-auth-page { min-height: 100svh; display: grid; place-items: center; padding: 28px 18px; }
.login-card { width: min(100%, 430px); overflow: hidden; border: 1px solid rgba(215,225,239,.9); border-radius: 8px; background: #fff; box-shadow: 0 22px 55px rgba(32,58,101,.14); }
.login-brand { display: flex; align-items: center; gap: 14px; padding: 25px 27px; color: #fff; background: linear-gradient(125deg, #3168b9, #17499c 68%, #143a7e); }
.login-brand img { width: 82px; height: 48px; object-fit: contain; }
.login-brand div { display: grid; gap: 2px; }
.login-brand strong { font-size: 16px; }
.login-brand span { color: rgba(255,255,255,.7); font-size: 11px; font-weight: 600; text-transform: uppercase; }
.login-content { padding: 28px; }
.login-heading { margin-bottom: 22px; }
.login-heading h1 { margin: 0; font-size: 25px; }
.login-heading p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.login-content .field + .field { margin-top: 15px; }
.login-remember { display: flex; align-items: center; gap: 8px; margin: 17px 0; color: #52647f; font-size: 12px; font-weight: 600; }
.login-remember input { width: 16px; height: 16px; accent-color: var(--blue-900); }
.login-submit { width: 100%; }

@media (max-width: 480px) {
    .admin-auth-page { padding: 0; background: #fff; }
    .login-card { min-height: 100svh; border: 0; border-radius: 0; box-shadow: none; }
    .login-brand { padding: 27px 22px; }
    .login-content { padding: 30px 22px; }
}
