/* ============================================================
   Prep — Owner Frontend Styles
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #0a0a0f;
    --surface:      #13131a;
    --surface2:     #1a1a24;
    --surface3:     #20202e;
    --border:       #2a2a3a;
    --text:         #e8e8f0;
    --text-muted:   #7777aa;
    --text-faint:   #4a4a6a;
    --primary:      #6c5ce7;
    --primary-h:    #7d6ff0;
    --green:        #00b894;
    --green-dim:    rgba(0,184,148,.12);
    --red:          #e17055;
    --red-dim:      rgba(225,112,85,.12);
    --amber:        #f59e0b;
    --amber-dim:    rgba(245,158,11,.12);
    --blue:         #0984e3;
    --blue-dim:     rgba(9,132,227,.12);
    --radius:       10px;
    --radius-sm:    6px;
    --shadow:       0 4px 24px rgba(0,0,0,.4);
    --sidebar-w:    230px;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* ── Layout ─────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand-logo {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), #a29bfe);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; font-weight: 800; color: #fff;
    flex-shrink: 0;
}

.sidebar-brand-text {
    display: flex; flex-direction: column;
}

.sidebar-brand-name {
    font-size: 1rem; font-weight: 700; color: var(--text);
    line-height: 1.2;
}

.sidebar-brand-sub {
    font-size: 0.7rem; color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(108,92,231,.18); color: var(--primary); }

.nav-item .nav-icon { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }

.nav-section {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-faint);
    padding: 12px 12px 4px;
}

.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
}

.sidebar-user-avatar {
    width: 30px; height: 30px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.68rem; color: var(--text-muted); }

/* ── Page body ───────────────────────────────────────────── */
.page-body {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topnav {
    height: 54px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topnav-page { font-size: 1rem; font-weight: 600; }
.topnav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.page-main {
    flex: 1;
    padding: 28px 28px 40px;
    max-width: 1100px;
    width: 100%;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.card-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.card-actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 20px; }

/* ── Metrics grid ────────────────────────────────────────── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}

.metric-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.metric-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; }
.metric-green .metric-value { color: var(--green); }
.metric-red   .metric-value { color: var(--red); }
.metric-amber .metric-value { color: var(--amber); }
.metric-blue  .metric-value { color: var(--blue); }

/* ── Table card ──────────────────────────────────────────── */
.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.table-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-card-title { font-size: 0.9rem; font-weight: 600; }
.table-card-sub   { font-size: 0.75rem; color: var(--text-muted); }
.table-card-actions { margin-left: auto; }

table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    white-space: nowrap;
}

td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    text-decoration: none;
}

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

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface3); }

.btn-danger    { background: var(--red-dim); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(225,112,85,.22); }

.btn-success   { background: var(--green-dim); color: var(--green); }
.btn-success:hover:not(:disabled) { background: rgba(0,184,148,.22); }

.btn-sm { padding: 5px 11px; font-size: 0.78rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }
.btn-icon { padding: 7px; }

.action-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    border: none; border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all .15s;
}
.action-btn:hover { color: var(--text); background: var(--surface3); }
.action-btn.action-red:hover { color: var(--red); background: var(--red-dim); }
.action-btn.action-green:hover { color: var(--green); background: var(--green-dim); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-green  { background: var(--green-dim);  color: var(--green); }
.badge-red    { background: var(--red-dim);    color: var(--red); }
.badge-amber  { background: var(--amber-dim);  color: var(--amber); }
.badge-blue   { background: var(--blue-dim);   color: var(--blue); }
.badge-muted  { background: var(--surface2);   color: var(--text-muted); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 9px 12px;
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
    -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
}

textarea { resize: vertical; min-height: 80px; }

select option { background: var(--surface2); }

.form-row {
    display: grid;
    gap: 14px;
}
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.input-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Toggle / Checkbox ───────────────────────────────────── */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toggle {
    position: relative;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface3);
    border-radius: 99px;
    transition: .2s;
    border: 1px solid var(--border);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    left: 3px; top: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: .2s;
}

.toggle input:checked + .toggle-slider { background: var(--primary); border-color: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #fff; }

.toggle-label { font-size: 0.85rem; }

/* ── Modals ───────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-content.modal-sm  { max-width: 420px; }
.modal-content.modal-lg  { max-width: 700px; }
.modal-content.modal-xl  { max-width: 900px; }

.modal-header {
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.modal-header h2 { font-size: 1rem; font-weight: 600; }
.modal-header-sub { font-size: 0.75rem; color: var(--text-muted); }

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: -2px;
}
.close-btn:hover { color: var(--text); background: var(--surface2); }

.modal-body { padding: 20px; }

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* ── Toolbar ─────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon { font-size: 2.5rem; margin-bottom: 14px; }
.empty-state h3 { font-size: 1rem; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 0.85rem; }

/* ── Toast ───────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
    max-width: 360px;
    animation: slideUp .2s ease;
}

.toast-success { border-color: var(--green); }
.toast-success span:first-child { color: var(--green); }
.toast-error   { border-color: var(--red); }
.toast-error   span:first-child { color: var(--red); }
.toast-info    { border-color: var(--primary); }
.toast-info    span:first-child { color: var(--primary); }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

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

/* ── Dashboard status grid ───────────────────────────────── */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.branch-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.branch-card-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.branch-card-icon {
    width: 34px; height: 34px;
    background: rgba(108,92,231,.15);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.branch-card-name { font-size: 0.9rem; font-weight: 600; }
.branch-card-code { font-size: 0.72rem; color: var(--text-muted); }

.checklist-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
}

.checklist-row:last-child { border-bottom: none; }

.checklist-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.checklist-dot.done    { background: var(--green); }
.checklist-dot.pending { background: var(--border); }

.checklist-name { font-size: 0.85rem; flex: 1; }

.checklist-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.checklist-link {
    font-size: 0.75rem;
    color: var(--primary);
    text-decoration: none;
}
.checklist-link:hover { text-decoration: underline; }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 4px;
}

/* ── Checklist config items ──────────────────────────────── */
.item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.item-label { flex: 1; font-size: 0.875rem; }

.item-photo-badge {
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 99px;
    background: var(--amber-dim);
    color: var(--amber);
    font-weight: 600;
}

/* ── Photo grid ──────────────────────────────────────────── */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.photo-thumb {
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: opacity .15s;
    width: 100%;
}

.photo-thumb:hover { opacity: .85; }

/* ── Lightbox ────────────────────────────────────────────── */
#lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.9);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

#lightbox.active { display: flex; }

#lightbox img {
    max-width: 92vw;
    max-height: 90vh;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

#lightbox-close {
    position: absolute;
    top: 20px; right: 24px;
    font-size: 1.8rem;
    color: #fff;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
}

/* ── Login page ──────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}

.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
    box-shadow: var(--shadow);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.login-logo-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary), #a29bfe);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 800; color: #fff;
}

.login-logo-text h1 { font-size: 1.2rem; font-weight: 700; }
.login-logo-text p  { font-size: 0.75rem; color: var(--text-muted); }

.login-error {
    background: var(--red-dim);
    border: 1px solid var(--red);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.83rem;
    color: var(--red);
    margin-bottom: 16px;
    display: none;
}

/* ── Subtoolbar ──────────────────────────────────────────── */
.subtoolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.subtoolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* ── Pill divider ────────────────────────────────────────── */
.section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 22px 0 16px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── Hamburger (mobile) ──────────────────────────────────── */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    flex-direction: column;
    gap: 4px;
}

.hamburger span {
    display: block;
    width: 20px; height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: .2s;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-w)));
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.4);
    }

    .sidebar-overlay.active { display: block; }

    .page-body { margin-left: 0; }

    .hamburger { display: flex; }

    .page-main { padding: 20px 16px 32px; }

    .form-row.cols-2,
    .form-row.cols-3 { grid-template-columns: 1fr; }

    .metrics-grid { grid-template-columns: 1fr 1fr; }

    .dash-grid { grid-template-columns: 1fr; }
}
