:root {
    /* Minimalist Black & White Ecosystem Palette */
    --primary: #000000;
    --primary-hover: #333333;
    --bg-color: #f3f4f6;
    --surface: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --cell-border: #d1d5db;
    --cell-bg: #ffffff;
    --cell-selected: rgba(0, 0, 0, 0.12);
    --cell-selected-border: #000000;
    --header-bg: #f9fafb;
    --radius-md: 6px;
    --radius-lg: 10px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- VIEW CONTROLLER --- */
.view-section {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
}

.view-section.active {
    display: flex;
}

/* =========================================
           DASHBOARD VIEW (PROJECTS PAGE)
           ========================================= */
#dashboard-view {
    overflow-y: auto;
    background-color: #fafafa;
    padding: 0;
    display: none;
    flex-direction: column;
    min-height: 100vh;
}

#dashboard-view.active {
    display: flex;
}

.dash-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.dash-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.02em;
}

.dash-search-container {
    flex: 1;
    max-width: 400px;
    margin: 0 24px;
    position: relative;
}

.dash-search-container svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.dash-search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--surface);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.dash-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.dash-nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e4e4e7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.dashboard-container {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 40px 32px;
}

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.dash-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #000;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.dash-footer {
    padding: 24px 32px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
    background: var(--surface);
    margin-top: auto;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--surface);
    padding: 24px;
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.12), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(20px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.new-project-modal-content {
    max-width: 480px;
    padding: 24px;
    border-radius: 20px;
}

.modal-top-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.modal-title-wrap {
    flex: 1;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.modal-subtitle {
    font-size: 0.84rem;
    color: #64748b;
    margin-top: 3px;
    font-weight: 400;
    line-height: 1.4;
}

.modal-close-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.modal-close-icon-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

.modal-segmented-control {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 20px;
    gap: 4px;
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.modal-tab-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-tab-btn:hover {
    color: #0f172a;
}

.modal-tab-btn.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.modal-tab-panel {
    display: none;
    animation: fadeIn 0.2s ease;
}

.modal-tab-panel.active {
    display: block;
}

.modal-field-group {
    margin-bottom: 24px;
}

.modal-field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}

.modal-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.modal-input-icon {
    position: absolute;
    left: 14px;
    color: #94a3b8;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.modal-input-styled {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border-radius: 12px;
    border: 1.5px solid #e2e8f0;
    font-size: 0.95rem;
    font-weight: 500;
    color: #0f172a;
    background: #ffffff;
    outline: none;
    transition: all 0.2s ease;
}

.modal-input-styled:focus {
    border-color: #0f172a;
    box-shadow: 0 0 0 3.5px rgba(15, 23, 42, 0.06);
}

.file-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 30px 16px;
    text-align: center;
    background: #fafbfc;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.file-dropzone:hover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.03);
    transform: translateY(-1px);
}

.file-dropzone.dragover {
    border-color: #059669;
    background: rgba(16, 185, 129, 0.08);
    transform: scale(1.02);
}

.dropzone-badge {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    box-shadow: 0 8px 16px -4px rgba(16, 185, 129, 0.35);
    transition: transform 0.2s;
}

.file-dropzone:hover .dropzone-badge {
    transform: scale(1.05);
}

.dropzone-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 4px;
}

.dropzone-desc {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 12px;
}

.dropzone-formats {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.format-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: #64748b;
    font-weight: 600;
    border-radius: 10px;
    padding: 9px 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ghost:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.btn-modal-submit {
    padding: 9px 20px;
    font-weight: 600;
    border-radius: 10px;
    background: #0f172a;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-modal-submit:hover {
    background: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.project-card {
    background: var(--surface);
    border: 1px solid #e4e4e7;
    border-radius: 14px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 180px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.project-card:hover {
    border-color: #000;
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.08);
    transform: translateY(-4px);
}

.project-card:active {
    transform: scale(0.98);
    box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.1);
}

.project-card.new-project {
    border: 1.5px dashed #d4d4d8;
    background: transparent;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #52525b;
    box-shadow: none;
}

.project-card.new-project:hover {
    border-color: #000;
    color: #000;
    background: #fff;
}

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: auto;
}

.project-icon {
    width: 48px;
    height: 48px;
    background: #f4f4f5;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
}

.project-info {
    margin-top: 24px;
}

.project-title {
    font-weight: 600;
    font-size: 1.15rem;
    color: #09090b;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-meta {
    font-size: 0.85rem;
    color: #71717a;
    font-weight: 400;
}

.project-delete-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #a1a1aa;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 2;
}

.project-card:hover .project-delete-btn {
    color: #52525b;
}

.project-delete-btn:hover {
    background: #fee2e2 !important;
    color: #ef4444 !important;
}

/* =========================================
           SPREADSHEET VIEW
           ========================================= */
.app-header {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    flex-shrink: 0;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.btn-back,
.back-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #334155;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-back:hover,
.back-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
}

.btn-back:active,
.back-btn:active {
    transform: scale(0.94);
}

.project-title-container {
    display: flex;
    align-items: center;
}

.project-name-input {
    font-weight: 600;
    font-size: 1.02rem;
    color: #0f172a;
    border: 1.5px solid transparent;
    background: transparent;
    padding: 6px 10px;
    border-radius: 10px;
    outline: none;
    transition: all 0.2s;
    width: auto;
    min-width: 150px;
    max-width: 280px;
}

.project-name-input:hover {
    border-color: #e2e8f0;
    background: #f8fafc;
}

.project-name-input:focus {
    border-color: #0f172a;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.05);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 0;
}

.toolbar::-webkit-scrollbar {
    height: 3px;
}

.toolbar::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

/* Glass & Soft Toolbar Group */
.toolbar-group {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 3px 4px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.toolbar-text-btn {
    border: none;
    background: transparent;
    color: #475569;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.toolbar-text-btn:hover {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transform: translateY(-0.5px);
}

.toolbar-text-btn:active {
    transform: scale(0.95);
}

.color-indicator-pill {
    position: absolute;
    bottom: 3px;
    left: 6px;
    right: 6px;
    height: 3.5px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.btn-export-header {
    background: #0f172a !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 11px !important;
    padding: 7px 16px !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.btn-export-header:hover {
    background: #1e293b !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25) !important;
}

.btn-export-header:active {
    transform: scale(0.96) !important;
}

.toolbar::-webkit-scrollbar {
    height: 4px;
}

.toolbar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.btn {
    background: var(--surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.btn svg {
    pointer-events: none;
}

.btn:hover {
    background: var(--header-bg);
    border-color: var(--text-muted);
}

.btn:active {
    transform: scale(0.95);
}

.btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn.primary:hover {
    background: var(--primary-hover);
}

.formula-bar-container {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    flex-shrink: 0;
}

.cell-address-display {
    background: var(--header-bg);
    padding: 4px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 60px;
    text-align: center;
}

.formula-input {
    flex: 1;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.formula-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.spreadsheet-container {
    flex: 1;
    overflow: auto;
    background: var(--bg-color);
    position: relative;
    min-height: 0;
    min-width: 0;
}

table {
    border-collapse: collapse;
    table-layout: fixed;
    width: max-content;
    min-width: 100%;
    user-select: none;
}

th,
td {
    border: 1px solid var(--cell-border);
    padding: 0;
    margin: 0;
    background: var(--cell-bg);
    position: relative;
}

th {
    background: var(--header-bg);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    text-align: center;
    vertical-align: middle;
}

th.header-active {
    background: #e0e7ff !important;
    color: #3730a3 !important;
    font-weight: 700 !important;
}

thead th:hover,
tbody th:hover {
    background: #f1f5f9;
    cursor: pointer;
}

.selection-fill-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #2563eb;
    border: 1.5px solid #ffffff;
    border-radius: 1.5px;
    cursor: crosshair;
    z-index: 50;
    display: none;
    pointer-events: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.selection-fill-handle.active {
    display: block;
}

.cell-fill-preview {
    outline: 1.5px dashed #2563eb !important;
    background-color: rgba(219, 234, 254, 0.4) !important;
}

.resizer-col {
    position: absolute;
    top: 0;
    right: -4px;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 20;
    transition: background 0.2s;
}

.resizer-row {
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 8px;
    cursor: row-resize;
    z-index: 20;
    transition: background 0.2s;
}

.resizer-col:hover,
.resizer-row:hover,
.resizer-col.active,
.resizer-row.active {
    background: var(--primary);
    opacity: 0.3;
}

td .cell-content {
    width: 100%;
    height: 100%;
    padding: 4px 6px;
    outline: none;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

td.selected {
    box-shadow: inset 0 0 0 2px var(--cell-selected-border);
    z-index: 2;
}

td.in-selection {
    box-shadow: inset 0 0 0 9999px var(--cell-selected);
}

td.editing .cell-content {
    white-space: pre-wrap;
    overflow: visible;
    background: white;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 0 0 2px var(--cell-selected-border);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: auto;
    min-height: 100%;
    z-index: 21;
    border-radius: 2px;
    user-select: text;
    cursor: text;
}

/* --- FORMATTING POPUP --- */
.format-popup {
    position: fixed;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 14px;
    box-shadow: 0 16px 32px -6px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.03);
    padding: 5px;
    display: flex;
    align-items: center;
    gap: 3px;
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(0.96);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.format-popup.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.fmt-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #475569;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.fmt-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    transform: translateY(-0.5px);
}

.fmt-btn:active {
    transform: scale(0.92);
}

.fmt-btn.active {
    background: #0f172a;
    color: #ffffff;
}

.fmt-btn svg {
    width: 17px;
    height: 17px;
    pointer-events: none;
}

.fmt-divider {
    width: 1px;
    height: 20px;
    background: #e2e8f0;
    margin: 0 4px;
}

/* --- DROPDOWN MENUS --- */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    min-width: 180px;
    max-width: calc(100vw - 32px);
    z-index: 1000;
    padding: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dropdown-menu.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.1s;
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: #000;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.menu-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.border-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}

.border-grid .fmt-btn {
    width: 100%;
    height: 32px;
    border: 1px solid var(--border-color);
    background: var(--surface);
}

.border-grid .fmt-btn:hover {
    border-color: var(--primary);
    background: var(--bg-color);
}

.border-style-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
    margin-bottom: 16px;
}

.border-style-btn {
    padding: 6px 0;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--surface);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.border-style-btn:hover {
    background: var(--bg-color);
}

.border-style-btn.active {
    border-color: var(--primary);
    background: var(--header-bg);
    font-weight: 600;
}

.toolbar-dropdown-btn {
    position: relative;
    background: transparent;
    border: 1px solid transparent;
    color: #475569;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.toolbar-dropdown-btn:hover {
    background: #ffffff;
    color: #0f172a;
    border-color: rgba(226, 232, 240, 0.8);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transform: translateY(-0.5px);
}

.toolbar-dropdown-btn:active {
    transform: scale(0.92);
}

.toolbar-dropdown-btn svg {
    pointer-events: none;
    color: inherit;
    width: 17px;
    height: 17px;
}

.zoom-toolbar {
    display: flex;
    align-items: center;
    gap: 0;
    background: #f8fafc;
    padding: 2px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.zoom-toolbar .zoom-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    color: #64748b;
}

.zoom-toolbar .zoom-btn:hover {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.zoom-toolbar .zoom-btn:active {
    transform: scale(0.92);
}

.zoom-value {
    font-size: 0.78rem;
    font-weight: 700;
    color: #0f172a;
    min-width: 48px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.zoom-value:hover {
    background: #ffffff;
    color: #0f172a;
}

#spreadsheet-scaler {
    transform-origin: 0 0;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    width: max-content;
    height: max-content;
    display: block;
}

/* --- SHEET TABS --- */
.sheet-tabs-bar {
    height: 42px;
    min-height: 42px;
    flex-shrink: 0;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 8px;
    overflow-x: auto;
}

.sheet-tabs-bar::-webkit-scrollbar {
    height: 3px;
}

.sheet-tabs-bar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.sheet-tabs-list {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sheet-tab {
    padding: 6px 14px;
    font-size: 0.84rem;
    font-weight: 500;
    color: #64748b;
    background: transparent;
    border-radius: 9px;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.sheet-tab:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #0f172a;
}

.sheet-tab.active {
    background: #ffffff;
    color: #0f172a;
    font-weight: 600;
    border-color: #e2e8f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.delete-sheet-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 2px;
}

.delete-sheet-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

.add-sheet-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    cursor: pointer;
    color: #475569;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.add-sheet-btn:hover {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
}

.add-sheet-btn:active {
    transform: scale(0.92);
}

.hidden {
    display: none;
}

#global-file-input {
    display: none;
}

/* --- LOADING OVERLAY --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color, #e4e4e7);
    border-top-color: var(--primary, #000);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

.loading-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main, #111827);
}

/* =========================================
   MOBILE RESPONSIVENESS
   ========================================= */
@media (max-width: 768px) {

    /* Dashboard adjustments */
    .dash-navbar {
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 12px;
    }

    .dash-logo {
        flex: 1 1 auto;
        font-size: 1.1rem;
    }

    .dash-nav-actions {
        flex: 1 1 auto;
        justify-content: flex-end;
    }

    .dash-nav-actions .btn span {
        display: none;
        /* Icon only on mobile */
    }

    .dash-nav-actions .btn {
        padding: 8px;
    }

    .dash-search-container {
        flex: 1 1 100%;
        margin: 0;
        max-width: none;
        order: 3;
        /* Move below navbar items */
    }

    .dashboard-container {
        padding: 20px 16px;
    }

    .project-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .modal-content {
        width: 90%;
        max-width: none;
        margin: 0 16px;
    }

    /* Spreadsheet Header */
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 12px;
        gap: 8px;
    }

    .header-left {
        width: 100%;
    }

    .project-name-input {
        width: 100%;
        font-size: 1rem;
    }

    .toolbar {
        width: 100%;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll on iOS */
    }

    .toolbar>* {
        flex-shrink: 0;
    }

    .toolbar .btn span {
        display: none;
        /* Icon only for toolbar on mobile */
    }

    .toolbar .btn {
        padding: 6px 8px;
    }

    .toolbar-dropdown-btn {
        min-width: 32px;
    }

    /* Formula Bar */
    .formula-bar-container {
        padding: 8px 12px;
        gap: 8px;
    }

    .cell-address-display {
        min-width: 44px;
        padding: 4px;
        font-size: 0.8rem;
    }

    .formula-input {
        font-size: 16px;
        /* Prevents auto-zoom on iOS */
        padding: 6px 8px;
    }

    /* Spreadsheet Area */
    .spreadsheet-container {
        /* Prevents browser-default pinch-zoom and pull-to-refresh on the spreadsheet itself */
        touch-action: pan-x pan-y;
        -webkit-overflow-scrolling: touch;
    }

    .sheet-tabs-bar {
        padding: 0 12px;
    }

    /* Larger Touch Targets for Resizers */
    .resizer-col {
        width: 30px;
        right: -15px;
    }

    .resizer-row {
        height: 30px;
        bottom: -15px;
    }

    /* Format Popup - More touch friendly */
    .format-popup {
        max-width: 90vw;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 10px;
        gap: 8px;
        border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    }

    .fmt-btn {
        width: 42px;
        height: 42px;
        flex-shrink: 0;
        background: #f8fafc;
        border-radius: 8px;
    }

    /* Add tap feedback */
    .btn:active, .fmt-btn:active, .sheet-tab:active, .project-card:active {
        transform: scale(0.96);
        background-color: var(--header-bg);
    }

    /* Refine Toolbar */
    .toolbar {
        padding: 4px 0;
        gap: 6px;
    }

    .zoom-toolbar {
        display: none !important; /* Hide zoom buttons on mobile as pinch is used */
    }

    .formula-bar-container {
        padding: 6px 12px;
    }

    .project-delete-btn {
        width: 44px;
        height: 44px;
        color: #ef4444; /* Show explicit delete color on mobile */
        opacity: 0.8;
    }
}

/* Custom Scrollbar for Spreadsheet */
.spreadsheet-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

.spreadsheet-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.spreadsheet-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Prominent Import Button */
.btn-import {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    transition: all 0.2s ease !important;
}

.btn-import:hover {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25) !important;
    transform: translateY(-1px);
}

.btn-import:active {
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1) !important;
}

/* Sync Status Button & Indicator (Standard Spac2 Ecosystem) */
.sync-status-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.04);
    border: 1.5px solid rgba(0, 0, 0, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    padding: 0;
    flex-shrink: 0;
}

.sync-status-btn svg {
    width: 20px;
    height: 20px;
    transition: all 0.2s ease;
}

.sync-status-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.22);
    transform: translateY(-1px);
}

.sync-status-btn:active {
    transform: translateY(1px);
}

.sync-status-btn.synced {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.08);
}

.sync-status-btn.syncing {
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.08);
}

.sync-status-btn.dirty {
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.08);
}

.sync-status-btn.offline {
    color: #94a3b8;
    border-color: rgba(148, 163, 184, 0.2);
}

.sync-status-btn .spin {
    animation: spin 1.2s linear infinite;
}

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

.sync-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.3s ease;
    cursor: pointer;
    vertical-align: middle;
}

.sync-status-icon svg {
    transition: transform 0.3s ease;
}

.sync-status-icon.syncing svg {
    animation: spin 1.2s linear infinite;
    color: var(--primary);
}

.sync-status-icon.synced svg {
    color: #10b981;
}

.sync-status-icon.offline svg {
    color: #f59e0b;
}

/* ================= STANDARDIZED SPAC2 BRAND HEADER ================= */
.header-brand-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.btn-back {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.04);
    border: 1.5px solid rgba(0, 0, 0, 0.22);
    color: #0f172a;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 18px;
    padding: 0;
    box-sizing: border-box;
}

.btn-back i,
.btn-back svg {
    color: inherit;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-back:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #000000;
    transform: translateX(-2px);
    border-color: rgba(0, 0, 0, 0.45);
}

.btn-back:active {
    transform: scale(0.92);
    background: rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.55);
    opacity: 0.85;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.brand-link:hover {
    opacity: 0.92;
}

.brand-logo-card {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    padding: 3.5px;
    box-sizing: border-box;
    transition: transform 0.2s ease;
}

.brand-link:hover .brand-logo-card {
    transform: scale(1.04);
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
    display: block;
}

.brand-text {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    line-height: 1;
    white-space: nowrap;
}

.brand-name {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    font-weight: 800;
    font-size: 19px;
    color: #0f172a;
    letter-spacing: -0.025em;
    line-height: 1;
}

.brand-divider {
    font-size: 14px;
    font-weight: 300;
    color: #94a3b8;
    opacity: 0.7;
    user-select: none;
}

.brand-app {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    letter-spacing: -0.01em;
    line-height: 1;
}

@media (max-width: 640px) {
    .dash-navbar {
        padding: 12px 16px;
        gap: 12px;
    }

    .btn-back {
        width: 34px;
        height: 34px;
        border-radius: 10px;
        font-size: 16px;
    }

    .brand-logo-card {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        padding: 3px;
    }

    .brand-name {
        font-size: 17px;
    }

    .brand-divider {
        font-size: 13px;
    }
}

/* =========================================
   COLUMN & ROW RESIZERS
   ========================================= */
.resizer-col {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 10;
}

.resizer-col:hover,
.resizer-col.active {
    background-color: #3b82f6;
}

.resizer-row {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    cursor: row-resize;
    user-select: none;
    z-index: 10;
}

.resizer-row:hover,
.resizer-row.active {
    background-color: #3b82f6;
}

thead th,
tbody th {
    position: relative;
}

/* =========================================
   FIND & REPLACE FLOATING BAR
   ========================================= */
.find-replace-bar {
    position: absolute;
    top: 54px;
    right: 20px;
    z-index: 500;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.02);
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 8px;
    min-width: 320px;
    animation: fadeInDown 0.2s ease;
}

.find-replace-bar.active {
    display: flex;
}

.find-row,
.replace-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.find-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.find-search-icon {
    position: absolute;
    left: 10px;
    color: #94a3b8;
    pointer-events: none;
}

.find-input-wrap input {
    width: 100%;
    padding: 7px 54px 7px 32px;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    font-size: 0.86rem;
    color: #0f172a;
    background: #f8fafc;
    outline: none;
    transition: all 0.2s;
}

.find-input-wrap input:focus {
    background: #ffffff;
    border-color: #0f172a;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.05);
}

.replace-row .find-input-wrap input {
    padding: 7px 12px;
}

.find-match-count {
    position: absolute;
    right: 8px;
    font-size: 0.74rem;
    font-weight: 600;
    color: #64748b;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 6px;
}

.find-btn {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: transparent;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.find-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.find-btn.active {
    background: #e2e8f0;
    color: #0f172a;
}

.find-text-btn {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.find-text-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

.cell-find-highlight {
    background-color: rgba(254, 240, 138, 0.6) !important;
}

.cell-find-active {
    background-color: rgba(134, 239, 172, 0.8) !important;
    outline: 2px solid #16a34a !important;
    outline-offset: -2px;
}

/* =========================================
   CUSTOM CONTEXT MENU
   ========================================= */
.custom-context-menu {
    position: fixed;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 14px;
    box-shadow: 0 16px 36px -6px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.02);
    padding: 6px;
    min-width: 210px;
    display: none;
    flex-direction: column;
    gap: 2px;
    animation: fadeInScale 0.15s ease;
}

.custom-context-menu.active {
    display: flex;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
}

.context-menu-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.context-menu-item.danger:hover {
    background: #fee2e2;
    color: #ef4444;
}

.context-menu-item.danger:hover svg {
    color: #ef4444;
}

.context-shortcut {
    margin-left: auto;
    font-size: 0.74rem;
    font-weight: 600;
    color: #94a3b8;
}

.context-menu-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 4px 0;
}

/* =========================================
   KEYBOARD SHORTCUTS MODAL
   ========================================= */
.shortcuts-modal-content {
    max-width: 580px;
    padding: 24px;
    border-radius: 20px;
}

.shortcuts-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 4px;
}

.shortcut-category {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
}

.shortcut-cat-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #edf2f7;
}

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

.shortcut-desc {
    font-size: 0.84rem;
    color: #475569;
}

.kbd-pill {
    font-size: 0.76rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace, sans-serif;
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 3px 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* =========================================
   EXPORT MODAL STYLING
   ========================================= */
.export-modal-content {
    max-width: 480px;
    padding: 24px;
    border-radius: 20px;
}

.modal-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.modal-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.modal-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.modal-input-icon {
    position: absolute;
    left: 14px;
    color: #94a3b8;
    pointer-events: none;
}

.modal-input-wrap .modal-input {
    padding-left: 40px;
    margin-bottom: 0;
}

.export-format-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.export-format-card {
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    background: #f8fafc;
}

.export-format-card:hover {
    border-color: #cbd5e1;
    background: #ffffff;
    transform: translateY(-1px);
}

.export-format-card.active {
    border-color: #0f172a;
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.format-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.format-card-icon.xlsx {
    background: #dcfce7;
    color: #16a34a;
}

.format-card-icon.csv {
    background: #e0f2fe;
    color: #0284c7;
}

.format-card-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
}

.format-card-desc {
    font-size: 0.73rem;
    color: #64748b;
    margin-top: 2px;
}

.export-scope-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.export-scope-option {
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8fafc;
}

.export-scope-option:hover {
    border-color: #cbd5e1;
    background: #ffffff;
}

.export-scope-option.active {
    border-color: #0f172a;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.scope-radio-circle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.export-scope-option.active .scope-radio-circle {
    border-color: #0f172a;
    background: #0f172a;
    box-shadow: inset 0 0 0 3px #ffffff;
}

.scope-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #0f172a;
}

.scope-desc {
    font-size: 0.75rem;
    color: #64748b;
}

.btn-secondary-modal {
    padding: 10px 18px;
    border-radius: 11px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary-modal:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.btn-primary-modal {
    padding: 10px 22px;
    border-radius: 11px;
    background: #0f172a;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

.btn-primary-modal:hover {
    background: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
}

/* =========================================
   COMPREHENSIVE MOBILE & TABLET OPTIMIZATION
   ========================================= */

/* Sticky Headers for Spreadsheet Grid */
#sheet-head th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc;
}

#sheet-head tr th:first-child {
    z-index: 30;
    left: 0;
}

#sheet-body th {
    position: sticky;
    left: 0;
    z-index: 5;
    background: #f8fafc;
}

/* Tablet & Mobile Layout (< 860px) */
@media (max-width: 860px) {
    /* --- Dashboard Mobile --- */
    .dash-navbar {
        padding: 10px 14px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .header-brand-group {
        gap: 8px;
    }

    .brand-name, .brand-divider {
        display: inline-block;
    }

    .dash-search-container {
        order: 3;
        width: 100%;
        max-width: 100%;
        margin: 6px 0 0 0;
    }

    .dash-search-input {
        padding: 8px 14px 8px 36px;
        font-size: 16px; /* Prevents iOS auto-zoom */
        border-radius: 10px;
    }

    .dash-nav-actions {
        gap: 8px;
    }

    .btn-import {
        padding: 7px 10px !important;
        font-size: 0.8rem !important;
        border-radius: 10px !important;
    }

    .dashboard-container {
        padding: 16px 12px 32px 12px;
    }

    .dash-header {
        margin-bottom: 16px;
    }

    .dash-title {
        font-size: 1.25rem;
    }

    .project-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .project-card {
        padding: 12px;
        border-radius: 14px;
    }

    .project-card.new-project {
        min-height: 120px;
        padding: 16px 12px;
    }

    .project-card.new-project span {
        font-size: 0.88rem !important;
    }

    .project-title {
        font-size: 0.9rem;
    }

    .project-meta {
        font-size: 0.75rem;
    }

    /* --- Spreadsheet View Mobile --- */
    .app-header {
        flex-direction: column;
        align-items: stretch;
        padding: 6px 10px;
        gap: 6px;
    }

    .header-left {
        width: 100%;
        justify-content: space-between;
        gap: 6px;
    }

    .project-title-container {
        flex: 1;
        min-width: 0;
    }

    .project-name-input {
        width: 100%;
        max-width: 100%;
        font-size: 0.95rem;
        padding: 5px 8px;
    }

    .toolbar {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 4px 0 2px 0;
        gap: 6px;
    }

    .toolbar::-webkit-scrollbar {
        display: none;
    }

    .toolbar-group {
        flex-shrink: 0;
        padding: 2px 3px;
        border-radius: 10px;
    }

    .toolbar-dropdown-btn {
        width: 34px;
        height: 34px;
        border-radius: 8px;
    }

    .toolbar-text-btn {
        padding: 5px 8px;
        font-size: 0.78rem;
    }

    .zoom-toolbar {
        flex-shrink: 0;
    }

    .btn-export-header {
        flex-shrink: 0;
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
        border-radius: 9px !important;
    }

    .formula-bar-container {
        padding: 6px 10px;
        gap: 8px;
    }

    .cell-address-display {
        min-width: 48px;
        padding: 3px 6px;
        font-size: 0.8rem;
    }

    .formula-input {
        font-size: 16px; /* Prevents iOS auto-zoom */
        padding: 5px 8px;
    }

    .sheet-tabs-bar {
        padding: 4px 8px;
        padding-bottom: max(6px, env(safe-area-inset-bottom));
        gap: 4px;
    }

    .sheet-tab {
        padding: 6px 12px;
        font-size: 0.8rem;
        border-radius: 8px;
    }

    /* Modal Responsive on Mobile */
    .modal-content,
    .new-project-modal-content,
    .export-modal-content,
    .shortcuts-modal-content {
        max-width: calc(100vw - 24px);
        margin: 12px;
        padding: 18px 16px;
        border-radius: 18px;
        max-height: 88vh;
    }

    .modal-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .modal-actions button,
    .modal-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 11px;
    }

    .export-format-grid {
        grid-template-columns: 1fr;
    }

    .find-replace-bar {
        left: 10px;
        right: 10px;
        top: 90px;
        padding: 8px 10px;
    }

    .format-popup {
        max-width: calc(100vw - 20px);
        left: 10px !important;
        padding: 4px;
        overflow-x: auto;
    }
}

/* Extra Small Phones (< 480px) */
@media (max-width: 480px) {
    .btn-import span {
        display: none;
    }

    .btn-import {
        padding: 7px 10px !important;
    }

    .brand-name {
        font-size: 1rem;
    }

    .brand-app {
        font-size: 0.95rem;
    }

    .project-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .project-card {
        padding: 10px;
    }

    .project-icon {
        width: 32px;
        height: 32px;
    }

    .project-icon svg {
        width: 18px;
        height: 18px;
    }
}