:root {
    --navy: #1b2a4a;
    --navy-dark: #14203a;
    --blue: #2f6fed;
    --green: #1e9e5a;
    --green-dark: #17824a;
    --red: #d64545;
    --red-dark: #b93838;
    --grey-bg: #f2f4f8;
    --grey-border: #dde3ec;
    --text: #22293a;
    --muted: #6b7385;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(20, 32, 58, 0.08), 0 4px 14px rgba(20, 32, 58, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--grey-bg);
    color: var(--text);
    line-height: 1.5;
}

/* ---------- Navigation ---------- */
.topnav {
    background: var(--navy);
    color: #fff;
}

.topnav-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    align-items: center;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

/* Uploaded logo standing in for the hotel name. Capped in both directions so a
   tall or very wide file cannot stretch the bar. */
.brand-logo {
    display: block;
    height: 32px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.nav-links a {
    color: #cdd6e8;
    text-decoration: none;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    font-size: 0.95rem;
}

.nav-links a:hover {
    background: var(--navy-dark);
    color: #fff;
}

.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: #cdd6e8;
}

.nav-user .logout {
    color: #fff;
    text-decoration: none;
    background: var(--navy-dark);
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
}

/* ---------- Layout ---------- */
.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
}

.container.narrow { max-width: 560px; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0.5rem 0 1rem;
}

.page-head h1 { margin: 0; font-size: 1.45rem; }

h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; margin-top: 0; }

.card {
    background: #fff;
    border: 1px solid var(--grey-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.narrow-card { max-width: 560px; }

.muted { color: var(--muted); font-size: 0.92rem; }
.center { text-align: center; }

/* ---------- Alerts & badges ---------- */
.alert {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    margin: 0.6rem 0;
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.alert-success { background: #e7f6ee; border-color: #bfe5d0; color: #14603a; }
.alert-error   { background: #fdecec; border-color: #f3c6c6; color: #8a2626; }
.alert-info    { background: #eaf1fe; border-color: #c8d9f8; color: #24508f; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-green { background: #e7f6ee; color: #14603a; }
.badge-blue  { background: #eaf1fe; color: #24508f; }
.badge-grey  { background: #eef0f4; color: #555e70; }
.badge-red   { background: #fdecec; color: #8a2626; }
.badge-amber { background: #fdf3e0; color: #8a5a19; }

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.45rem;
}

.dot-green { background: var(--green); }
.dot-blue  { background: var(--blue); }
.dot-grey  { background: #a7afc0; }

.status-line {
    font-size: 1.02rem;
    padding: 0.4rem 0 0.8rem;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s ease;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary   { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2258c7; }
.btn-secondary { background: #e8ecf3; color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #dbe1eb; }
.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--green-dark); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--red-dark); }

.btn-small { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

.btn-big {
    display: block;
    width: 100%;
    padding: 1.1rem;
    font-size: 1.25rem;
    border-radius: 12px;
    margin: 0.75rem 0 0.5rem;
}

form.inline { display: inline; }
.actions { white-space: nowrap; }
.actions .btn { margin-right: 0.3rem; }

/* ---------- Forms ---------- */
label {
    display: block;
    margin: 0.85rem 0 0.25rem;
    font-weight: 600;
    font-size: 0.92rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="datetime-local"],
input[type="time"],
select {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--grey-border);
    border-radius: 8px;
    font-size: 0.98rem;
    background: #fff;
    color: var(--text);
}

input[type="file"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px dashed var(--grey-border);
    border-radius: 8px;
    background: #fff;
    font-size: 0.92rem;
}

input:focus, select:focus {
    outline: 2px solid rgba(47, 111, 237, 0.35);
    border-color: var(--blue);
}

form .btn[type="submit"] { margin-top: 1.1rem; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    margin-top: 1rem;
}

.checkbox-label input { width: auto; }

.filter-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-form label { margin: 0; }
.filter-form input, .filter-form select { width: auto; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.93rem;
}

.table th, .table td {
    text-align: left;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--grey-border);
    white-space: nowrap;
}

.table thead th {
    background: #f7f9fc;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.table tbody tr:hover { background: #fafbfd; }
.row-absent td { color: var(--muted); }
.row-daytotal td { background: #f7f9fc; font-size: 0.88rem; }

.row-group td {
    background: #eef2f9;
    border-top: 2px solid var(--grey-border);
    font-size: 0.95rem;
}

.row-group .badge { margin-left: 0.4rem; }

/* ---------- Manual entry (admin) ---------- */
.manual-entry summary {
    cursor: pointer;
    padding: 0.1rem 0;
}

.manual-entry-form { margin-top: 0.75rem; }

.manual-entry-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.manual-entry-fields label { margin-top: 0; }

.manual-checkout {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    vertical-align: middle;
}

.manual-checkout input[type="datetime-local"] {
    width: 190px;
    padding: 0 0.5rem;
    font-size: 0.88rem;
    border: 1px solid var(--grey-border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    height: 30px;
    box-sizing: border-box;
}

.manual-checkout .btn {
    height: 30px;
    padding: 0 0.7rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    margin: 0;
    box-sizing: border-box;
}

.table tfoot th {
    text-align: left;
    padding: 0.55rem 0.7rem;
    background: #f7f9fc;
}

/* ---------- Stats ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.25rem;
}

.stat {
    text-align: center;
    padding: 1rem 0.5rem;
    margin-bottom: 0;
}

.stat-value {
    display: block;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--navy);
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
}

/* ---------- Login ---------- */
.login-body {
    background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 60%, #0d1526 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-wrap {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-card { padding: 2rem 1.75rem; }
.login-title { text-align: center; margin: 0 0 0.25rem; font-size: 1.35rem; }
.login-logo {
    display: block;
    margin: 0 auto;
    max-height: 80px;
    max-width: 100%;
    width: auto;
    object-fit: contain;
}
.login-card form .btn { margin-top: 1.25rem; }

/* ---------- Branding uploads (admin settings) ---------- */
.branding-preview {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid #dfe3ea;
    border-radius: 8px;
    /* Chequerboard, so a transparent PNG reads as transparent rather than white. */
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #eef0f4 25%, transparent 25%, transparent 75%, #eef0f4 75%),
        linear-gradient(45deg, #eef0f4 25%, transparent 25%, transparent 75%, #eef0f4 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
}

.branding-preview img {
    height: 40px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
}

.branding-preview img.favicon-preview {
    height: 32px;
    width: 32px;
}

.branding-remove {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-weight: 400;
    font-size: 0.9rem;
}

.branding-remove input { width: auto; margin: 0; }

/* ---------- Check-in card ---------- */
.checkin-card {
    max-width: 480px;
    margin: 0 auto 1.25rem;
}

code {
    background: #eef0f4;
    padding: 0.1rem 0.4rem;
    border-radius: 5px;
    font-size: 0.92em;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .topnav-inner { padding: 0.5rem 0.75rem; }
    .brand-logo { height: 28px; max-width: 150px; }
    .nav-user { margin-left: 0; width: 100%; justify-content: space-between; }
    .page-head { flex-direction: column; align-items: flex-start; }
    .container { padding: 1rem 0.75rem 2.5rem; }
    .card { padding: 1rem; }
}

/* ---------- Custom Modal Dialog ---------- */
.modal-backdrop[hidden] {
    display: none !important;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(20, 32, 58, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
    box-sizing: border-box;
}

.modal-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(20, 32, 58, 0.15);
    border: 1px solid var(--grey-border);
    animation: modal-appear 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modal-appear {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-card h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
    color: var(--navy);
}

.modal-card p {
    margin: 0 0 1.25rem;
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

@media (max-width: 480px) {
    .modal-card {
        padding: 1.25rem;
    }
    .modal-actions {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    .modal-actions .btn {
        width: 100%;
        padding: 0.75rem;
        font-size: 0.95rem;
        height: auto;
        display: block;
    }
}

/* ---------- Bikram Sambat date picker ---------- */
/* Trigger button acting as a date field (filter bar / day nav). */
.bs-dp { text-align: left; min-width: 11rem; }

/* BS date button + native time input sitting side by side. */
.bs-datetime {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.bs-datetime .bs-dp {
    min-width: 7.5rem;
    flex: 0 1 auto;
}
.bs-datetime input[type="time"] {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
}

/* In the missed-check-in form, stack the date button over the time input so the
   check-in and check-out fields line up consistently regardless of label width. */
.manual-entry-fields .bs-datetime {
    flex-direction: column;
    align-items: stretch;
}
.manual-entry-fields .bs-datetime .bs-dp,
.manual-entry-fields .bs-datetime input[type="time"] {
    width: 100%;
    min-width: 0;
}

/* Compact variant inside the inline check-out cell (matches the button height). */
.manual-checkout .bs-datetime { gap: 0.35rem; }
.manual-checkout .bs-dp {
    min-width: 7rem;
    height: 30px;
    padding: 0 0.6rem;
    font-size: 0.85rem;
}
.manual-checkout input[type="time"] {
    width: auto;
    height: 30px;
    padding: 0 0.5rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

.bs-dp-popup {
    position: absolute;
    z-index: 1000;
    width: 17rem;
    max-width: calc(100vw - 1rem);
    background: #fff;
    border: 1px solid var(--grey-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.6rem;
}

.bs-dp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.bs-dp-title { font-weight: 700; }
.bs-dp-nav {
    border: 1px solid var(--grey-border);
    background: var(--grey-bg);
    color: var(--text);
    border-radius: 6px;
    width: 2rem;
    height: 2rem;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}
.bs-dp-nav:disabled { opacity: 0.4; cursor: default; }

.bs-dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.bs-dp-wd {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    padding-bottom: 0.2rem;
}
.bs-dp-empty { height: 2rem; }
.bs-dp-day {
    height: 2rem;
    border: 0;
    background: transparent;
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}
.bs-dp-day:hover:not(:disabled) { background: var(--grey-bg); }
.bs-dp-day.is-selected { background: var(--navy); color: #fff; }
.bs-dp-day:disabled { color: var(--grey-border); cursor: default; }

/* ---------- Footer ---------- */
.site-footer {
    padding: 1.75rem 1rem 1.25rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
}
.site-footer a {
    color: var(--navy);
    font-weight: 600;
    text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }

/* The login screen sits on a dark gradient, so the footer inverts there. */
.login-body .site-footer { color: rgba(255, 255, 255, 0.6); }
.login-body .site-footer a { color: rgba(255, 255, 255, 0.9); }
