/* Employee Mobile App — Admin Panel
   Plain CSS (no build step), matches the mobile app's blue/cyan design. */

:root {
    --primary: #3550DC;
    --primary-dark: #1E2A78;
    --accent: #63DCF6;
    --violet: #7C6CF2;
    --success: #16A34A;
    --danger: #DC2626;
    --warning: #D97706;
    --text: #1B1E3D;
    --muted: #6B7280;
    --hint: #A3A8B4;
    --border: #E6E8F0;
    --bg: #F5F6FB;
    --surface: #FFFFFF;
    --field: #F4F5F7;
    --sidebar: #161A3A;
    --radius: 16px;
    --shadow: 0 8px 24px rgba(27, 30, 61, .06);
    --gradient: linear-gradient(90deg, #2F48D8 0%, #4A8BE6 55%, #63DCF6 100%);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.icon { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.block { display: block; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.break { word-break: break-word; }
.link { color: var(--primary); font-weight: 500; }
.link:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
:focus-visible { outline: 3px solid rgba(53, 80, 220, .35); outline-offset: 2px; }

/* ---------- Layout ---------- */
.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: 260px; display: flex; flex-direction: column;
    background: var(--sidebar); color: #C9CDE6;
    padding: 22px 16px;
    transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 24px; color: #fff; }
.brand strong { display: block; font-size: 15.5px; }
.brand small { display: block; color: #8E94C2; font-size: 12px; }
.brand-mark {
    display: inline-grid; place-items: center; width: 40px; height: 40px;
    border-radius: 12px; background: var(--gradient); color: #fff;
    box-shadow: 0 8px 18px rgba(53, 80, 220, .35);
}
.brand-mark.lg { width: 56px; height: 56px; border-radius: 16px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 12px; font-weight: 500; color: #C9CDE6;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(99, 140, 255, .18); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }

.sidebar-footer {
    margin-top: auto; display: flex; align-items: center; gap: 10px;
    padding: 12px; border-radius: 14px; background: rgba(255,255,255,.05);
}
.sidebar-user { min-width: 0; flex: 1; }
.sidebar-user strong, .sidebar-user small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user strong { color: #fff; font-size: 13.5px; }
.sidebar-user small { color: #8E94C2; font-size: 12px; }
.sidebar-footer .icon-btn { color: #C9CDE6; }
.sidebar-footer .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; margin-left: 260px; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 14px;
    padding: 18px 32px; background: rgba(245, 246, 251, .92);
    backdrop-filter: blur(8px); border-bottom: 1px solid transparent;
}
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.topbar-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 10px; }
.topbar .menu-btn { display: none; }
.content { padding: 8px 32px 40px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 16.5px; font-weight: 600; }

.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.profile-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stats-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card {
    --tone: var(--primary);
    position: relative; overflow: hidden;
    background: linear-gradient(135deg, #fff 55%, color-mix(in srgb, var(--tone) 12%, #fff) 100%);
    border-radius: 20px; padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card.tone-blue { --tone: var(--primary); }
.stat-card.tone-green { --tone: var(--success); }
.stat-card.tone-red { --tone: var(--danger); }
.stat-card.tone-violet { --tone: var(--violet); }
.stat-card.tone-cyan { --tone: #0EA5E9; }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-weight: 500; font-size: 13px; }
.stat-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--tone); background: color-mix(in srgb, var(--tone) 12%, transparent); }
.stat-value { display: block; font-size: 28px; font-weight: 700; margin-top: 8px; }
.stat-value-sm { font-size: 16px; margin-top: 12px; }
.stat-card small { color: var(--muted); font-size: 12.5px; }

.chart-box { position: relative; height: 290px; }
.chart-box-sm { height: 290px; }

/* ---------- Map ---------- */
.map { width: 100%; border-radius: 14px; overflow: hidden; background: #EEF1F8; z-index: 0; }
.map-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); }
.map-pin {
    display: block; width: 16px; height: 16px; border-radius: 50%;
    background: var(--primary); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.map-pin.failed { background: var(--danger); }
.leaflet-popup-content { font-family: Inter, system-ui, sans-serif; font-size: 13px; }
.leaflet-popup-content strong { display: block; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th {
    text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table td:has(.inline-toggle) { white-space: nowrap; }
.inline-toggle .switch { gap: 8px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; transition: background .12s; }
.table tbody tr[data-href]:hover { background: #F8F9FD; }
.table .actions { text-align: right; width: 1%; white-space: nowrap; }
.table .empty, .list .empty { text-align: center; color: var(--muted); padding: 32px 12px; }

.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person strong, .person small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person small { color: var(--muted); font-size: 12.5px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--border); }
.list .person { padding: 10px 4px; border-radius: 10px; }
.list .person:hover { background: #F8F9FD; }

.avatar {
    display: inline-grid; place-items: center; flex-shrink: 0;
    width: var(--size, 40px); height: var(--size, 40px); border-radius: 50%;
    background: linear-gradient(135deg, hsl(var(--hue) 70% 52%), hsl(calc(var(--hue) + 40) 80% 68%));
    color: #fff; font-weight: 600; font-size: calc(var(--size, 40px) * .38);
}

/* ---------- Badges ---------- */
.badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-success { color: var(--success); background: rgba(22, 163, 74, .1); }
.badge-danger { color: var(--danger); background: rgba(220, 38, 38, .1); }
.badge-warning { color: var(--warning); background: rgba(217, 119, 6, .12); }
.badge-primary { color: var(--primary); background: rgba(53, 80, 220, .1); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-gradient { background: var(--gradient); color: #fff; box-shadow: 0 8px 18px rgba(53, 80, 220, .28); }
.btn-gradient:hover { box-shadow: 0 10px 22px rgba(53, 80, 220, .38); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #2B44C4; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #F8F9FD; }
.btn-danger-outline { background: #fff; color: var(--danger); border-color: rgba(220, 38, 38, .35); }
.btn-danger-outline:hover { background: rgba(220, 38, 38, .06); }
.icon-btn {
    display: inline-grid; place-items: center; width: 36px; height: 36px;
    border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: #EEF0F7; color: var(--primary); }

/* ---------- Alerts ---------- */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; font-weight: 500; }
.alert-success { background: rgba(22, 163, 74, .1); color: #116B33; }
.alert-error { background: rgba(220, 38, 38, .08); color: #A11B1B; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.form .field { margin-bottom: 0; }
.field label, .field .label { font-weight: 500; color: #3F4250; font-size: 14px; }
.req { color: var(--muted); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=search], select {
    width: 100%; height: 50px; padding: 0 16px;
    font: inherit; color: var(--text); background: var(--field);
    border: 1.5px solid transparent; border-radius: 14px; outline: none;
    transition: border-color .15s, background .15s;
}
input::placeholder { color: var(--hint); }
input:focus, select:focus { border-color: var(--primary); background: #fff; }
input.is-invalid { border-color: var(--danger); background: #FFF7F7; }
.field-error { margin: 0; color: var(--danger); font-size: 12.5px; }
.hint { margin: -6px 0 16px; color: var(--muted); font-size: 12.5px; }
.field .hint { margin: 0; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 70px; }
.password-toggle {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    border: 0; background: transparent; color: var(--primary); font: inherit; font-weight: 600; font-size: 13px;
    padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--primary); }

.segmented { display: inline-flex; padding: 4px; background: var(--field); border-radius: 14px; gap: 4px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 9px 22px; border-radius: 10px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented input:checked + span { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(27, 30, 61, .08); }
.segmented input:focus-visible + span { outline: 3px solid rgba(53, 80, 220, .35); }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; }
.switch input[type=checkbox] { position: absolute; opacity: 0; }
.switch-track { position: relative; width: 44px; height: 26px; border-radius: 999px; background: #CBD0DC; transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(53, 80, 220, .35); }

.switch-block { display: flex; margin-top: 16px; }
.switch-hint { margin: 6px 0 0 56px; }
.switch-sm .switch-track { width: 38px; height: 22px; }
.switch-sm .switch-track::after { width: 16px; height: 16px; }
.switch-sm input:checked + .switch-track::after { transform: translateX(16px); }
.switch-sm input:not(:checked) + .switch-track { background: #E5A3A3; }
.switch-text { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.inline-toggle { display: inline-flex; align-items: center; margin: 0; }
.inline-toggle .switch { position: relative; }
.access-row {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--field); text-align: left;
}
.access-row strong, .access-row small { display: block; }
.access-row small { color: var(--muted); font-size: 12.5px; }
.access-row form { width: auto; margin: 0; }
.text-danger { color: var(--danger); }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px; }
.filters select, .filters input[type=date] { width: auto; height: 42px; min-width: 140px; }
.search-input { position: relative; flex: 1 1 260px; }
.search-input .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--hint); }
.search-input input { height: 42px; padding-left: 40px; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; }

/* ---------- Details ---------- */
.profile-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.profile-card h2 { font-size: 19px; margin-top: 8px; }
.profile-card p { margin: 0 0 6px; }
.profile-card form { width: 100%; margin-top: 14px; }
.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 0; }
.details-1 { grid-template-columns: 1fr; }
.details > div { padding: 11px 0; border-bottom: 1px solid var(--border); }
.details dt { color: var(--muted); font-size: 12.5px; }
.details dd { margin: 2px 0 0; font-weight: 500; word-break: break-word; }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.pagination-info { color: var(--muted); font-size: 13px; }
.pagination-links { display: flex; gap: 4px; }
.page { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 10px; font-weight: 600; color: var(--text); }
a.page:hover { background: #EEF0F7; }
.page.active { background: var(--primary); color: #fff; }
.page.disabled { color: var(--hint); }

/* ---------- Login page ---------- */
.auth-body { min-height: 100vh; background: #F7F8FC; }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-hero {
    display: flex; flex-direction: column; justify-content: center; gap: 16px;
    padding: 64px; color: #fff;
    background: radial-gradient(circle at 80% 10%, rgba(99, 220, 246, .35), transparent 45%), linear-gradient(140deg, #1E2A78, #3550DC 60%, #4A8BE6);
}
.auth-hero h2 { font-size: 32px; }
.auth-hero p { margin: 0; max-width: 420px; color: rgba(255,255,255,.85); font-size: 16px; }
.auth-hero ul { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 12px; }
.auth-hero li { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.92); }
.auth-card {
    align-self: center; justify-self: center; width: min(440px, 100%);
    padding: 48px 40px; margin: 24px; background: #fff; border-radius: 32px;
    box-shadow: 0 20px 50px rgba(27, 30, 61, .08);
}
.auth-card h1 { font-size: 40px; font-weight: 500; letter-spacing: -.5px; }
.auth-card > .muted { margin: 4px 0 28px; }
.auth-card .alert { margin-bottom: 18px; }
.auth-card .btn-gradient { height: 56px; font-size: 17px; font-weight: 500; margin-top: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .grid-2-1, .profile-grid, .form-grid { grid-template-columns: 1fr; }
    .stats-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.25); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(15, 18, 40, .45); }
    .main { margin-left: 0; }
    .topbar .menu-btn { display: inline-grid; }
    .topbar { padding: 14px 16px; flex-wrap: wrap; }
    .topbar-actions { width: 100%; margin-left: 0; }
    .content { padding: 8px 16px 32px; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
}
@media (max-width: 640px) {
    .stats-grid, .stats-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .stat-value { font-size: 23px; }
    .field-row, .details { grid-template-columns: 1fr; }
    .card { padding: 16px; border-radius: 18px; }
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
    .filters > * { flex: 1 1 100%; }
    .filters select, .filters input[type=date] { width: 100%; }
    .auth-card { padding: 36px 22px; margin: 16px; border-radius: 28px; }
    .page-title { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
