/* =========================
   BASE
========================= */
body {
  background: #f8f9fa;
  font-family: 'Roboto', Arial, sans-serif;
  font-size: 13px;
  margin: 0;
  height: 100vh;
  overflow: hidden; /* controlled by workspace */
}

/* =========================
   TOP NAVBAR
========================= */
.top-navbar {
  height: 52px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: #202124;
}

.sheet-title {
  font-size: 14px;
}

.nav-center {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #188038;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34a853;
}

.nav-right {
  display: flex;
  align-items: center;
}

/* =========================
   TOOLBAR (COMPACT)
========================= */
.compact-toolbar {
  height: 40px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
}

.compact-toolbar button,
.compact-toolbar select,
.compact-toolbar input[type=color] {
  height: 28px;
  font-size: 12px;
  border: 1px solid #dadce0;
  background: #fff;
  border-radius: 4px;
  padding: 0 8px;
  cursor: pointer;
}

.compact-toolbar button:hover,
.compact-toolbar select:hover {
  background: #f8f9fa;
}

.divider {
  width: 1px;
  height: 20px;
  background: #dadce0;
  margin: 0 6px;
}

/* =========================
   WORKSPACE LAYOUT
========================= */
.sheet-workspace {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 92px); /* navbar + toolbar */
  overflow: hidden;
}

/* =========================
   LOADING OVERLAY
========================= */
.sheet-loading {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  font-size: 13px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #dadce0;
  border-top-color: #1a73e8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}

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

/* =========================
   FORMULA BAR
========================= */
.formula-bar {
  background: #ffffff;
  padding: 6px 12px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.formula-label {
  font-size: 12px;
  color: #5f6368;
  min-width: 30px;
}

.formula-input {
  flex: 1;
  height: 28px;
  border: 1px solid #dadce0;
  border-radius: 4px;
  padding: 0 8px;
  font-family: monospace;
  font-size: 12px;
}

.formula-input:focus {
  outline: 2px solid #1a73e8;
  outline-offset: -2px;
}

/* =========================
   SHEET INFO
========================= */
#sheetInfo {
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  padding: 6px 12px;
  font-size: 11px;
  color: #5f6368;
  display: flex;
  gap: 8px;
}

/* =========================
   TABLE CONTAINER
========================= */
.table-container {
  flex: 1;
  overflow: auto;
  background: #ffffff;
  position: relative;
}

/* =========================
   TABLE (UNCHANGED CORE)
========================= */
#sheetTable {
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 100%;
}

#sheetTable thead th {
  background: #f8f9fa;
  position: sticky;
  top: 0;
  z-index: 10;
  border: 1px solid #e0e0e0;
  height: 24px;
  min-width: 100px;
  text-align: center;
  font-size: 12px;
}

#sheetTable tbody th {
  background: #f8f9fa;
  position: sticky;
  left: 0;
  z-index: 9;
  border: 1px solid #e0e0e0;
  width: 50px;
  text-align: center;
  font-size: 12px;
}

#sheetTable td {
  border: 1px solid #e0e0e0;
  height: 24px;
  padding: 2px 4px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  cursor: cell;
}

#sheetTable td.selected-cell {
  outline: 2px solid #1a73e8;
  outline-offset: -2px;
}

/* =========================
   CONTEXT MENU
========================= */
.context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 3000;
  min-width: 160px;
  display: none;
}

.context-menu-item {
  padding: 6px 16px;
  font-size: 12px;
  cursor: pointer;
}

.context-menu-item:hover {
  background: #f8f9fa;
}

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

/* =========================
   STATUS BOX
========================= */
#statusBox {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid #dadce0;
  font-size: 12px;
  z-index: 3000;
}

.merged-hidden {
  display: none !important;
}
