/* ── Spreadsheet Agent Preview Panel ─────────────────────────────────────── */

.nd-spreadsheet-preview {
    flex: 2;
    min-width: 480px;
    display: none;
    flex-direction: column;
    border-left: 1px solid rgba(255,255,255,0.06);
    background: #0d0d14;
    overflow: hidden;
}
.nd-spreadsheet-active .nd-spreadsheet-preview { display: flex !important; }
.nd-spreadsheet-active .nd-code-explorer       { display: none !important; }
.nd-spreadsheet-active .nd-code-chat-panel     { flex: 0 0 360px; min-width: 0; }
.nd-spreadsheet-active .nd-code-viewer         { display: none !important; }

.nd-ss-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Top bar */
.nd-ss-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    height: 42px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: relative;
    z-index: 10;
}
.nd-ss-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}
.nd-ss-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.6);
    flex-shrink: 0;
}
.nd-ss-title {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    line-height: 1.2;
}
.nd-ss-info {
    font-size: 10px;
    color: rgba(255,255,255,0.3);
}
.nd-ss-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.nd-ss-drive-btn,
.nd-ss-export-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.55);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}
.nd-ss-drive-btn:not([disabled]):hover,
.nd-ss-export-btn:not([disabled]):hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
    border-color: rgba(255,255,255,0.18);
}
.nd-ss-drive-btn[disabled],
.nd-ss-export-btn[disabled] { opacity: 0.35; cursor: not-allowed; }

/* Import button (topbar) */
.nd-ss-import-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.55);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}
.nd-ss-import-btn:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
    border-color: rgba(255,255,255,0.18);
}

/* Empty state */
.nd-ss-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
}
.nd-ss-empty[hidden] { display: none; }
.nd-ss-empty-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.2);
}
.nd-ss-empty-label {
    font-size: 12px;
    color: rgba(255,255,255,0.35);
    text-align: center;
    line-height: 1.6;
    margin: 0;
}
.nd-ss-empty-hint {
    font-size: 10px;
    color: rgba(255,255,255,0.15);
}
.nd-ss-suggestions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 400px;
    margin-top: 4px;
}
.nd-ss-suggestion {
    padding: 8px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: rgba(255,255,255,0.45);
    font-size: 11.5px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    line-height: 1.4;
    transition: all 0.15s;
}
.nd-ss-suggestion:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
}

/* Viewer */
.nd-ss-viewer {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Sheet tabs */
.nd-ss-sheet-tabs-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 12px;
    height: 36px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.nd-ss-sheet-tabs-wrap::-webkit-scrollbar { display: none; }
.nd-ss-sheet-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
}
.nd-ss-tab {
    padding: 4px 12px;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 5px;
    background: none;
    color: rgba(255,255,255,0.38);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.12s;
    white-space: nowrap;
}
.nd-ss-tab:hover { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.65); }
.nd-ss-tab--active {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
    border-color: rgba(255,255,255,0.15);
}

/* Formula bar */
.nd-ss-formula-bar {
    display: flex;
    align-items: center;
    height: 28px;
    background: #fff;
    border-bottom: 1px solid #dadce0;
    flex-shrink: 0;
    font-size: 12px;
    font-family: -apple-system, 'Inter', 'Segoe UI', sans-serif;
}
.nd-ss-formula-bar[hidden] { display: none; }
.nd-ss-cell-ref {
    min-width: 58px;
    width: 58px;
    text-align: center;
    color: #202124;
    font-weight: 600;
    font-size: 12px;
    border-right: 1px solid #dadce0;
    padding: 0 6px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
}
.nd-ss-fx-label {
    color: #5f6368;
    font-size: 13px;
    padding: 0 8px;
    font-family: Georgia, 'Times New Roman', serif;
    border-right: 1px solid #e8eaed;
    height: 100%;
    display: flex;
    align-items: center;
    user-select: none;
}
.nd-ss-formula-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 12px;
    font-family: 'SFMono-Regular', Consolas, 'Roboto Mono', monospace;
    color: #202124;
    padding: 0 10px;
    background: transparent;
    height: 100%;
}
.nd-ss-formula-input::placeholder { color: #bdc1c6; font-style: italic; font-family: -apple-system, sans-serif; }
.nd-ss-formula-input:focus { background: #f8f9fa; }

/* Selected cell */
.nd-ss-cell--selected {
    outline: 2px solid #1a73e8 !important;
    outline-offset: -2px;
    background: #e8f0fe !important;
    position: relative;
    z-index: 1;
}

/* Double-click hint */
.nd-ss-cell[data-addr] { cursor: pointer; }

/* Grid — Excel/white theme */
.nd-ss-grid-wrap {
    flex: 1;
    overflow: auto;
    padding: 0;
    background: #fff;
}
.nd-ss-grid-wrap[hidden],
.nd-ss-sheet-tabs-wrap[hidden] { display: none; }
.nd-ss-grid-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.nd-ss-grid-wrap::-webkit-scrollbar-track { background: #f1f3f4; }
.nd-ss-grid-wrap::-webkit-scrollbar-thumb { background: #bdc1c6; border-radius: 4px; }
.nd-ss-grid-wrap::-webkit-scrollbar-thumb:hover { background: #9aa0a6; }

.nd-ss-table {
    border-collapse: collapse;
    font-size: 12px;
    font-family: -apple-system, 'Inter', 'Segoe UI', sans-serif;
    width: max-content;
    min-width: 100%;
    background: #fff;
}

/* Column letter row */
.nd-ss-col-letter {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 4px 8px;
    background: #f8f9fa;
    border-bottom: 1px solid #dadce0;
    border-right: 1px solid #e8eaed;
    color: #5f6368;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    user-select: none;
}

/* Row number column */
.nd-ss-rownum-th {
    position: sticky;
    left: 0;
    top: 0;
    z-index: 4;
    width: 42px;
    min-width: 42px;
    background: #f8f9fa;
    border-right: 1px solid #dadce0;
    border-bottom: 1px solid #dadce0;
}
.nd-ss-rownum-th--header { z-index: 3; top: 25px; }
.nd-ss-rownum {
    position: sticky;
    left: 0;
    z-index: 2;
    padding: 5px 8px;
    background: #f8f9fa;
    border-right: 1px solid #dadce0;
    border-bottom: 1px solid #e8eaed;
    color: #80868b;
    font-size: 10px;
    text-align: right;
    user-select: none;
    min-width: 42px;
}

/* Header row (column names) */
.nd-ss-header-cell {
    position: sticky;
    top: 25px;
    z-index: 3;
    padding: 6px 10px;
    background: #e8f0fe;
    border-bottom: 2px solid #aecbfa;
    border-right: 1px solid #dadce0;
    color: #1a73e8;
    font-weight: 600;
    font-size: 11px;
    white-space: nowrap;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Data cells */
.nd-ss-cell {
    padding: 5px 10px;
    border-bottom: 1px solid #e8eaed;
    border-right: 1px solid #e8eaed;
    color: #202124;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
    background: #fff;
}
.nd-ss-cell--num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.nd-ss-cell--computed { color: #1967d2; }
.nd-ss-cell-error { color: #d93025; font-style: italic; font-size: 11px; }
.nd-ss-row-alt .nd-ss-cell  { background: #f8f9fa; }
.nd-ss-row-alt .nd-ss-rownum { background: #f1f3f4; }
tr:hover .nd-ss-cell   { background: #e8f0fe !important; }
tr:hover .nd-ss-rownum { background: #d2e3fc !important; color: #1a73e8; }
