:root {
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --line: #e2e8f0;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #64748b;
    --accent: #0284c7;
    --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

body:has(.login) {
    overflow: auto;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.muted {
    color: var(--text-muted);
}

/* APP LAYOUT */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* SIDEBAR NAV */
.sidebar {
    width: 205px;
    height: 100vh;
    background: #1e293b;
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 12px 0;
    border-right: 1px solid #334155;
    overflow-y: auto;
    position: sticky;
    top: 0;
}

.sidebar .brand {
    padding: 0 14px 12px;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #fff;
    border-bottom: 1px solid #334155;
}

.sidebar .brand small {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: #94a3b8;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.sidebar .nav-group {
    padding: 10px 8px 2px;
}

.sidebar .nav-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    margin-bottom: 4px;
    padding-left: 6px;
}

.sidebar .nav-item {
    display: flex;
    align-items: center;
    padding: 6px 9px;
    border-radius: 5px;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s ease;
    margin-bottom: 2px;
    text-decoration: none;
}

.sidebar .nav-item:hover {
    background: #334155;
    color: #fff;
    text-decoration: none;
}

.sidebar .nav-item.active {
    background: #4f46e5;
    color: #fff;
    font-weight: 600;
}

.sidebar .nav-bottom {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #334155;
}

/* MAIN AREA */
.main {
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.topbar {
    height: 50px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.topbar .sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

.topbar .user {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 16px;
    border: 1px solid var(--line);
}

.content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 12px 16px;
}

/* LOGIN CARD */
.login.card {
    max-width: 380px;
    margin: 60px auto;
    padding: 24px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--line);
}

.login h2 {
    margin: 0 0 4px;
    font-size: 20px;
    text-align: center;
}

.login p.muted {
    margin: 0 0 18px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* CARDS & PANELS */
.panel, .card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    overflow: visible;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.panel-head h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.panel-head span {
    font-size: 11px;
    color: var(--text-muted);
}

/* METRICS GRID */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.metric {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 11px;
    text-align: left;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.metric:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.04);
}

.metric .label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.metric .value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    margin: 2px 0;
}

.metric .hint {
    font-size: 10px;
    color: var(--text-muted);
}

/* GRID LAYOUTS & FORMS */
.grid2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.form-row > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.btn-group, .form-row > div.btn-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

label {
    font-size: 11px;
    font-weight: 600;
    color: #475569;
}

input, select, textarea {
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    font-size: 12px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.2;
}

.btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn.secondary {
    background: #475569;
    color: #fff;
    border-color: #334155;
}

.btn.secondary:hover {
    background: #334155;
}

.btn.small {
    padding: 4px 7px;
    font-size: 11px;
}

.toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

/* TABLES & LISTS */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    text-align: left;
}

th, td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
}

th {
    background: #fafbfc;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

tbody tr:hover {
    background: #f8fafc;
}

.empty, .empty-block {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 12px;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item small {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
}

/* ATTENDANCE MATRIX & STICKY COLUMNS */
.card.scroll {
    max-height: calc(100vh - 170px);
    overflow: auto;
}

.attendance th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fafbfc;
    box-shadow: 0 1px 0 var(--line);
}

.attendance td:nth-child(1), .attendance th:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 5;
    background: #fff;
}

.attendance td:nth-child(2), .attendance th:nth-child(2) {
    position: sticky;
    left: 75px;
    z-index: 5;
    background: #fff;
}

.attendance td:nth-child(3), .attendance th:nth-child(3) {
    position: sticky;
    left: 205px;
    z-index: 5;
    background: #fff;
}

.attendance td:nth-child(4), .attendance th:nth-child(4) {
    position: sticky;
    left: 280px;
    z-index: 5;
    background: #fff;
    box-shadow: 2px 0 4px rgba(0,0,0,.04);
}

.attendance th:nth-child(-n+4) {
    z-index: 15;
    background: #fafbfc;
}

/* BADGES & CODES */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge.green {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.badge.amber {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}

.badge.red {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.badge.purple {
    background: #f3e8ff;
    color: #6b21a8;
    border: 1px solid #e9d5ff;
}

.badge.blue {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.badge.shift-day {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
}

.badge.shift-night {
    background: #f3e8ff;
    color: #6b21a8;
    border: 1px solid #e9d5ff;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
}

.code-P { background: #e6f4ea; color: #137333; font-weight: 700; text-align: center; }
.code-OFF, .code-WO, .code-LO { background: #f1f3f4; color: #5f6368; font-weight: 600; text-align: center; }
.code-SL, .code-RC { background: #fef7e0; color: #b06000; font-weight: 700; text-align: center; }
.code-V { background: #e8eaed; color: #3c4043; font-weight: 600; text-align: center; }
.code-A, .code-C { background: #fce8e6; color: #c5221f; font-weight: 700; text-align: center; }

/* ALERTS & MODALS */
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 14px;
    font-weight: 500;
}

.alert.ok { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert.err { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert.warn { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }

/* LIVE SEARCH DROPDOWNS */
.searchable-select {
    position: relative;
    width: 100%;
}

.searchable-input {
    width: 100%;
    padding: 7px 24px 7px 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fff;
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
}

.searchable-select::after {
    content: "▾";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 10px;
}

.searchable-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0,0,0,.18);
    z-index: 99999;
    max-height: 280px !important;
    overflow-y: auto !important;
    display: none;
}

.searchable-option {
    padding: 8px 11px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.searchable-option:last-child {
    border-bottom: none;
}

.searchable-option:hover, .searchable-option.selected {
    background: #eef2ff;
    color: #4f46e5;
    font-weight: 600;
}

.searchable-option.no-match {
    color: var(--text-muted);
    cursor: default;
    font-style: italic;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.55);
    backdrop-filter: blur(3px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,.25);
    width: 100%;
    max-width: 520px;
    padding: 14px;
    position: relative;
    z-index: 3001;
    animation: modalIn .2s ease-out;
}

.modal-card.assign-deployment-modal {
    max-width: 650px;
    padding: 16px;
}

/* GROUPED GRID LAYOUTS */
.assign-deployment-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
}

.assign-deployment-grid .project-field {
    grid-column: 1 / -1;
}

.assign-deployment-grid .shift-field {
    grid-column: 1;
}

.assign-deployment-grid .date-field {
    grid-column: 2;
}

.assign-deployment-grid .remark-field {
    grid-column: 1 / -1;
}

/* DEPLOYMENT FORM GRID */
.deployment-form-grid {
    display: grid;
    grid-template-columns: 320px 130px 150px 1fr auto;
    gap: 10px 12px;
    align-items: end;
}

.deployment-form-grid .field-employee {
    grid-column: 1;
}

.deployment-form-grid .field-project {
    grid-column: 2 / -1;
}

.deployment-form-grid .field-shift {
    grid-column: 1;
}

.deployment-form-grid .field-date {
    grid-column: 2;
}

.deployment-form-grid .field-remark {
    grid-column: 3 / 5;
}

.deployment-form-grid .field-btn {
    grid-column: 5;
    justify-self: end;
}

/* MONTHLY FILTER GRID */
.monthly-filter-grid {
    display: grid;
    grid-template-columns: 145px 175px 140px 1fr;
    gap: 10px 12px;
    align-items: end;
}

.monthly-filter-grid .filter-month {
    grid-column: 1;
}

.monthly-filter-grid .filter-view {
    grid-column: 2;
}

.monthly-filter-grid .filter-shift {
    grid-column: 3;
}

.monthly-filter-grid .filter-project {
    grid-column: 1 / -1;
}

.monthly-filter-grid .filter-actions {
    grid-column: 1 / -1;
    justify-self: end;
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 2px;
}

/* EMAIL SETTINGS SECTION & WRAPPER */
.email-settings-wrap {
    max-width: 980px;
}

.email-section {
    margin-bottom: 12px;
}

.email-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #475569;
    margin: 12px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #f1f5f9;
}

.email-grid-3 {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 120px 150px;
    gap: 8px 12px;
}

.email-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(300px, 1fr));
    gap: 8px 12px;
}

.email-grid-2 input,
.email-grid-3 input,
.email-grid-3 select {
    width: 100%;
}

.test-email-row {
    display: grid;
    grid-template-columns: minmax(300px, 420px) auto;
    gap: 10px;
    align-items: end;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.modal-head.indigo {
    background: #4f46e5;
    color: #fff;
    padding: 10px 12px;
    border-radius: 6px 6px 0 0;
    margin: -12px -12px 10px -12px;
    border-bottom: none;
}

.modal-head.indigo h3 {
    color: #fff;
    font-size: 14px;
}

.modal-head.indigo .modal-close {
    color: #fff;
}

.modal-head h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.email-summary {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 8px 10px;
    border-radius: 5px;
    margin-bottom: 8px;
    font-size: 11px;
}

.email-summary div {
    margin-bottom: 2px;
}

.email-attachment {
    background: #eff6ff;
    border: 1px dashed #93c5fd;
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 11px;
    color: #1e40af;
}

/* PROCESSING OVERLAY & SPINNER */
.processing-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.processing-box {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px 26px;
    min-width: 280px;
    text-align: center;
    box-shadow: 0 12px 30px rgba(0,0,0,.22);
}

.processing-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto 12px;
    border: 4px solid #e2e8f0;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: processingSpin .8s linear infinite;
}

.processing-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.processing-text {
    margin-top: 4px;
    font-size: 12px;
    color: #64748b;
}

@keyframes processingSpin {
    to {
        transform: rotate(360deg);
    }
}

/* FULL SCREEN LOGIN PAGE LAYOUT */
body:has(.login-page) {
    overflow: hidden;
}

.login-page {
    min-height: 100vh;
    width: 100%;
    position: relative;

    display: flex;
    align-items: center;
    justify-content: center;

    background:
        linear-gradient(
            rgba(8, 20, 48, 0.28),
            rgba(8, 20, 48, 0.42)
        ),
        url("assets/login-background.jpg") center center / cover no-repeat;

    overflow: hidden;
}

.login-brand {
    position: absolute;
    top: 28px;
    left: 38px;
}

.login-brand img {
    width: 220px;
    max-height: 70px;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}

.login-card {
    width: min(420px, calc(100vw - 32px));

    padding: 30px 34px 26px;

    background: rgba(255, 255, 255, 0.94);

    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);

    border: 1px solid rgba(255,255,255,.6);

    border-radius: 18px;

    box-shadow:
        0 25px 70px rgba(5, 15, 40, .30);

    position: relative;
    z-index: 2;
}

.login-card-logo {
    display: block;
    width: 220px;
    max-width: 80%;
    margin: 0 auto 16px;
    object-fit: contain;
}

.login-card h1 {
    margin: 0;
    text-align: center;

    font-size: 20px;
    font-weight: 700;

    color: #0f172a;
}

.login-subtitle {
    margin: 5px 0 24px;

    text-align: center;

    font-size: 13px;
    color: #64748b;
}

.login-form {
    display: grid;
    gap: 15px;
}

.login-field {
    display: grid;
    gap: 5px;
}

.login-field label {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
}

.login-field input {
    width: 100%;

    height: 44px;
    padding: 0 13px;

    border: 1px solid #cbd5e1;
    border-radius: 8px;

    background: #fff;

    font-size: 13px;
}

.login-field input:focus {
    outline: none;
    border-color: #4f46e5;

    box-shadow:
        0 0 0 3px rgba(79,70,229,.10);
}

.password-wrap {
    position: relative;
}

.password-wrap input {
    padding-right: 60px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;

    transform: translateY(-50%);

    background: none;
    border: none;

    color: #64748b;

    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.password-toggle:hover {
    color: #4f46e5;
    background: rgba(79, 70, 229, 0.05);
}

.login-button {
    height: 46px;
    margin-top: 5px;

    border: 0;
    border-radius: 8px;

    background:
        linear-gradient(135deg, #6347f5, #3730a3);

    color: #fff;

    font-size: 14px;
    font-weight: 700;

    cursor: pointer;

    box-shadow:
        0 8px 20px rgba(79,70,229,.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.login-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(79,70,229,.35);
}

.login-security {
    margin-top: 20px;
    padding-top: 14px;

    border-top: 1px solid #e2e8f0;

    text-align: center;

    font-size: 11px;
    color: #64748b;
}

.login-footer {
    position: absolute;
    bottom: 18px;

    color: rgba(255,255,255,.75);

    font-size: 10px;
    letter-spacing: 1.5px;
    font-weight: 600;
}






