/* ── DESIGN TOKENS ─────────────────────────────────── */
:root {
    --orange-50: #fff7ed;
    --orange-100: #ffedd5;
    --orange-200: #fed7aa;
    --orange-400: #fb923c;
    --orange-500: #f5821f;
    --orange-600: #ea6c0a;
    --orange-700: #c2550a;
    --orange-800: #9a3f08;

    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    --white: #ffffff;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    --success: #10b981;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .05);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .10), 0 4px 12px rgba(15, 23, 42, .06);
    --shadow-orange: 0 4px 18px rgba(13, 148, 136, .22);

    --transition: 0.2s cubic-bezier(.4, 0, .2, 1);
}

/* ── RESET & BASE ──────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--slate-100);
    background-image:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(13, 148, 136, .10) 0%, transparent 60%),
        linear-gradient(180deg, var(--slate-100) 0%, #e8f4f3 100%);
    background-attachment: fixed;
    min-height: 100dvh;
    color: var(--slate-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── LAYOUT ────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100dvh;
    padding: 24px 16px 40px;
}

.app-card {
    width: 100%;
    max-width: 620px;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(203, 213, 225, .6);
    overflow: hidden;
}

/* ── HEADER ────────────────────────────────────────── */
.app-header {
    background: linear-gradient(135deg, var(--orange-700) 0%, var(--orange-500) 100%);
    padding: 36px 32px 28px;
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, .08) 0%, transparent 50%),
        radial-gradient(circle at 20% 80%, rgba(0, 0, 0, .06) 0%, transparent 40%);
}

.header-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.header-logo {
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, .18);
    border-radius: var(--radius-lg);
    display: grid;
    place-items: center;
    margin-bottom: 4px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, .25);
}

.header-logo svg {
    width: 26px;
    height: 26px;
    stroke: white;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#pageTitle {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    font-weight: 400;
    color: var(--white);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

#pageSubtitle {
    font-size: 0.8rem;
    font-weight: 400;
    color: rgba(255, 255, 255, .72);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ── BODY CONTENT ──────────────────────────────────── */
.app-body {
    padding: 28px 28px 32px;
}

@media (max-width: 480px) {
    .app-header {
        padding: 28px 20px 22px;
    }

    .app-body {
        padding: 20px 16px 28px;
    }
}

/* ── FOOTER CONTENT ────────────────────────────────── */
.app-footer {
    text-align: center;
    margin-top: 16px;
    margin-bottom: 24px;
    color: var(--slate-400);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.app-footer p {
    margin: 0;
}

/* ── VIEW SECTIONS ─────────────────────────────────── */
.view-section {
    display: block;
}

.view-section.hidden {
    display: none !important;
}

/* ── LOGIN SECTION ─────────────────────────────────── */
.login-welcome {
    text-align: center;
    padding: 12px 0 24px;
}

.login-welcome h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--slate-800);
    margin-bottom: 8px;
}

.login-welcome p {
    font-size: 0.875rem;
    color: var(--slate-500);
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--slate-400);
    font-size: 0.75rem;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--slate-200);
}

.google-btn-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    color: var(--slate-500);
    font-size: 0.875rem;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--orange-200);
    border-top-color: var(--orange-600);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.error-msg {
    text-align: center;
    color: var(--danger);
    font-size: 0.8rem;
    font-weight: 500;
    min-height: 20px;
    padding: 4px 0;
}

/* ── USER BADGE ────────────────────────────────────── */
.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--orange-50);
    border: 1px solid var(--orange-100);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 24px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange-500), var(--orange-700));
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.user-avatar svg {
    width: 20px;
    height: 20px;
    stroke: white;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.user-info .label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--orange-600);
}

.user-info .name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--slate-800);
}

/* ── SECTION HEADINGS ──────────────────────────────── */
.section-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 24px 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--slate-200);
}

.section-heading:first-of-type {
    margin-top: 0;
}

.section-heading .icon {
    width: 28px;
    height: 28px;
    background: var(--orange-50);
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.section-heading .icon svg {
    width: 14px;
    height: 14px;
    stroke: var(--orange-600);
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.section-heading .title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--slate-600);
}

.section-heading .badge {
    margin-left: auto;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--slate-400);
    background: var(--slate-100);
    padding: 2px 8px;
    border-radius: 20px;
}

/* ── GRID ──────────────────────────────────────────── */
.grid {
    display: grid;
    gap: 14px;
}

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

.grid-full {
    grid-column: 1 / -1;
}

@media (max-width: 480px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ── FORM ELEMENTS ─────────────────────────────────── */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--slate-500);
}

.field label .req {
    color: var(--orange-500);
    margin-left: 2px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 11px 14px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--slate-800);
    background: var(--slate-50);
    border: 1.5px solid var(--slate-200);
    border-radius: var(--radius-md);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.field textarea {
    resize: vertical;
    min-height: 88px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--orange-500);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, .12);
}

.field input:disabled,
.field input[readonly] {
    background: var(--slate-100);
    color: var(--slate-500);
    border-style: dashed;
    cursor: default;
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--slate-400);
}

/* Separator */
.separator {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
}

.separator::before,
.separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #00000025;
}

.separator:not(:empty)::before {
    margin-right: 0.5em;
}

.separator:not(:empty)::after {
    margin-left: 0.5em;
}

.separator span {
    background: #fff;
    color: #00000080;
    padding: 0 10px;
}


.autofill-indicator {
    position: relative;
}

.autofill-indicator::after {
    content: 'AUTO';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--orange-600);
    background: var(--orange-50);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--orange-100);
    pointer-events: none;
}

/* ── CUSTOM DROPDOWN ───────────────────────────────── */
.custom-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--white);
    border: 1.5px solid var(--slate-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow-y: auto;
    margin-top: 4px;
    transition: opacity var(--transition), visibility var(--transition);
}

.custom-dropdown.hidden {
    display: none !important;
    opacity: 0;
    visibility: hidden;
}

.dropdown-item {
    padding: 11px 14px;
    font-size: 0.9rem;
    color: var(--slate-800);
    cursor: pointer;
    transition: background-color var(--transition);
    border-bottom: 1px solid var(--slate-100);
}

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

.dropdown-item:hover {
    background-color: var(--orange-50);
    color: var(--orange-700);
}

.dropdown-item.active {
    background-color: var(--orange-100);
    color: var(--orange-700);
    font-weight: 600;
}

.dropdown-empty {
    padding: 18px 14px;
    text-align: center;
    color: var(--slate-400);
    font-size: 0.85rem;
}

/* ── SUBMIT BUTTON ─────────────────────────────────── */
.btn-submit {
    width: 100%;
    padding: 14px 24px;
    margin-top: 28px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--white);
    background: linear-gradient(135deg, var(--orange-600) 0%, var(--orange-500) 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
    box-shadow: var(--shadow-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(13, 148, 136, .32);
}

.btn-submit:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-submit svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.btn-sheets {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 18px;
    border-radius: 8px;
    background: #27a55e;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.btn-sheets:hover {
    background: #1c7b45;
    box-shadow: 0 3px 8px rgba(26, 115, 64, 0.35);
    transform: translateY(-1px);
}

.btn-sheets:active {
    background: #0f4a24;
    transform: translateY(0);
    box-shadow: none;
}

.btn-sheets svg {
    flex-shrink: 0;
}

/* ── LOGOUT LINK ───────────────────────────────────── */
.logout-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--slate-400);
    text-decoration: none;
    cursor: pointer;
    transition: color var(--transition);
    background: none;
    border: none;
    width: 100%;
    padding: 4px;
}

.logout-link:hover {
    color: var(--danger);
}

/* ── DASHBOARD ─────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100% !important;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 18px 16px;
    width: 100% !important;
    transition: border-color var(--transition);
}

.stat-card:hover {
    border-color: var(--orange-200);
}

.stat-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--slate-400);
    margin-bottom: 6px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 400;
    color: var(--slate-800);
    line-height: 1;
}

.stat-value.accent {
    color: var(--orange-600);
}

/* ── LOG LIST ──────────────────────────────────────── */
.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--slate-200);
}

.list-header .title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--slate-500);
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--orange-600);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    transition: background var(--transition);
}

.btn-refresh:hover {
    background: var(--orange-50);
}

.btn-refresh svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.log-list-container {
    max-height: 360px;
    overflow-y: auto;
    padding-right: 2px;
}

.log-list-container::-webkit-scrollbar {
    width: 3px;
}

.log-list-container::-webkit-scrollbar-track {
    background: transparent;
}

.log-list-container::-webkit-scrollbar-thumb {
    background: var(--slate-300);
    border-radius: 4px;
}

.log-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 0;
    border-bottom: 1px solid var(--slate-100);
    animation: slideIn .25s ease forwards;
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.log-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.log-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--slate-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-time {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-family: 'DM Mono', monospace;
    color: var(--slate-400);
    background: var(--slate-100);
    padding: 2px 7px;
    border-radius: 20px;
    letter-spacing: 0.02em;
}

.log-activity {
    font-size: 0.82rem;
    color: var(--slate-500);
    line-height: 1.5;
}

.log-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--slate-400);
    font-size: 0.85rem;
}

.log-empty svg {
    display: block;
    margin: 0 auto 10px;
    width: 32px;
    height: 32px;
    stroke: var(--slate-300);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}


/* ── PROGRESS BAR ──────────────────────────────────── */
.progress-bar-wrapper {
    height: 4px;
    background: var(--slate-200);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--orange-500), var(--orange-400));
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(.4, 0, .2, 1);
}

/* ── CUSTOM MODAL  ─────────────────────────────────── */
.custom-modal {
    border: none;
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    background: var(--white);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    text-align: center;

    margin: 0;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.custom-modal::backdrop {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.custom-modal .modal-icon svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
}

.custom-modal .modal-icon.info svg {
    stroke: var(--orange-500);
    fill: var(--orange-50);
}

.custom-modal .modal-icon.error svg {
    stroke: var(--danger);
    fill: var(--danger-light);
}

.custom-modal .modal-icon.success svg {
    stroke: var(--orange-600);
    fill: var(--orange-50);
}

.custom-modal h3 {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
    color: var(--slate-800);
}

.custom-modal p {
    margin: 0 0 24px 0;
    font-size: 0.9rem;
    color: var(--slate-500);
    line-height: 1.5;
    white-space: pre-wrap;
}

.custom-modal .modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.custom-modal .modal-actions button {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-cancel {
    background: var(--slate-100);
    color: var(--slate-600);
}

.btn-cancel:hover {
    background: var(--slate-200);
}

.btn-confirm {
    background: var(--orange-500);
    color: var(--white);
    flex-grow: 1;
}

.btn-confirm:hover {
    background: var(--orange-600);
}

.master-nav {
    width: 100%;
    display: flex;
    gap: 4px;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--slate-200);
    background: var(--slate-100, #f1f5f9);
    border-radius: 10px;
    padding: 4px;
}

.master-nav .nav-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: #9ca3af !important;;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.master-nav .nav-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.7);
    color: var(--slate-700, #334155);
}

.master-nav .nav-btn.active {
    background: #ffffff;
    color: #111827 !important;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

/* ── UTILITY ───────────────────────────────────────── */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeUp .4s cubic-bezier(.4, 0, .2, 1) forwards;
}

#photoInput::file-selector-button {
    background: var(--primary-color);
    color: #fb923c;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    margin-right: 10px;
    cursor: pointer;
    font-size: 0.8rem;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── RESPONSIVE TWEAKS ─────────────────────────────── */
@media (max-width: 360px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 1.6rem;
    }
}