:root {
    --kdi-red: #8b1321;
    --kdi-red-2: #d8202f;
    --ink: #17171c;
    --muted: #6f7280;
    --line: #e8e2e4;
    --bg: #f7f3f4;
    --panel: #ffffff;
    --good: #117a48;
    --warn: #9d6800;
    --bad: #b4202a;
    --soft-red: #fff1f3;
    --shadow: 0 20px 55px rgba(61, 9, 19, .10);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
    width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff;
}
input[type="checkbox"] { width: auto; }
textarea { min-height: 88px; resize: vertical; }
label { display: grid; gap: 6px; color: #3d3d45; font-size: 13px; font-weight: 650; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #57525b; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #fbf8f9; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(28px, 3vw, 44px); line-height: 1.05; }
h2 { font-size: 19px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.eyebrow { color: var(--kdi-red); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; margin: 0 0 8px; }
.btn {
    border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 10px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 750; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(35, 12, 17, .08); }
.btn.primary { background: linear-gradient(135deg, var(--kdi-red), var(--kdi-red-2)); color: #fff; border-color: transparent; }
.btn.dark { background: #25212a; color: #fff; border-color: #25212a; }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.btn.small { padding: 7px 10px; font-size: 12px; }
.nav-toggle-check { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.menu-toggle { display: none; }
.alert { padding: 12px 14px; border-radius: 8px; margin: 0 0 16px; border: 1px solid var(--line); background: #fff; }
.alert.success { border-color: #bfe6d0; color: var(--good); background: #effaf4; }
.alert.warning { border-color: #f2d79a; color: var(--warn); background: #fff8e8; }
.alert.danger { border-color: #f0b8bd; color: var(--bad); background: #fff0f1; }
.badge { display: inline-flex; border-radius: 999px; padding: 4px 9px; background: #f2e6e8; color: var(--kdi-red); font-weight: 800; font-size: 12px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.mobile-scrim { display: none; }
.sidebar { background: linear-gradient(180deg, #1b171d 0%, #351019 100%); color: #fff; padding: 22px; position: sticky; top: 0; height: 100vh; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 900; font-size: 20px; }
.brand img { width: 54px; height: 54px; object-fit: contain; background: #fff; border-radius: 8px; padding: 5px; }
.sidebar-close { display: none; color: #fff; border-color: rgba(255,255,255,.18); cursor: pointer; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { padding: 12px; border-radius: 8px; color: #e9dfe1; font-weight: 700; border: 1px solid transparent; }
.sidebar nav a.active, .sidebar nav a:hover { background: var(--kdi-red); color: #fff; }
.main { min-width: 0; padding: 22px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; background: rgba(255,255,255,.78); border: 1px solid var(--line); border-radius: 8px; padding: 12px; box-shadow: 0 12px 35px rgba(61,9,19,.06); backdrop-filter: blur(14px); }
.topbar div:first-child { display: grid; gap: 3px; }
.topbar span { color: var(--muted); font-size: 13px; }
.topbar-brand { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 12px; min-width: 0; }
.topbar-brand img { width: 48px; height: 48px; object-fit: contain; background: #fff; border-radius: 8px; padding: 5px; border: 1px solid var(--line); }
.topbar-brand > div { min-width: 0; display: grid; gap: 3px; }
.top-actions, .action-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hero-panel, .panel, .metric {
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.hero-panel { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 20px; padding: 32px; overflow: hidden; margin-bottom: 18px; }
.hero-panel p:last-child { max-width: 780px; color: var(--muted); font-size: 17px; }
.hero-panel img { width: 220px; align-self: center; justify-self: end; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { padding: 18px; display: grid; gap: 8px; min-height: 112px; }
.metric span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { font-size: 30px; color: var(--kdi-red); }
.employee-announcements { margin-bottom: 16px; }
.section-head.compact { align-items: center; }
.announcement-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.announcement-strip.employee { margin-bottom: 0; }
.announcement-mini { background: linear-gradient(135deg, #fff, var(--soft-red)); border: 1px solid #efd5d9; border-left: 4px solid var(--kdi-red); border-radius: 8px; padding: 14px; display: grid; gap: 5px; min-height: 82px; }
.announcement-mini span { color: var(--muted); font-size: 12px; font-weight: 800; }
.announcement-list { display: grid; gap: 14px; }
.announcement-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: 0 16px 40px rgba(45, 10, 18, .05); }
.announcement-card > div { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.announcement-card p { color: #3f3a42; line-height: 1.6; }
.employee-home { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); gap: 16px; margin-bottom: 16px; }
.employee-card, .attendance-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 22px; box-shadow: var(--shadow); }
.employee-card { background: linear-gradient(135deg, #fff 0%, #fff6f7 55%, #f7e4e7 100%); }
.employee-card h1 { font-size: clamp(30px, 4vw, 48px); }
.employee-card p:not(.eyebrow) { color: var(--muted); font-weight: 650; }
.employee-identity { display: flex; gap: 16px; align-items: center; }
.avatar { object-fit: cover; border-radius: 8px; border: 2px solid #fff; box-shadow: 0 12px 28px rgba(61, 9, 19, .14); background: #fff; }
.avatar.xl { width: 96px; height: 96px; }
.avatar.sm { width: 46px; height: 46px; }
.photo-upload { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; margin-top: 16px; padding: 12px; border: 1px solid #efd5d9; border-radius: 8px; background: rgba(255,255,255,.78); }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.employee-metrics .metric { color: inherit; }
.panel { padding: 18px; margin-bottom: 18px; }
.section-head, .page-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.page-title { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 22px; }
.page-title p { margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid h2, .form-grid .full, .form-grid .wide { grid-column: 1 / -1; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff8f9; }
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 18px; align-items: start; }
.attendance-grid { display: grid; grid-template-columns: minmax(320px, .9fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.camera-panel { display: grid; gap: 14px; }
video { width: 100%; min-height: 320px; background: #17171c; border-radius: 8px; object-fit: cover; }
.camera-panel video { transform: scaleX(-1); }
.camera-status { border: 1px dashed #d9c4c8; color: var(--muted); padding: 12px; border-radius: 8px; background: #fff8f9; }
.status-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.status-list div { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; gap: 5px; }
.status-list span { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
.filter-bar { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 12px; align-items: end; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; min-width: 360px; }
.inline-form input { width: 130px; }
.row-actions { display: flex; gap: 7px; flex-wrap: wrap; min-width: 260px; }
.row-actions form { margin: 0; }
.employee-checklist { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; display: grid; gap: 12px; }
.checklist-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 280px; overflow-y: auto; }
.login-body, .install-body {
    min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
        radial-gradient(circle at 15% 10%, rgba(216, 32, 47, .18), transparent 30%),
        linear-gradient(135deg, #1b171d, #6f0f1a 65%, #220b10);
}
.login-shell { width: min(980px, 100%); display: grid; grid-template-columns: 1fr 420px; gap: 22px; align-items: center; }
.login-brand { color: #fff; padding: 30px; }
.login-brand img { width: 180px; background: #fff; border-radius: 8px; padding: 12px; margin-bottom: 20px; }
.login-brand p { color: #f4dfe3; font-size: 18px; line-height: 1.6; max-width: 560px; }
.login-card, .install-card { background: #fff; border-radius: 8px; padding: 26px; box-shadow: 0 24px 70px rgba(0,0,0,.22); display: grid; gap: 16px; }
.install-card { width: min(620px, 100%); }
.install-logo { width: 150px; justify-self: center; }
@media (max-width: 920px) {
    .app-shell { grid-template-columns: 1fr; }
    .menu-toggle { display: inline-flex; }
    label.menu-toggle { cursor: pointer; user-select: none; position: relative; z-index: 12; }
    .mobile-scrim { display: block; position: fixed; inset: 0; background: rgba(10, 8, 12, .45); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 20; }
    .sidebar { position: fixed; z-index: 21; left: 0; top: 0; bottom: 0; width: min(320px, 86vw); height: 100vh; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 20px 0 60px rgba(0,0,0,.28); }
    .sidebar-close { display: inline-flex; }
    .sidebar nav { grid-template-columns: 1fr; max-height: calc(100vh - 110px); overflow-y: auto; }
    #navToggle:checked ~ .app-shell .sidebar { transform: translateX(0); }
    #navToggle:checked ~ .mobile-scrim { opacity: 1; pointer-events: auto; }
    body.menu-open .sidebar { transform: translateX(0); }
    body.menu-open .mobile-scrim { opacity: 1; pointer-events: auto; }
    .hero-panel, .split, .attendance-grid, .employee-home, .login-shell { grid-template-columns: 1fr; }
    .hero-panel img { justify-self: start; width: 160px; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .announcement-strip { grid-template-columns: 1fr; }
    .filter-bar { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .main { padding: 12px; }
    .topbar { position: sticky; top: 0; z-index: 10; margin: -12px -12px 14px; padding: 10px 12px; border-radius: 0; border-left: 0; border-right: 0; align-items: center; }
    .topbar-brand img { width: 42px; height: 42px; }
    .topbar > div:first-of-type, .topbar-brand { min-width: 0; }
    .topbar strong, .topbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .top-actions { margin-left: auto; }
    .top-actions .btn[href*="logout"] { padding: 8px 10px; font-size: 12px; }
    .section-head, .page-title { flex-direction: column; }
    .sidebar nav { grid-template-columns: 1fr; }
    .hero-panel { padding: 18px; gap: 8px; }
    .hero-panel h1 { font-size: 26px; line-height: 1.12; }
    .hero-panel p:last-child { font-size: 14px; margin-bottom: 0; }
    .hero-panel img { display: none; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .metric { padding: 13px; }
    .metric strong { font-size: 22px; }
    .employee-card, .attendance-card { padding: 16px; }
    .employee-identity { align-items: flex-start; }
    .avatar.xl { width: 74px; height: 74px; }
    .photo-upload { grid-template-columns: 1fr; }
    .employee-card h1 { font-size: 30px; }
    .quick-actions .btn { width: 100%; }
    .panel, .page-title { padding: 14px; }
    .form-grid, .status-list, .check-grid { grid-template-columns: 1fr; }
    .table-wrap table { min-width: 720px; }
    .page-title h1 { font-size: 26px; }
    video { min-height: 240px; }
}
