:root {
    --red: #d8232a;
    --red-dark: #b71c22;
    --purple: #7b61ff;
    --purple-dark: #6a50e8;
    --text: #2e353b;
    --text-muted: #70777d;
    --border: #e8eaed;
    --bg: #f4f5f7;
    --sidebar-active: #e7eef9;
    --sidebar-active-text: #1a73e8;
    --green: #1f9d61;
    --yellow: #f5a623;
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a { color: var(--sidebar-active-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Topbar ===== */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 170px;
}

.brand-mark {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

.brand-name {
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.topbar .module {
    font-weight: 600;
    font-size: 15px;
    border-left: 1px solid var(--border);
    padding-left: 16px;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 18px;
}

.icon-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
}

.icon-btn .badge {
    position: absolute;
    top: -6px; right: -8px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    border-radius: 999px;
    padding: 1px 5px;
    font-weight: 700;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--purple);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }

.user-chip .u-name { font-weight: 700; font-size: 13px; line-height: 1.2; }
.user-chip .u-company { font-size: 11px; color: var(--text-muted); }

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 60px; left: 0; bottom: 0;
    width: 220px;
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 14px 10px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text);
    font-size: 13.5px;
    margin-bottom: 2px;
}

.nav-item:hover { background: #f1f3f4; text-decoration: none; }

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-text);
    font-weight: 600;
}

.nav-item .nav-ic { width: 18px; text-align: center; }

.nav-sep { border-top: 1px solid var(--border); margin: 12px 6px; }

/* ===== Layout ===== */
.main {
    margin-left: 220px;
    margin-top: 60px;
    padding: 24px;
    min-height: calc(100vh - 60px);
}

.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--text-muted); margin-bottom: 20px; }

/* ===== Cards ===== */
.card {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}

.card h3 {
    font-size: 15px;
    margin-bottom: 14px;
}

/* ===== Dashboard ===== */
.hero {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    overflow: hidden;
}

.hero h1 { font-size: 24px; margin-bottom: 6px; }
.hero .date { color: var(--text-muted); margin-bottom: 20px; }

.hero-illustration { font-size: 64px; opacity: .9; }

.shortcut-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.shortcuts { display: flex; gap: 12px; flex-wrap: wrap; }

.btn-pill {
    display: inline-block;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 9px 20px;
    font-size: 13.5px;
    color: var(--text);
    cursor: pointer;
    font-weight: 500;
}

.btn-pill:hover { border-color: var(--text-muted); text-decoration: none; }

.dash-grid {
    display: grid;
    grid-template-columns: 240px 1fr 290px;
    gap: 20px;
    align-items: start;
}

.quick-links a, .app-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    color: var(--text);
    font-size: 13.5px;
}

.quick-links a:hover, .app-links a:hover { color: var(--sidebar-active-text); text-decoration: none; }

.banner {
    background: linear-gradient(100deg, var(--purple), var(--purple-dark));
    border-radius: var(--radius);
    color: #fff;
    padding: 24px 28px;
    margin-bottom: 20px;
}

.banner b { display: block; font-size: 15px; margin-bottom: 8px; }
.banner a { color: #fff; font-weight: 600; }

.balance-value { font-size: 22px; font-weight: 700; margin: 6px 0; }

.tag-new {
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    padding: 1px 6px;
    margin-left: 6px;
}

/* ===== Tabs ===== */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }

.tab {
    padding: 10px 2px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
}

.tab.active { color: var(--text); border-bottom-color: var(--red); }
.tab:hover { text-decoration: none; }

/* ===== Announcement list ===== */
.ann-item {
    display: flex;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.ann-item:last-child { border-bottom: none; }
.ann-meta { font-size: 12px; color: var(--text-muted); }
.ann-title { font-weight: 600; }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; }

.table th, .table td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

.table th {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    background: #fafbfc;
}

.table tr:hover td { background: #fafbfc; }

/* ===== Badges & status ===== */
.status {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
}

.status.pending { background: #fff4e0; color: #b57908; }
.status.approved, .status.hadir { background: #e3f6ec; color: var(--green); }
.status.rejected, .status.alpha { background: #fdeaea; color: var(--red); }
.status.terlambat { background: #fff4e0; color: #b57908; }
.status.izin, .status.sakit { background: #e8eefc; color: #3b5bdb; }

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover { text-decoration: none; opacity: .92; }
.btn-primary { background: var(--red); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }

.form-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }

.form-control {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}

.form-control:focus { outline: none; border-color: var(--purple); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }

.form-error { color: var(--red); font-size: 12.5px; margin-top: 4px; }

/* ===== Alerts ===== */
.alert { border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; font-size: 13.5px; }
.alert-success { background: #e3f6ec; color: var(--green); }
.alert-error { background: #fdeaea; color: var(--red); }

/* ===== Login page ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: #fff;
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 36px;
    width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,.06);
}

.login-card .brand { justify-content: center; margin-bottom: 8px; }
.login-card h1 { font-size: 19px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 13px; }

/* ===== Misc ===== */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; }
.w-100 { width: 100%; }

.profile-head { display: flex; gap: 20px; align-items: center; margin-bottom: 20px; }

.detail-grid { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; font-size: 14px; }
.detail-grid dt { color: var(--text-muted); }
.detail-grid dd { font-weight: 500; }

.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
}
.pagination .active span { background: var(--red); color: #fff; border-color: var(--red); }
.pagination span[aria-disabled] { color: #c3c7cb; }
.pagination svg { width: 14px; height: 14px; }

.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
}

@media (max-width: 1100px) {
    .dash-grid { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main { margin-left: 0; }
}

.mobile-nav { display: none; }

.mobile-attendance { max-width: 640px; margin: 0 auto; }
.mobile-attendance .page-sub { margin-bottom: 14px; }
.shift-card { border-top: 4px solid var(--red); }
.shift-card strong { display: block; font-size: 19px; margin: 8px 0 4px; }
.attendance-step h2 { font-size: 18px; margin: 8px 0; }
.attendance-step > .muted { margin-bottom: 16px; }
.step-count { color: var(--red); font-size: 12px; font-weight: 700; letter-spacing: .8px; }
.location-result {
    padding: 14px;
    margin-bottom: 14px;
    border-radius: 8px;
    background: #f4f5f7;
    color: var(--text-muted);
    line-height: 1.5;
}
.location-result.is-valid { background: #e3f6ec; color: var(--green); }
.location-result.is-invalid { background: #fdeaea; color: var(--red); }
.camera-frame {
    position: relative;
    min-height: 260px;
    overflow: hidden;
    border-radius: 10px;
    background: #242a31;
    display: flex;
    align-items: center;
    justify-content: center;
}
.camera-frame video, .camera-frame img {
    width: 100%;
    max-height: 480px;
    object-fit: cover;
}
.camera-frame video { transform: scaleX(-1); }
.camera-frame #camera-placeholder { color: #fff; padding: 24px; text-align: center; }
.camera-actions { display: flex; gap: 10px; margin-top: 12px; }
.camera-actions .btn { flex: 1; }
.table-scroll { overflow-x: auto; }

@media (max-width: 700px) {
    body { font-size: 14px; }
    .topbar { height: 56px; padding: 0 12px; gap: 8px; }
    .brand { min-width: 0; }
    .brand-mark { width: 30px; height: 30px; font-size: 11px; }
    .brand-name, .topbar .module, .user-chip .u-company, .topbar-right form { display: none; }
    .topbar-right { gap: 12px; }
    .user-chip .u-name { display: none; }
    .avatar { width: 32px; height: 32px; }
    .sidebar { display: none; }
    .main { margin: 56px 0 0; padding: 16px 12px 88px; min-height: calc(100vh - 56px); }
    .page-title { font-size: 19px; }
    .hero { padding: 20px 16px; align-items: flex-start; }
    .hero h1 { font-size: 21px; }
    .hero-illustration { display: none; }
    .shortcuts { gap: 8px; }
    .btn-pill { padding: 8px 12px; font-size: 12px; }
    .dash-grid { grid-template-columns: 1fr; gap: 0; }
    .card { padding: 16px; margin-bottom: 14px; }
    .form-grid { grid-template-columns: 1fr; gap: 0; }
    .detail-grid { grid-template-columns: 130px 1fr; }
    .flex-between { gap: 10px; }
    .table { min-width: 720px; }
    .mobile-nav {
        position: fixed;
        z-index: 120;
        bottom: 0;
        left: 0;
        right: 0;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
        background: #fff;
        border-top: 1px solid var(--border);
    }
    .mobile-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        color: var(--text-muted);
        font-size: 11px;
    }
    .mobile-nav a span { font-size: 22px; line-height: 1; }
    .mobile-nav a.active { color: var(--sidebar-active-text); font-weight: 600; }
}
