:root {
    --bg: #FFFFFF;
    --surface: #FFFFFF;
    --surface-2: #e8f2f2;
    --text: #1e293b;
    --muted: #5a6c6c;
    --accent: #088395;
    --accent-dark: #09637E;
    --accent-light: #7AB2B2;
    --accent-hover: #09637E;
    --success: #0d9488;
    --danger: #dc2626;
    --border: #dde8e8;
    --border-focus: #7AB2B2;
}

* {
    box-sizing: border-box;
}

.w-full {
    width: 100% !important;
}

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.layout-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.sidebar {
    width: 280px;
    background: var(--surface);
    padding: 1.25rem;
    border-right: 1px solid var(--border);
    box-shadow: 1px 0 0 0 var(--border);
}

.content {
    flex: 1;
    padding: 1.5rem;
    background: var(--bg);
}

/* Footer: always at bottom of viewport; well-designed ERP-style */
.app-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 1rem 0;
    font-size: 0.8125rem;
    color: var(--muted);
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.app-footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.app-footer a {
    color: var(--accent);
    font-weight: 500;
}

.app-footer a:hover {
    text-decoration: underline;
}

.app-footer-left {
    margin: 0;
}

.app-footer-right {
    margin: 0;
}

.app-footer-guest {
    align-self: stretch;
}

.app-footer-guest .app-footer-inner {
    max-width: none;
    padding-left: 1rem;
    padding-right: 1rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    color: var(--text);
}

.topbar h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.topbar-tz {
    margin: 0;
    font-size: 0.75rem;
}

.brand {
    display: flex;
    gap: 0.4rem;
    align-items: flex-start;
    margin-bottom: 1.75rem;
}

.brand-title {
    margin: 0;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.brand-subtitle {
    margin: 0.15rem 0 0;
    color: var(--accent);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.menu {
    display: grid;
    gap: 0.25rem;
}

.menu a {
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    transition: background 0.15s;
}

.menu a:hover {
    background: var(--surface-2);
    text-decoration: none;
}

.logout-form {
    margin-top: 1rem;
}

.logout-form button {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.logout-form button:hover {
    background: var(--surface-2);
}

.grid {
    display: grid;
    gap: 1rem;
}

.cards-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.metric {
    font-size: 1.75rem;
    margin: 0.35rem 0 0;
    color: var(--accent);
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--surface-2);
}

tr:last-child td {
    border-bottom: none;
}

form {
    display: grid;
    gap: 0.75rem;
}

label {
    display: grid;
    gap: 0.35rem;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
}

input,
select,
button {
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(8, 131, 149, 0.2);
}

/* Modern: no number input arrows (spinners) */
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

button {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

button:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    filter: none;
}

.alert {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

.attendance-notification {
    margin-top: 1rem;
}

.attendance-notification[hidden] {
    display: none;
}

.muted {
    color: var(--muted);
}

/* Guest / Login layout */
.guest-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--surface-2) 0%, #c9e4e7 100%);
}

.guest-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    align-items: center;
    margin: 0 auto;
}

.guest-wrapper {
    width: min(460px, 94vw);
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 0;
}

/* Logo block above card */
.login-page-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.login-logo-block {
    text-align: center;
    padding: 2rem 1.5rem 1.5rem;
}

.login-logo-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    margin: 0 auto 1rem;
    box-shadow: 0 4px 20px rgba(8, 131, 149, 0.35);
}

.auth-brand-title {
    margin: 0 0 0.35rem;
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.1;
}

.auth-brand-subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: var(--accent);
    letter-spacing: 0.06em;
    font-weight: 600;
    text-transform: uppercase;
}

/* Login card */
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 20px 20px;
    padding: 1.75rem 1.75rem 1.5rem;
    box-shadow: 0 8px 32px rgba(8, 131, 149, 0.10), 0 1px 4px rgba(0, 0, 0, 0.06);
    text-align: left;
}

.login-logo-block {
    border-radius: 20px 20px 0 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: none;
    box-shadow: 0 -2px 12px rgba(8, 131, 149, 0.06);
}

.login-card-heading {
    margin: 0 0 1.1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
}

.login-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.75rem;
    font-size: 1rem;
    border-radius: 10px;
    letter-spacing: 0.02em;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
}

/* Password field enhancements (Icon embedded inside) */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
}

.password-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(8, 131, 149, 0.2);
}

.password-input-wrapper input {
    flex: 1;
    width: 100%;
    border: none;
    box-shadow: none;
    padding: 0.6rem 0.75rem;
    padding-right: 48px;
    font-family: Verdana, sans-serif;
    letter-spacing: 0.15em;
    font-size: 1rem;
    background: transparent;
}

.password-input-wrapper input:focus {
    outline: none;
    box-shadow: none;
}

.password-input-wrapper input.showing-text {
    font-family: inherit;
    letter-spacing: normal;
}

.password-input-wrapper input::placeholder {
    font-family: system-ui, -apple-system, sans-serif;
    letter-spacing: normal;
}

.password-toggle-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    box-shadow: none;
}

.password-toggle-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    box-shadow: none;
}

.password-toggle-btn:focus {
    outline: none;
}

.password-toggle-btn svg {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

.caps-warning {
    color: var(--danger);
    font-size: 0.82rem;
    font-weight: 500;
    margin-top: 2px;
    animation: fadeInWarning 0.2s ease-out forwards;
}

@keyframes fadeInWarning {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.narrow {
    max-width: 520px;
}

.checkin-btn {
    min-height: 52px;
    font-size: 1.05rem;
}

.big-action-btn {
    display: block;
    width: 100%;
    min-height: 64px;
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 1rem;
    border-radius: 12px;
}

.checkout-btn {
    background: var(--accent);
    border-color: var(--accent);
}

.checkout-btn:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.inline-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.form-inline label {
    margin: 0;
}

.search-label {
    display: block;
    margin-top: 0.5rem;
}

.search-input {
    max-width: 320px;
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--muted);
}

.btn-small {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.btn-ghost {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--border);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #e8f2f2;
    color: var(--accent-dark);
}

.badge-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-muted {
    background: var(--surface-2);
    color: var(--muted);
}

.map-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.map-modal[hidden] {
    display: none;
}

.map-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.map-modal-content {
    position: relative;
    background: var(--surface);
    border-radius: 12px;
    padding: 1rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.map-modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--surface-2);
    border-radius: 8px;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text);
}

.map-box {
    height: 360px;
    width: 100%;
    border-radius: 8px;
    background: var(--surface-2);
}

.map-coords {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
}

.map-container {
    height: 200px;
    width: 100%;
    margin: 0.75rem 0;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-2);
}

.btn-map {
    margin-right: 0.5rem;
}

/* Attendance calendar block */
.attendance-calendar-wrap {
    background: var(--surface-2);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border);
}

.attendance-date-form {
    margin: 0;
}

.attendance-date-label {
    display: block;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.attendance-date-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.attendance-date-input {
    min-width: 180px;
    padding: 0.65rem 0.85rem;
    font-size: 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.attendance-date-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(8, 131, 149, 0.2);
}

.attendance-date-btn {
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
}

.attendance-date-btn:hover {
    background: var(--accent-dark);
}

.attendance-date-hint {
    margin: 0.75rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Attendance row buttons: selected = colored, unselected = grey/white */
.attendance-btn-form {
    display: inline-block;
    margin: 0;
}

.btn-attendance {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-attendance:not(.is-selected) {
    background: #f8fafc;
    color: var(--muted);
    border-color: var(--border);
}

.btn-attendance:not(.is-selected):hover {
    background: var(--surface-2);
    color: var(--text);
}

.btn-attendance.btn-full.is-selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-attendance.btn-half.is-selected {
    background: var(--accent-light);
    border-color: var(--accent-light);
    color: #fff;
}

.btn-attendance.btn-absent.is-selected {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.inline-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.inline-filters label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.location-checkboxes {
    display: grid;
    gap: 0.5rem;
    margin: 1rem 0;
}

.location-checkboxes legend {
    color: var(--muted);
    font-size: 0.9rem;
}

.fieldset-checkboxes {
    border: none;
    padding: 0;
}

.button-link {
    display: inline-block;
    padding: 0.6rem 1rem;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    border-radius: 8px;
    margin-top: 0.5rem;
    transition: background 0.15s;
}

.button-link:hover {
    background: var(--accent-hover);
    filter: none;
    text-decoration: none;
}

@media (max-width: 900px) {
    .layout-body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .cards-3 {
        grid-template-columns: 1fr;
    }

    .app-footer-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Mobile centered branding matching login screen */
    .sidebar .brand {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 1rem 0 0.5rem;
    }

    .sidebar .brand-title {
        font-size: 2rem;
        font-weight: 900;
        letter-spacing: 0.16em;
        line-height: 1.1;
        margin-bottom: 0.25rem;
    }

    .sidebar .brand-subtitle {
        font-size: 0.85rem;
        font-weight: 600;
        letter-spacing: 0.06em;
    }
}