/* Paki Sheets — app chrome */
.paki-app {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    background:
        radial-gradient(900px 420px at -10% -20%, rgba(0, 155, 77, 0.10), transparent 55%),
        radial-gradient(700px 380px at 110% 0%, rgba(0, 194, 97, 0.08), transparent 50%),
        #f4faf6;
}

.paki-app.dark,
.dark.paki-app,
html.dark .paki-app {
    background: #0b1510;
}

.app-header {
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(12, 31, 22, 0.08);
}

.dark .app-header {
    background: rgba(19, 32, 24, 0.88);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.logo-link {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(180deg, #eafff3, #e7f8ee);
    box-shadow: 0 8px 18px -12px rgba(0, 155, 77, 0.7);
    flex-shrink: 0;
}

.dark .logo-link {
    background: #1a2e22;
}

.icon-btn {
    padding: 8px;
    border-radius: 10px;
    color: #3d5247;
    background: #fff;
    border: 1px solid rgba(12, 31, 22, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}

.user-chip-wrap { position: relative; }
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid rgba(12, 31, 22, 0.08);
    font-weight: 700;
    font-size: 13px;
    color: #163325;
    transition: transform .15s, box-shadow .15s;
}
.user-chip:hover { transform: translateY(-1px); box-shadow: 0 8px 18px -12px rgba(0,155,77,.6); }
.user-avatar, .user-fallback {
    width: 28px; height: 28px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
}
.user-fallback {
    display: grid; place-items: center;
    background: linear-gradient(180deg, #00c261, #009B4D);
    color: #fff; font-size: 11px; font-weight: 800;
}
.user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: 220px; background: #fff; border-radius: 14px;
    box-shadow: 0 18px 40px -18px rgba(12,31,22,.4);
    border: 1px solid rgba(12,31,22,.08);
    padding: 8px; z-index: 80;
}
.user-drop-head {
    padding: 10px 12px 8px; border-bottom: 1px solid rgba(12,31,22,.06); margin-bottom: 4px;
}
.user-drop-head strong { display: block; font-size: 13px; }
.user-drop-head span { font-size: 11px; color: #8aa194; font-weight: 600; }
.user-dropdown a {
    display: block; padding: 8px 12px; border-radius: 10px;
    font-size: 13px; font-weight: 600; color: #163325;
}
.user-dropdown a:hover { background: #e8f8ef; color: #009B4D; }
.signin-chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 12px 6px 6px; border-radius: 999px;
    background: linear-gradient(180deg, #00c261, #009B4D);
    color: #fff; font-weight: 800; font-size: 13px;
    box-shadow: 0 8px 18px -10px rgba(0,155,77,.7);
    transition: transform .15s;
}
.signin-chip:hover { transform: translateY(-1px); }
.signin-chip img {
    width: 22px; height: 22px; object-fit: contain;
    background: #fff; border-radius: 50%; padding: 2px;
}
.dark .user-chip, .dark .user-dropdown { background: #1a2e22; color: #e8f8ef; border-color: rgba(255,255,255,.08); }
.dark .user-dropdown a { color: #e8f8ef; }
.dark .user-dropdown a:hover { background: #244233; }
.dark .user-drop-head { border-bottom-color: rgba(255,255,255,.08); }

.icon-btn:hover {
    color: #009B4D;
    transform: translateY(-1px);
}

.dark .icon-btn {
    background: #1a2e22;
    color: #cfe5d8;
    border-color: rgba(255, 255, 255, 0.08);
}

.toolbar {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(12, 31, 22, 0.06);
}

.dark .toolbar {
    background: rgba(19, 32, 24, 0.8);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.toolbar-btn {
    padding: 6px;
    border-radius: 8px;
    color: #4a5568;
    background-color: transparent;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border: 1px solid transparent;
}

.toolbar-btn:hover {
    background: #e7f8ee;
    color: #009B4D;
}

.toolbar-btn:active,
.toolbar-btn.active {
    background: #009B4D;
    color: #fff;
    box-shadow: 0 6px 14px -8px rgba(0, 155, 77, 0.8);
}

.dark .toolbar-btn {
    background-color: transparent;
    box-shadow: none;
    color: #cbd5e0;
}

.dark .toolbar-btn:hover {
    background-color: #1f3328;
    color: #7dffb8;
}

.dark .toolbar-btn:active,
.dark .toolbar-btn.active {
    background-color: #009B4D;
    color: #fff;
}

.formula-bar {
    background: #fff;
    border-bottom: 1px solid #e6eee9;
}

.dark .formula-bar {
    background: #132018;
    border-bottom-color: #24362c;
}

.cell-chip {
    min-width: 42px;
    text-align: center;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: #00753a;
    background: #e7f8ee;
    border-radius: 8px;
    padding: 4px 8px;
}

.dark .cell-chip {
    background: #1a2e22;
    color: #7dffb8;
}

.fx-label {
    font-weight: 800;
    font-style: italic;
    color: #009B4D;
    margin-right: 8px;
    font-family: ui-serif, Georgia, serif;
}

.sheet-tabs {
    background: #f3f7f4;
    border-top: 1px solid #e6eee9;
}

.dark .sheet-tabs {
    background: #132018;
    border-top-color: #24362c;
}

#spreadsheet th,
#spreadsheet td {
    border: 1px solid #e2e8f0;
    padding: 0;
    margin: 0;
    min-width: 88px;
    height: 26px;
    white-space: nowrap;
    position: relative;
    user-select: none;
    color: #2d3748;
}

.dark #spreadsheet th,
.dark #spreadsheet td {
    border-color: #2a3d33;
    color: #e2e8f0;
}

#spreadsheet th {
    background-color: #f4f7f5;
    color: #718096;
    font-weight: 600;
    text-align: center;
    user-select: none;
    height: 28px;
    font-size: 11px;
    letter-spacing: 0.04em;
}

.dark #spreadsheet th {
    background-color: #1a2e22;
    color: #a0aec0;
}

#spreadsheet td {
    background-color: #ffffff;
    cursor: cell;
}

.dark #spreadsheet td {
    background-color: #0f1b14;
}

.cell-input {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    background: transparent;
    padding: 0 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: cell;
}

.cell-input:focus {
    cursor: text;
}

#spreadsheet td.selected {
    outline: 2px solid #009B4D;
    outline-offset: -2px;
    z-index: 2;
    position: relative;
    box-shadow: 0 0 0 4px rgba(0, 155, 77, 0.12);
}

th.selected-header {
    background-color: rgba(0, 155, 77, 0.14) !important;
    color: #009B4D !important;
}

td.in-range {
    background-color: rgba(0, 155, 77, 0.08);
}

.sheet-tab {
    padding: 5px 16px;
    border-radius: 8px;
    font-size: 13px;
    color: #718096;
    background: transparent;
    transition: all 0.2s;
    border: 1px solid transparent;
    font-weight: 600;
}

.sheet-tab:hover {
    background: rgba(0, 155, 77, 0.08);
    color: #009B4D;
}

.sheet-tab.active {
    background: #ffffff;
    color: #009B4D;
    font-weight: 700;
    box-shadow: 0 4px 10px -6px rgba(12, 31, 22, 0.35);
    border-color: rgba(0, 155, 77, 0.18);
}

.dark .sheet-tab.active {
    background: #1a2e22;
    box-shadow: none;
}

.modal-card {
    box-shadow: 0 30px 80px -28px rgba(12, 31, 22, 0.55);
    border: 1px solid rgba(12, 31, 22, 0.06);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.fade-in {
    animation: fadeIn 0.28s ease-out;
}

#grid-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

#grid-container::-webkit-scrollbar-thumb {
    background: #c5d6cb;
    border-radius: 99px;
}

.dark #grid-container::-webkit-scrollbar-thumb {
    background: #2a3d33;
}

@media (max-width: 640px) {
    #spreadsheet th,
    #spreadsheet td {
        min-width: 72px;
    }
}
