/* =====================================================================
   LOG BOOK MAKER
   style.css  |  Full rewrite — no Tailwind dependency
   All layout, colour, and typography driven by CSS custom properties.
   ===================================================================== */


/* ========== 1. FONTS ========== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Lora:ital,wght@0,400;0,600;0,700;1,400&family=Courier+Prime:ital,wght@0,400;0,700;1,400&display=swap');


/* ========== 2. THEME TOKENS ========== */

:root,
[data-theme="light"] {
    --bg-base: #f0f6ff;
    --bg-surface: #e8f0fb;
    --surface-elevated: #ffffff;
    --surface-card: #ffffff;
    --surface-card-hover: #f0f7ff;

    --border: #c8d8ee;
    --border-subtle: #ddeaf8;
    --text-primary: #0a0f1e;
    --text-secondary: #1a3158;
    --text-muted: #5a7a9e;

    --accent: #06b6d4;
    --accent-hover: #0891b2;
    --accent-glow: rgba(6, 182, 212, 0.12);
    --accent-border: rgba(6, 182, 212, 0.3);

    --role-tech: #059669;
    --role-super: #d97706;
    --role-pm: #7c3aed;

    --role-tech-bg: rgba(5, 150, 105, 0.08);
    --role-tech-border: rgba(5, 150, 105, 0.2);
    --role-super-bg: rgba(217, 119, 6, 0.08);
    --role-super-border: rgba(217, 119, 6, 0.2);
    --role-pm-bg: rgba(124, 58, 237, 0.08);
    --role-pm-border: rgba(124, 58, 237, 0.2);
}

[data-theme="dark"] {
    --bg-base: #0a0f1e;
    --bg-surface: #0f1f3d;
    --surface-elevated: #0d1a35;
    --surface-card: #112244;
    --surface-card-hover: #162a50;

    --border: #1a3158;
    --border-subtle: #0f2040;
    --text-primary: #e8f4ff;
    --text-secondary: #93c5fd;
    --text-muted: #4a6a8a;

    --accent: #06b6d4;
    --accent-hover: #22d3ee;
    --accent-glow: rgba(6, 182, 212, 0.15);
    --accent-border: rgba(6, 182, 212, 0.25);

    --role-tech: #10b981;
    --role-super: #f59e0b;
    --role-pm: #a78bfa;

    --role-tech-bg: rgba(16, 185, 129, 0.08);
    --role-tech-border: rgba(16, 185, 129, 0.2);
    --role-super-bg: rgba(245, 158, 11, 0.08);
    --role-super-border: rgba(245, 158, 11, 0.2);
    --role-pm-bg: rgba(167, 139, 250, 0.08);
    --role-pm-border: rgba(167, 139, 250, 0.2);
}


/* ========== 3. RESET & BASE ========== */

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

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    background: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input,
textarea,
select {
    font-family: inherit;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

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

/* views / panels */
.is-hidden {
    display: none !important;
}

/* form container toggle */
.hidden-img {
    display: none;
}


/* ========== 4. FONT FAMILY UTILITIES ========== */

.font-serif-document {
    font-family: 'Lora', 'Times New Roman', serif;
}

.font-sans-document {
    font-family: 'Inter', Arial, sans-serif;
}

.font-mono-document {
    font-family: 'Courier Prime', Courier, monospace;
}


/* ========== 5. APP SHELL ========== */

/* --- Header --- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 24px;
    background: var(--surface-elevated);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 50;
    position: relative;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-logo-icon {
    width: 38px;
    height: 38px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 0 20px var(--accent-glow);
    border: 1px solid var(--accent-border);
}

.header-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.header-subtitle {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Tab switcher --- */
.tab-switcher {
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 3px;
    gap: 2px;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-radius: 9px;
    color: var(--text-muted);
    background: transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 0 16px var(--accent-glow);
}

.tab-btn:not(.active):hover {
    color: var(--text-primary);
    background: var(--border-subtle);
}

/* --- Theme toggle --- */
.theme-toggle-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 16px;
    transition: all 0.2s;
}

.theme-toggle-btn:hover {
    color: var(--accent);
    border-color: var(--accent-border);
    background: var(--accent-glow);
}

/* --- Main layout --- */
.app-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    height: calc(100vh - 57px);
}

.view-panel {
    flex: 1;
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

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

/* Dashboard view: sidebar + scroll area side-by-side */
.view-dashboard {
    flex-direction: row;
}

/* Preview view: vertical stack */
.view-preview {
    flex-direction: column;
    background: var(--bg-base);
    overflow-y: auto;
    align-items: center;
    padding: 24px;
    gap: 24px;
}


/* ========== 6. SIDEBAR ========== */

.app-sidebar {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: var(--bg-surface);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    height: 100%;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-label {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Search */
.search-wrap {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px 9px 34px;
    font-size: 12px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Week filter dropdown */
.week-filter-wrap {
    position: relative;
}

.week-filter-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.week-filter-trigger:hover {
    border-color: var(--accent-border);
}

.week-filter-trigger i:first-child {
    color: var(--accent);
    font-size: 14px;
}

.week-filter-arrow {
    color: var(--text-muted);
    font-size: 14px;
    margin-left: auto;
    transition: transform 0.2s;
    pointer-events: none;
}

.week-filter-popover {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
    z-index: 100;
    max-height: 260px;
    overflow-y: auto;
    padding: 6px;
}

[data-theme="dark"] .week-filter-popover {
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.week-filter-item {
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border-radius: 8px;
    transition: all 0.15s;
}

.week-filter-item:hover {
    background: var(--accent-glow);
    color: var(--text-primary);
}

.week-filter-item.active {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 700;
}

/* Role pills */
.role-pills {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.role-filter-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.18s;
    width: 100%;
    text-align: left;
}

.role-filter-btn:hover {
    background: var(--surface-card);
    border-color: var(--border);
    color: var(--text-primary);
}

.role-filter-btn.active {
    background: var(--accent-glow);
    border-color: var(--accent-border);
    color: var(--accent);
}

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

.dot-all {
    background: var(--accent);
}

.dot-tech {
    background: var(--role-tech);
}

.dot-super {
    background: var(--role-super);
}

.dot-pm {
    background: var(--role-pm);
}

.role-count {
    margin-left: auto;
    font-size: 10px;
    font-weight: 800;
    color: var(--text-muted);
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 6px;
    min-width: 22px;
    text-align: center;
}

.role-filter-btn.active .role-count {
    color: var(--accent);
    border-color: var(--accent-border);
    background: var(--accent-glow);
}

/* Sidebar action buttons */
.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border: 1px solid transparent;
    transition: all 0.18s;
}

.action-primary {
    background: var(--accent);
    color: #0a0f1e;
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.action-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}

.action-success {
    background: var(--role-tech-bg);
    color: var(--role-tech);
    border-color: var(--role-tech-border);
}

.action-success:hover {
    background: rgba(5, 150, 105, 0.15);
    border-color: rgba(5, 150, 105, 0.5);
}

.action-ghost {
    background: var(--surface-elevated);
    color: var(--text-secondary);
    border-color: var(--border);
}

.action-ghost:hover {
    color: var(--text-primary);
    border-color: var(--accent-border);
    background: var(--accent-glow);
}

.action-docs {
    background: var(--role-pm-bg);
    color: var(--role-pm);
    border-color: var(--role-pm-border);
}

.action-docs:hover {
    background: rgba(124, 58, 237, 0.12);
    border-color: rgba(124, 58, 237, 0.4);
}

.action-danger-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
    font-size: 10px;
}

.action-danger-ghost:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.06);
}


/* ========== 7. LOGS SCROLL AREA ========== */

.logs-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-base);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Status bar */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 16px;
}

.status-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--role-tech);
    flex-shrink: 0;
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.status-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
}

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

.status-badge {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--role-tech);
    background: var(--role-tech-bg);
    border: 1px solid var(--role-tech-border);
    padding: 3px 10px;
    border-radius: 6px;
}


/* ========== 8. ADD / EDIT FORM ========== */

.add-form-container {
    display: block;
    position: relative;
    background: var(--surface-card);
    border: 1px solid var(--accent-border);
    border-radius: 16px;
    padding: 24px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.form-accent-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: var(--accent);
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.form-title-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
}

.form-discard-btn {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    transition: color 0.2s;
}

.form-discard-btn:hover {
    color: var(--text-primary);
}

.log-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

@media (max-width: 700px) {
    .form-grid-3 {
        grid-template-columns: 1fr;
    }
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.form-input {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-textarea {
    resize: vertical;
}

.week-hint {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-glow);
    border: 1px solid var(--accent-border);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.form-cancel-btn {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 8px 16px;
    transition: color 0.2s;
}

.form-cancel-btn:hover {
    color: var(--text-primary);
}

.form-submit-btn {
    background: var(--accent);
    color: #0a0f1e;
    border: none;
    border-radius: 10px;
    padding: 10px 24px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow: 0 4px 14px var(--accent-glow);
    transition: all 0.2s;
}

.form-submit-btn:hover {
    background: var(--accent-hover);
    color: #fff;
}


/* ========== 9. LOGS LIST (rendered by JS) ========== */

.logs-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Week group header */
.week-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 16px;
    margin-bottom: 10px;
}

.week-group-header.has-entries {
    background: var(--accent-glow);
    border-color: var(--accent-border);
}

.week-badge {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    background: var(--surface-elevated);
    border: 1px solid var(--accent-border);
    padding: 3px 10px;
    border-radius: 8px;
}

.week-badge.empty {
    color: var(--text-muted);
    background: var(--surface-elevated);
    border-color: var(--border);
}

.week-date-range {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.week-date-range.empty {
    color: var(--text-muted);
}

.week-add-btn {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.week-add-btn:hover {
    color: var(--accent-hover);
}

.week-add-btn.empty {
    color: var(--text-muted);
}

.week-add-btn.empty:hover {
    color: var(--accent);
}

/* Log entry card */
.log-card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 12px;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    position: relative;
}

.log-card:hover {
    border-color: var(--accent-border);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .log-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.log-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.log-card-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.log-date-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-glow);
    border: 1px solid var(--accent-border);
    padding: 4px 12px;
    border-radius: 8px;
}

.log-client-name {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-primary);
}

.log-card-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.role-badge {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
}

.role-badge-tech {
    background: var(--role-tech-bg);
    color: var(--role-tech);
    border-color: var(--role-tech-border);
}

.role-badge-super {
    background: var(--role-super-bg);
    color: var(--role-super);
    border-color: var(--role-super-border);
}

.role-badge-pm {
    background: var(--role-pm-bg);
    color: var(--role-pm);
    border-color: var(--role-pm-border);
}

.log-card-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.log-card:hover .log-card-actions {
    opacity: 1;
}

.log-action-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-muted);
    transition: all 0.15s;
}

.log-action-btn:hover {
    background: var(--bg-surface);
}

.log-action-btn.edit:hover {
    color: var(--accent);
}

.log-action-btn.delete:hover {
    color: #ef4444;
}

.log-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    font-size: 12px;
}

@media (max-width: 800px) {
    .log-card-body {
        grid-template-columns: 1fr;
    }
}

.log-section-label {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
}

.log-section-label.tasks {
    color: var(--text-muted);
}

.log-section-label.reflect {
    color: var(--accent);
}

.log-tasks-text {
    color: var(--text-secondary);
    line-height: 1.6;
}

.log-reflect-col {
    border-left: 1px solid var(--border);
    padding-left: 20px;
}

.log-reflect-text {
    color: var(--text-secondary);
    line-height: 1.6;
    font-style: italic;
}

/* Empty week placeholder */
.week-empty-box {
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
    margin-bottom: 16px;
}

.week-empty-box p {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.week-empty-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    transition: color 0.2s;
}

.week-empty-add-btn:hover {
    color: var(--accent-hover);
}

/* No results */
.no-results-box {
    text-align: center;
    padding: 64px 20px;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.no-results-box i {
    font-size: 2rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 8px;
}

.no-results-box p {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
}

/* Week group wrapper */
.week-group {
    margin-bottom: 8px;
}


/* ========== 10. PREVIEW EDITOR TOOLBAR ========== */

.editor-toolbar {
    width: 100%;
    max-width: 794px;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.editor-toolbar-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.toolbar-font-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-label-sm {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ========== CUSTOM SELECT WRAPPER ========== */
/* Hides the native dropdown arrow and renders a remixicon chevron instead.
   Works for every <select> wrapped in .select-wrap throughout the app.     */

.select-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.2s;
    padding-right: 4px;
}

.select-wrap select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: transparent;
    border: none;
    outline: none;
    padding: 6px 32px 6px 10px;
    font-size: 11px;
    color: var(--text-primary);
    width: 100%;
    cursor: pointer;
}

/* The chevron icon sits as a pseudo-element overlay via a sibling <i> injected by JS */
.select-wrap .select-chevron {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--text-muted);
    pointer-events: none;
    line-height: 1;
}

/* Remove — wrapper handles these now */
.toolbar-select {
    background: transparent;
    border: none;
    padding: 6px 32px 6px 10px;
    font-size: 11px;
    color: var(--text-primary);
    outline: none;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    flex-shrink: 0;
}

.toolbar-format-btns {
    display: flex;
    align-items: center;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    gap: 2px;
}

.toolbar-divider-sm {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 4px;
    align-self: center;
}

.format-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-muted);
    transition: all 0.15s;
}

.format-btn:hover {
    color: var(--text-primary);
    background: var(--surface-card);
}

.print-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: #0a0f1e;
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow: 0 4px 14px var(--accent-glow);
    transition: all 0.2s;
}

.print-btn:hover {
    background: var(--accent-hover);
    color: #fff;
}


/* ========== 11. COVER SETTINGS TOOLBAR ========== */

.cover-settings-toolbar {
    width: 794px;
    margin: 0 auto;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.section-divider {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}

.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.toolbar-field {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 160px;
}

.toolbar-field-wide {
    min-width: 180px;
}

.toolbar-label {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

.toolbar-input {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

.toolbar-input:focus {
    border-color: var(--accent);
}

.upload-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--bg-surface);
    border: 1.5px dashed var(--border);
    border-radius: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 140px;
    text-align: center;
}

.upload-btn:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.upload-btn span {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.upload-icon {
    font-size: 20px;
    color: var(--text-muted);
}

.preview-thumb {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 4px;
}

.toolbar-fields-group {
    flex: 1;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.range-input {
    width: 100px;
    accent-color: var(--accent);
}

.range-value {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}


/* ========== 12. PRINT CANVAS ========== */

.print-canvas {
    width: 100%;
}


/* ========== 13. A4 PAGE SHEETS ========== */

/* Always white — immune to theme */
.a4-sheet,
.a4-sheet-continuous {
    width: 794px;
    margin: 0 auto 30px auto;
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.a4-sheet {
    min-height: 1123px;
    padding: var(--page-margin, 60px);
    display: flex;
    flex-direction: column;
    position: relative;
    page-break-after: always;
    break-after: page;
}

.a4-sheet-continuous {
    min-height: 1123px;
    height: auto;
    padding: 0;
    page-break-before: always;
    break-before: page;
}

/* Force all children of A4 to black text */
.a4-sheet *,
.a4-sheet-continuous * {
    color: #000000 !important;
}

.a4-sheet table {
    text-decoration: none !important;
}

.a4-sheet table td {
    text-decoration: none !important;
}


/* ========== 14. COVER PAGE ========== */

.cover-page {
    text-align: center;
    align-items: center;
    padding: 60px 70px;
}

.cover-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.cover-crest-wrap {
    margin-bottom: 20px;
}

.cover-crest-img {
    object-fit: contain;
    width: 160px;
    height: 160px;
}

.cover-crest-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px dashed #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cover-crest-placeholder i {
    font-size: 1.5rem;
    color: #cbd5e1;
}

.cover-faculty {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #000;
    margin: 0 0 3px;
    font-family: 'Lora', 'Times New Roman', serif;
}

.cover-dept {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #000;
    margin: 0;
    font-family: 'Lora', 'Times New Roman', serif;
}

.cover-spacer {
    flex: 1;
    min-height: 40px;
}

.cover-title-block {
    width: 100%;
}

.cover-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #000;
    font-family: 'Lora', 'Times New Roman', serif;
}

.cover-details-table-wrap {
    width: 70%;
    margin: 0 auto;
}

.cover-details-table {
    width: 100%;
    border-collapse: collapse;
}

.cover-detail-label,
.cover-detail-value {
    font-size: 11px;
    font-weight: 400;
    color: #000;
    padding: 6px 0;
    font-family: 'Lora', 'Times New Roman', serif;
}

.cover-detail-label {
    text-align: left;
    padding-right: 16px;
    white-space: nowrap;
}

.cover-detail-value {
    text-align: right;
}

.cover-submission-statement {
    width: 78%;
    margin: 0 auto;
}

.cover-submission-statement p {
    font-size: 11px;
    font-weight: 400;
    color: #000;
    line-height: 1.7;
    text-align: center;
    font-family: 'Lora', 'Times New Roman', serif;
}

.cover-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.cover-based-at {
    font-size: 11px;
    color: #000;
    margin: 0 0 12px;
    font-family: 'Lora', 'Times New Roman', serif;
}

.cover-logo-img {
    max-height: 70px;
    max-width: 200px;
    object-fit: contain;
    margin-bottom: 8px;
}

.cover-company-name {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #000;
    font-family: 'Lora', 'Times New Roman', serif;
}

.cover-location {
    font-size: 11px;
    color: #000;
    margin-top: 4px;
    font-family: 'Lora', 'Times New Roman', serif;
}


/* ========== 15. LOG TABLE (A4 pages) ========== */

table.log-table {
    width: 100%;
    border-collapse: collapse;
    border: 1.5px solid #000;
}

table.log-table th {
    border: 1px solid #000;
    background-color: #ffffff;
    color: #000000;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    padding: 10px 8px;
}

table.log-table td {
    border: 1px solid #000;
    color: #000000;
    font-size: 11px;
    line-height: 1.5;
    padding: 10px 8px;
    vertical-align: top;
    font-weight: 400;
    text-transform: none;
}

table.log-table tbody tr:last-child td {
    border-bottom: 1px solid #000;
}

/* Tick list — reflections column */
.tick-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.tick-list li {
    padding-left: 18px;
    position: relative;
    margin-bottom: 4px;
}

.tick-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #000000;
    font-weight: 900;
    font-size: 11px;
}

/* Inner content padding for weekly sheets */
.a4-inner-content {
    padding: var(--page-margin, 60px);
    background: transparent;
    color: #000;
}

/* Signature block */
.signature-block {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid #cbd5e1;
    display: flex;
    justify-content: space-between;
}

.sig-field {
    width: 176px;
}

.sig-field-right {
    width: 176px;
    text-align: right;
}

.sig-line {
    border-bottom: 1px solid #000;
    height: 32px;
    margin-bottom: 4px;
}

.sig-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #475569;
    display: block;
}

/* Week copy bar */
.week-copy-bar {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.week-copy-btn {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6366f1;
    background: transparent;
    border: 1px solid #6366f1;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
}


/* ========== 16. CONTENTEDITABLE ========== */

[contenteditable="true"]:focus {
    outline: 2px dashed var(--accent);
    outline-offset: 4px;
    background-color: var(--accent-glow);
    border-radius: 4px;
}


/* ========== 17. APP FOOTER ========== */

.app-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 24px;
    background: rgba(from var(--surface-elevated) r g b / 0.3);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    z-index: 40;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
}

.app-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s;
}

.app-footer a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

@media print {
    .app-footer {
        display: none !important;
    }
}


/* ========== 18. PRINT / PDF EXPORT ========== */

@media screen {
    .a4-inner-content {
        padding: var(--page-margin, 60px);
    }
}

@media print {

    /* ===== CRITICAL: break the overflow:hidden chain =====
     * Screen layout uses overflow:hidden on every ancestor.
     * Chrome clips printed content to the container bounds,
     * so only what fits in one viewport height gets captured.
     * Every ancestor must be overflow:visible and height:auto
     * so the full document flows.
     */
    html,
    body,
    .app-main,
    .view-panel,
    #view-preview,
    #view-preview.hidden,
    #print-canvas {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        display: block !important;
        position: static !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
    }

    header,
    #view-generator,
    .editor-toolbar,
    .cover-settings-toolbar,
    .no-print {
        display: none !important;
    }

    #view-preview,
    #view-preview.hidden {
        display: block !important;
        background: #fff !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        height: auto !important;
        width: 100% !important;
    }

    #view-generator,
    #view-generator.hidden {
        display: none !important;
    }

    /* Nuclear option: disable .hidden utility entirely during print */
    .hidden {
        display: revert !important;
    }

    /* But re-hide the no-print elements explicitly */
    .no-print {
        display: none !important;
    }

    .a4-sheet {
        box-shadow: none !important;
        margin: 0 !important;
        padding: var(--page-margin, 60px) !important;
        width: 100% !important;
        min-height: 100vh !important;
        border: none !important;
        page-break-after: always !important;
        break-after: page !important;
    }

    .a4-sheet-continuous {
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        min-height: auto !important;
        border: none !important;
        page-break-before: always !important;
        break-before: page !important;
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    .a4-inner-content {
        padding: var(--page-margin, 60px) !important;
    }

    table.log-table thead {
        display: none !important;
    }

    table.log-table tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}

/* ========== 19. MOBILE RESPONSIVE ========== */

@media (max-width: 768px) {

    /* ── Base scroll unlock ── */
    html,
    body {
        overflow: auto;
        height: auto;
    }

    .app-main {
        height: auto;
        overflow: visible;
        flex-direction: column;
    }

    /* ── Header: compact, no subtitle ── */
    .app-header {
        padding: 10px 14px;
        gap: 8px;
    }

    .header-subtitle {
        display: none;
    }

    .tab-switcher {
        background: var(--bg-surface);
        border-radius: 20px;
        padding: 3px;
    }

    .tab-btn {
        padding: 6px 14px;
        font-size: 10px;
        border-radius: 18px;
    }

    /* ── Dashboard: collapse sidebar into horizontal filter strip ── */
    .view-dashboard {
        flex-direction: column;
    }

    .app-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 10px 12px;
        gap: 8px;
        overflow: visible;
        flex-shrink: 0;
    }

    /* Hide sidebar labels on mobile — context is obvious */
    .sidebar-label {
        display: none;
    }

    /* Search: full width */
    .search-wrap {
        width: 100%;
    }

    /* Role pills: horizontal scroll strip */
    .role-pills {
        flex-wrap: nowrap;
        flex-direction: row;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
    }

    .role-pills::-webkit-scrollbar {
        display: none;
    }

    .role-filter-btn {
        width: auto;
        flex-shrink: 0;
        padding: 6px 12px;
        font-size: 10px;
        border-radius: 20px;
        flex-shrink: 0;
        /* ADD THIS — prevents pills squishing */
    }

    /* Week filter: full width */
    .week-filter-wrap {
        width: 100%;
    }

    /* Sidebar actions: 2-column grid */
    .sidebar-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--border);
        margin-top: 0;
    }

    .action-danger-ghost {
        grid-column: 1 / -1;
    }

    .action-btn {
        font-size: 10px;
        padding: 9px 10px;
        gap: 6px;
    }

    /* ── Logs area ── */
    .logs-scroll-area {
        padding: 12px;
        gap: 12px;
        height: auto;
        overflow-y: visible;
        padding-bottom: 24px;
    }

    /* Week group header: tighter */
    .week-group-header {
        padding: 8px 12px;
    }

    .week-date-range {
        font-size: 11px;
    }

    /* Log card: single column, always-visible actions */
    .log-card {
        padding: 14px;
    }

    .log-card-header {
        flex-wrap: nowrap;
        gap: 6px;
    }

    .log-card-header-left {
        gap: 8px;
        min-width: 0;
        flex: 1;
    }

    .log-client-name {
        font-size: 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100px;
    }

    .log-card-actions {
        opacity: 1;
        /* always visible — no hover on touch */
    }

    .log-action-btn {
        width: 30px;
        height: 30px;
    }

    .log-card-body {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .log-reflect-col {
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 12px;
    }

    /* ── Add/Edit form ── */
    .add-form-container {
        padding: 16px;
    }

    .form-grid-3 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* ── Preview/logbook view ── */
    .view-preview {
        padding: 10px;
        gap: 12px;
        overflow-y: auto;
        height: auto;
    }

    /* Editor toolbar: stack vertically */
    .editor-toolbar {
        width: 100%;
        max-width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }

    .editor-toolbar-left {
        flex-wrap: wrap;
        gap: 8px;
    }

    .print-btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }

    .toolbar-divider {
        display: none;
    }

    /* Cover settings: full width, columns stack */
    .cover-settings-toolbar {
        width: 100%;
        padding: 12px;
    }

    .toolbar-row {
        flex-direction: column;
        gap: 8px;
    }

    /* Upload + fields side by side on mobile */
    .toolbar-row:has(.upload-col) {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .upload-col {
        min-width: 100px;
    }

    .toolbar-field,
    .toolbar-field-wide {
        min-width: 0;
        width: 100%;
    }

    /* A4 sheets: scale to fit viewport */
    .a4-sheet,
    .a4-sheet-continuous {
        width: 794px;
        transform-origin: top left;
        transform: scale(calc((100vw - 20px) / 794));
        /* Compensate for the gap transform creates */
        margin-bottom: calc((1123px * ((100vw - 20px) / 794)) - 1123px + 12px);
    }

    /* Footer: static, compact */
    .app-footer {
        position: sticky;
        /* sticky instead of static or fixed */
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        padding: 10px 16px;
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
        gap: 4px;
        z-index: 40;
        /* Re-add the backdrop since sticky supports it */
        background: var(--surface-elevated);
        backdrop-filter: blur(8px);
        border-top: 1px solid var(--border);
    }
}

/* ── Narrow phones (< 400px) ── */
@media (max-width: 400px) {

    .app-header {
        padding: 8px 10px;
    }

    .tab-btn {
        padding: 5px 10px;
        font-size: 9px;
    }

    .header-title {
        font-size: 12px;
    }

    .logs-scroll-area {
        padding: 8px;
    }

    .log-card {
        padding: 12px;
    }

    .action-btn {
        font-size: 9px;
        padding: 8px 8px;
    }

    .sidebar-actions {
        grid-template-columns: 1fr;
    }
}