:root {
  color-scheme: light;
  --blue: #1769aa;
  --blue-soft: #e8f1f8;
  --line: #d9dee4;
  --line-dark: #b8c1cb;
  --text: #1f2933;
  --muted: #607080;
  --surface: #ffffff;
  --header: #f3f5f7;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: #eef1f4;
  color: var(--text);
  font: 13px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, input { font: inherit; }

.workbook {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 640px;
  background: var(--surface);
}

.titlebar, .toolbar, .formula-bar, .statusbar, .sheet-tabs {
  display: flex;
  align-items: center;
}

.titlebar {
  min-height: 42px;
  padding: 0 16px;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.brand { color: var(--blue); font-size: 16px; font-weight: 700; }
.workbook-name { color: var(--muted); }
.connection-state { margin-left: auto; color: var(--muted); font-size: 12px; }

.toolbar {
  min-height: 40px;
  padding: 0 12px;
  gap: 5px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}

.toolbar button, .sheet-tabs button {
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 5px 9px;
}

.toolbar button:hover, .sheet-tabs button:hover { background: var(--blue-soft); }
.toolbar-divider { height: 21px; margin: 0 5px; border-left: 1px solid var(--line); }
.toolbar label { color: var(--muted); font-size: 12px; }
.name-box { width: 70px; border: 1px solid var(--line-dark); border-radius: 2px; padding: 4px 6px; }

.formula-bar { min-height: 36px; padding: 0 12px; gap: 8px; border-bottom: 1px solid var(--line); }
.formula-symbol { width: 25px; color: var(--muted); font-style: italic; text-align: center; }
.formula-bar input { flex: 1; border: 1px solid var(--line-dark); border-radius: 2px; padding: 5px 8px; }

.sheet-frame { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.grid-header { display: flex; min-height: 30px; padding-left: 48px; border-bottom: 1px solid var(--line-dark); background: var(--header); overflow: hidden; }
.grid-header-cell { flex: 0 0 150px; padding: 6px 8px; border-right: 1px solid var(--line); color: #44515e; font-weight: 600; }
.grid-viewport { position: relative; flex: 1; overflow: auto; background: var(--surface); }
.grid-canvas { position: relative; min-width: 100%; }
.grid-row { position: absolute; left: 0; display: flex; height: 28px; min-width: 100%; border-bottom: 1px solid var(--line); }
.grid-row-number { flex: 0 0 48px; padding: 5px 7px; border-right: 1px solid var(--line-dark); background: var(--header); color: var(--muted); text-align: right; }
.grid-cell { flex: 0 0 150px; overflow: hidden; padding: 5px 8px; border-right: 1px solid var(--line); white-space: nowrap; text-overflow: ellipsis; }
.grid-row:hover .grid-cell { background: #f8fbfd; }
.grid-empty { position: absolute; inset: 40% 0 auto; color: var(--muted); text-align: center; }

.statusbar { min-height: 26px; padding: 0 12px; gap: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.row-count { margin-left: auto; }
.sheet-tabs { min-height: 34px; padding: 0 10px; gap: 4px; border-top: 1px solid var(--line-dark); background: var(--header); }
.sheet-tab.active { border-bottom: 2px solid var(--blue); border-radius: 0; background: var(--surface); color: var(--blue); font-weight: 600; }
.add-sheet { font-size: 18px; line-height: 1; }
