:root {
    --navy-950: #041b28;
    --navy-900: #062332;
    --navy-800: #0b3446;
    --teal-600: #0e9f9a;
    --teal-500: #16b8ae;
    --blue-700: #145b96;
    --blue-600: #1a6fb5;
    --ink: #102238;
    --muted: #607187;
    --line: #d9e2eb;
    --surface: #ffffff;
    --canvas: #f2f5f8;
    --danger: #b93c49;
    --shadow: 0 10px 30px rgba(14, 39, 57, .08);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 272px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; color: #e8f5f5; background: linear-gradient(180deg, var(--navy-950), var(--navy-900)); border-right: 1px solid rgba(255,255,255,.06); padding: 28px 18px 20px; z-index: 30; }
.brand { min-height: 116px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; border-bottom: 1px solid rgba(255,255,255,.11); margin: 0 4px 28px; padding-bottom: 22px; }
.brand img { width: 174px; max-height: 69px; object-fit: contain; filter: brightness(0) invert(1); }
.brand span { color: #75d8d1; font-size: .75rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.main-nav { display: grid; gap: 8px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 14px; border: 0; border-radius: 8px; padding: 13px 16px; background: transparent; color: #d8e8ed; text-align: left; transition: .18s ease; }
.nav-item span { width: 22px; color: #92b8c3; text-align: center; font-size: 1.1rem; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.is-active { color: #fff; background: var(--teal-600); box-shadow: 0 8px 18px rgba(14,159,154,.2); }
.nav-item.is-active span { color: #fff; }
.sidebar-footer { margin-top: auto; padding: 18px 12px 0; border-top: 1px solid rgba(255,255,255,.1); display: grid; gap: 3px; }
.sidebar-footer span, .sidebar-footer small { color: #88a9b3; font-size: .75rem; }
.sidebar-footer strong { overflow: hidden; text-overflow: ellipsis; }

.app-main { min-width: 0; min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.topbar { min-height: 102px; display: flex; align-items: center; gap: 16px; background: #fff; border-bottom: 1px solid var(--line); padding: 22px 34px; }
.topbar h1 { margin: 0 0 4px; font-size: clamp(1.6rem, 2.4vw, 2rem); letter-spacing: -.03em; }
.topbar p { margin: 0; color: var(--muted); }
.connection-chip { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: #eff5f7; color: #556b76; font-size: .82rem; font-weight: 700; }
.connection-chip span, .status-dot { width: 8px; height: 8px; border-radius: 50%; background: #91a2ad; }
.connection-chip.is-online { color: #087b5d; background: #e5f6ef; }
.connection-chip.is-online span, .status-dot { background: #13a776; }
.connection-chip.is-offline { color: #a43945; background: #fcebed; }
.connection-chip.is-offline span { background: #d34c5a; }
.menu-toggle { display: none; border: 0; background: transparent; color: var(--ink); font-size: 1.5rem; }

.content { min-width: 0; padding: 28px 34px 36px; }
.app-view { display: none; }
.app-view.is-active { display: block; animation: view-in .2s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric-card { position: relative; min-height: 138px; padding: 22px 24px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.metric-card::after { content: ""; position: absolute; right: -26px; bottom: -35px; width: 88px; height: 88px; border-radius: 50%; background: rgba(22,184,174,.08); }
.metric-card span { display: block; color: var(--muted); font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.metric-card strong { display: block; margin: 14px 0 7px; font-size: clamp(1.55rem, 2.4vw, 2.05rem); line-height: 1; }
.metric-card small { color: #8a98a7; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0; }
.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 5px; padding: 9px 17px; font-weight: 750; transition: .17s ease; text-decoration: none; }
.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(18,50,72,.12); }
.button:focus-visible, input:focus-visible, .nav-item:focus-visible, .tab:focus-visible { outline: 3px solid rgba(22,184,174,.28); outline-offset: 2px; }
.button:disabled { opacity: .48; cursor: not-allowed; }
.button-primary { color: #fff; background: var(--blue-700); border-color: var(--blue-700); }
.button-secondary { color: var(--blue-700); background: #fff; border-color: #b8cce0; }
.button-ghost { color: #536b80; background: transparent; border-color: transparent; }
.button-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button-block { width: 100%; }

.panel { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.table-panel { overflow: hidden; }
.panel-heading { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 4px 0 0; font-size: 1.12rem; }
.eyebrow { color: var(--teal-600); font-size: .7rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.record-count { flex: 0 0 auto; color: var(--muted); font-size: .82rem; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { position: sticky; top: 0; z-index: 1; padding: 11px 13px; color: #334b60; background: #e9eff4; border-bottom: 1px solid #cad6e1; text-align: left; white-space: nowrap; }
td { padding: 11px 13px; border-bottom: 1px solid #e4e9ee; color: #33465b; white-space: nowrap; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: #eff8f7; }
tbody tr.is-selectable { cursor: pointer; }
tbody tr.is-selected { background: #dff4f2; box-shadow: inset 3px 0 var(--teal-600); }
.cell-muted { color: #91a0ad; }
.status-pill { display: inline-flex; border-radius: 999px; padding: 4px 8px; background: #e5f6ef; color: #087b5d; font-size: .74rem; font-weight: 800; }
.status-pill.is-inactive { color: #875d11; background: #fff2d4; }
.empty-row td { height: 120px; color: var(--muted); text-align: center; white-space: normal; }

.import-panel { margin-bottom: 18px; }
.import-toolbar { display: flex; flex-wrap: wrap; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-summary { display: grid; grid-template-columns: minmax(0, 1fr) 150px 150px; }
.file-summary div { display: grid; gap: 4px; padding: 15px 20px; border-right: 1px solid var(--line); }
.file-summary div:last-child { border-right: 0; }
.file-summary span { color: var(--muted); font-size: .74rem; font-weight: 750; text-transform: uppercase; }
.file-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); background: #f8fafb; }
.tab { border: 0; border-bottom: 3px solid transparent; padding: 15px 20px 12px; color: var(--muted); background: transparent; font-weight: 750; white-space: nowrap; }
.tab.is-active { color: var(--blue-700); border-bottom-color: var(--teal-600); background: #fff; }
.tab-panel { display: none; min-height: 330px; }
.tab-panel.is-active { display: block; }
.empty-state { padding: 46px 20px; color: var(--muted); text-align: center; }

.employee-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; align-items: start; }
.employee-form { display: grid; gap: 7px; padding: 0 20px 22px; }
.employee-form .panel-heading { margin: 0 -20px 10px; }
.employee-form > label:not(.check-row), .login-form > label:not(.check-row) { color: #44596d; font-size: .8rem; font-weight: 750; margin-top: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"], select { width: 100%; min-height: 42px; border: 1px solid #bdcad6; border-radius: 5px; background: #fff; color: var(--ink); padding: 9px 11px; }
input[type="time"], textarea { width: 100%; min-height: 42px; border: 1px solid #bdcad6; border-radius: 5px; background: #fff; color: var(--ink); padding: 9px 11px; }
.check-row { display: flex; align-items: center; gap: 9px; color: #40566a; font-size: .84rem; margin: 10px 0; }
.check-row input { width: 17px; height: 17px; accent-color: var(--teal-600); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.employee-list { min-width: 0; }
.employee-heading { align-items: flex-end; }
.search-box { width: min(430px, 100%); display: flex; gap: 8px; }
.table-hint { margin: 0; padding: 9px 20px; color: var(--muted); background: #f7f9fb; border-bottom: 1px solid var(--line); font-size: .77rem; }
.employee-list .table-wrap { max-height: calc(100vh - 285px); }

.report-toolbar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; padding: 16px 20px; margin-bottom: 18px; }
.report-toolbar label { display: grid; gap: 5px; color: var(--muted); font-size: .76rem; font-weight: 750; }
.report-toolbar input { min-width: 160px; }
.report-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 18px; margin-top: 18px; align-items: start; }
.report-detail-wrap { max-height: 560px; }
.justification-form { display: grid; gap: 8px; padding: 0 20px 22px; }
.justification-form .panel-heading { margin: 0 -20px 6px; }
.justification-form > label:not(.check-row) { color: #44596d; font-size: .8rem; font-weight: 750; margin-top: 6px; }
.justification-form > p { color: var(--muted); line-height: 1.45; }
.schedule-editor { display: grid; gap: 7px; margin: 12px -4px 0; padding: 15px; border: 1px solid var(--line); background: #f8fafb; }
.schedule-editor > p { margin: 0 0 5px; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.schedule-editor label, .schedule-editor summary { color: #44596d; font-size: .78rem; font-weight: 750; }
.schedule-editor details { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.schedule-editor details[open] { display: grid; }
.schedule-editor summary { cursor: pointer; margin-bottom: 8px; }
.schedule-times { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.schedule-times label { display: grid; gap: 4px; }
.weekday-picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 5px 0; border: 0; padding: 0; }
.weekday-picker legend { width: 100%; color: #44596d; font-size: .78rem; font-weight: 750; }
.weekday-picker label { display: inline-flex; align-items: center; gap: 3px; }
.user-layout { display: grid; grid-template-columns: 370px minmax(0, 1fr); gap: 18px; align-items: start; }
.user-form { display: grid; gap: 7px; padding: 0 20px 22px; }
.user-form .panel-heading { margin: 0 -20px 10px; }
.user-form > label { color: #44596d; font-size: .8rem; font-weight: 750; margin-top: 6px; }
.user-form label span { color: #8a98a7; font-weight: 500; }
.user-actions { margin-top: 13px; }
.user-content { min-width: 0; display: grid; gap: 18px; }
.role-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.role-cards article { min-height: 104px; display: grid; align-content: center; gap: 7px; padding: 17px; border: 1px solid var(--line); border-top: 3px solid var(--teal-600); background: #fff; box-shadow: var(--shadow); }
.role-cards strong { color: var(--ink); }
.role-cards span { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.user-list .table-wrap { max-height: calc(100vh - 390px); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 1050px; }
.settings-card { display: grid; grid-template-columns: auto 1fr; gap: 16px; padding: 24px; }
.settings-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--teal-600); font-size: 1.35rem; }
.settings-card h2 { margin: 5px 0 8px; }
.settings-card p { color: var(--muted); line-height: 1.55; }
.settings-card dl { margin: 18px 0; }
.settings-card dl div { display: grid; grid-template-columns: 90px minmax(0,1fr); gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.settings-card dt { color: var(--muted); }
.settings-card dd { margin: 0; overflow-wrap: anywhere; font-weight: 700; }

.statusbar { min-height: 34px; display: flex; align-items: center; gap: 8px; background: #fff; border-top: 1px solid var(--line); color: var(--muted); padding: 7px 34px; font-size: .77rem; }
.sidebar-overlay { display: none; }
.toast { position: fixed; right: 24px; bottom: 54px; z-index: 60; max-width: 410px; padding: 13px 16px; border-radius: 6px; color: #fff; background: var(--navy-800); box-shadow: 0 15px 35px rgba(0,0,0,.2); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast.is-error { background: #a63441; }
.toast.is-success { background: #087b5d; }

.biosync-login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 14% 20%, rgba(22,184,174,.22), transparent 30%), linear-gradient(125deg, var(--navy-950) 0 50%, #eef4f5 50%); }
.login-shell { width: min(1000px, 100%); display: grid; grid-template-columns: 1.15fr .85fr; background: #fff; box-shadow: 0 28px 70px rgba(0,16,26,.28); }
.login-brand { min-height: 570px; display: flex; flex-direction: column; justify-content: space-between; padding: 54px; color: #fff; background: linear-gradient(155deg, rgba(4,27,40,.92), rgba(6,35,50,.98)); }
.login-brand img { width: 230px; max-height: 90px; object-fit: contain; object-position: left center; filter: brightness(0) invert(1); }
.login-brand h1 { margin: 10px 0; font-size: clamp(3rem, 7vw, 5.2rem); line-height: .95; letter-spacing: -.06em; }
.login-brand p { max-width: 470px; margin: 0; color: #b8d0d6; font-size: 1.1rem; line-height: 1.65; }
.login-card { display: flex; flex-direction: column; justify-content: center; padding: 52px 44px; }
.login-card-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 26px; }
.login-card-heading h2 { margin: 0 0 4px; font-size: 1.7rem; }
.login-card-heading p { margin: 0; color: var(--muted); }
.login-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--teal-600); font-size: 1.4rem; font-weight: 900; }
.login-form { display: grid; gap: 8px; }
.login-help { margin: 24px 0 0; color: #8796a4; font-size: .78rem; line-height: 1.5; text-align: center; }
.alert { margin-bottom: 16px; border-radius: 5px; padding: 11px 13px; font-size: .84rem; }
.alert-error { color: #8d2d38; background: #fdecef; border: 1px solid #f3c7ce; }

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

@media (max-width: 840px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 272px; transition: transform .2s ease; box-shadow: 16px 0 40px rgba(0,0,0,.25); }
    .app-shell.menu-open .sidebar { transform: translateX(0); }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 25; border: 0; background: rgba(2,16,25,.55); }
    .app-shell.menu-open .sidebar-overlay { display: block; }
    .menu-toggle { display: block; }
    .topbar { min-height: 86px; padding: 17px 20px; }
    .connection-chip { display: none; }
    .content { padding: 20px; }
    .employee-layout, .user-layout, .settings-grid, .report-layout { grid-template-columns: 1fr; }
    .employee-list .table-wrap { max-height: none; }
    .user-list .table-wrap { max-height: none; }
    .employee-heading { align-items: stretch; flex-direction: column; }
    .search-box { width: 100%; }
    .statusbar { padding-inline: 20px; }
    .login-shell { grid-template-columns: 1fr; max-width: 500px; }
    .login-brand { min-height: auto; padding: 32px; gap: 55px; }
    .login-brand h1 { font-size: 3.3rem; }
    .login-card { padding: 38px 32px; }
}

@media (max-width: 560px) {
    .metrics-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .metric-card { min-height: 119px; padding: 17px; }
    .metric-card strong { font-size: 1.45rem; }
    .metric-card small { display: none; }
    .file-summary { grid-template-columns: 1fr 1fr; }
    .file-summary div:first-child { grid-column: 1 / -1; border-bottom: 1px solid var(--line); }
    .file-summary div:nth-child(2) { border-right: 1px solid var(--line); }
    .import-toolbar .button { flex: 1 1 auto; }
    .report-toolbar > * { flex: 1 1 140px; }
    .report-toolbar .button { align-self: stretch; }
    .search-box { flex-direction: column; }
    .role-cards { grid-template-columns: 1fr; }
    .settings-card { grid-template-columns: 1fr; }
    .topbar p { font-size: .82rem; }
    .content { padding: 14px; }
    .login-brand { display: none; }
    .biosync-login-page { background: var(--navy-900); padding: 14px; }
    .login-card { padding: 34px 24px; }
}
