:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: rgba(255, 255, 255, 0.9);
  --grid: #d6deeb;
  --header: #eef3fb;
  --text: #1d2939;
  --muted: #667085;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.14);
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font: 14px/1.4 Inter, system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #ffffff 0, #edf3ff 35%, var(--bg) 100%);
}
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  padding: 18px;
  gap: 14px;
}
.toolbar, .grid-wrap {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.toolbar {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  padding: 12px 14px;
  gap: 14px;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: 0.02em; }
.formula-bar-group {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  align-items: center;
}
.name-box {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 46px;
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: #fff;
  font-weight: 600;
}
.formula-wrap {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.formula-label {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--header);
  height: 100%;
  font-weight: 600;
}
#formula-input { border: 0; padding: 12px 14px; font: inherit; min-width: 0; }
#formula-input:focus, .cell-input:focus { outline: none; }
.grid-wrap { overflow: auto; padding: 10px; }
.sheet { border-collapse: separate; border-spacing: 0; min-width: max-content; }
.sheet th, .sheet td {
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  min-width: 104px;
  height: 32px;
  padding: 0;
}
.sheet thead th, .row-header {
  position: sticky;
  z-index: 1;
  background: var(--header);
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}
.sheet thead th { top: 0; }
.row-header { left: 0; min-width: 52px; }
.corner { left: 0; z-index: 2; }
.cell {
  position: relative;
  background: white;
  padding: 6px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: cell;
}
.cell.active {
  background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)), white;
  box-shadow: inset 0 0 0 2px var(--accent);
}
.cell.range {
  background: linear-gradient(0deg, rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0.08)), white;
}
.cell.range.active {
  background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)), white;
}
.cell-input { width: 100%; height: 100%; padding: 6px 8px; border: 0; font: inherit; }
@media (max-width: 720px) {
  .app-shell { padding: 10px; }
  .toolbar { grid-template-columns: 1fr; }
  .brand { font-size: 16px; }
  .formula-bar-group { grid-template-columns: 72px 1fr; }
  .sheet th, .sheet td { min-width: 88px; }
}
