:root {
  --bg: #f6f8fb;
  --bg-2: #eef6f4;
  --surface: #ffffff;
  --surface-soft: #f9fbfd;
  --line: #dce4ee;
  --line-strong: #c7d2df;
  --text: #172033;
  --muted: #64748b;
  --muted-2: #8a97aa;
  --brand: #2563eb;
  --brand-2: #0f766e;
  --brand-soft: #edf4ff;
  --danger: #dc2626;
  --danger-soft: #fff1f2;
  --warn: #b45309;
  --warn-soft: #fff7ed;
  --ok: #0f8b5f;
  --ok-soft: #ecfdf5;
  --shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --sidebar: 272px;
  --header: 64px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg) 0%, #f7fbff 45%, var(--bg-2) 100%);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 0.8fr) minmax(420px, 1.2fr);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(15, 118, 110, 0.1)),
    var(--bg);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px;
}

.login-card {
  width: min(430px, 100%);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(220, 228, 238, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
}

.login-visual {
  padding: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid rgba(220, 228, 238, 0.72);
}

.login-preview {
  width: min(760px, 100%);
  min-height: 520px;
  display: grid;
  grid-template-rows: auto 1fr;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(210, 220, 232, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #ffffff, #f8fafc);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(94px, 1fr));
  grid-auto-rows: 42px;
  padding: 22px;
  gap: 1px;
  background: #edf2f7;
}

.preview-grid span {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px solid #edf2f7;
}

.preview-grid span:nth-child(-n + 5) {
  background: #eef4ff;
  color: #1f3a6d;
  font-weight: 700;
}

.brand-lockup {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.avatar,
.avatar-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #0f766e);
  color: #fff;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.avatar {
  width: 42px;
  height: 42px;
  font-size: 14px;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.brand-title {
  display: grid;
  min-width: 0;
}

.brand-title strong {
  font-size: 18px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-title span {
  font-size: 13px;
  color: var(--muted);
}

.status-pill,
.tag,
.access-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.status-pill.online,
.tag.active,
.access-pill.edit {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: #bdebd7;
}

.status-pill.offline,
.tag.inactive,
.access-pill.no {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #fecdd3;
}

.tag.archived,
.access-pill.view {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: #fed7aa;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.login-card h1 {
  margin: 24px 0 8px;
  font-size: 28px;
  line-height: 1.2;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.textarea {
  min-height: 90px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: var(--radius);
  background: #fff;
  color: #25324a;
  border: 1px solid var(--line);
  font-weight: 750;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  border-color: var(--line-strong);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(135deg, #2563eb, #0f766e);
  color: #fff;
  border-color: transparent;
}

.btn.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #fecdd3;
}

.btn.ghost {
  background: transparent;
}

.sheet-open-name {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: #1d4ed8;
  font-weight: 850;
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
}

.sheet-open-name:hover {
  transform: none;
  box-shadow: none;
  color: #0f766e;
  text-decoration: underline;
}

.btn.icon {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.icon-svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.hint,
.error,
.success {
  font-size: 13px;
  line-height: 1.45;
}

.hint {
  color: var(--muted);
}

.error {
  color: var(--danger);
}

.success {
  color: var(--ok);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  max-width: min(320px, 88vw);
  z-index: 50;
  border-right: 1px solid rgba(210, 220, 232, 0.85);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
  min-width: 0;
  transform: translateX(-105%);
  transition: transform 220ms ease, box-shadow 220ms ease;
  will-change: transform;
}

.app-shell:not(.sidebar-hidden) .sidebar {
  transform: translateX(0);
  box-shadow: 24px 0 50px rgba(15, 23, 42, 0.14);
}

.sidebar-top {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
}

.collapse-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.nav {
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 5px;
  overflow-y: auto;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 11px;
  border-radius: var(--radius);
  color: #334155;
  font-weight: 700;
  transition: background 160ms ease, color 160ms ease;
}

.nav a:hover,
.nav a.active {
  background: #edf4ff;
  color: #1746a2;
}

.nav .nav-icon {
  width: 22px;
  text-align: center;
  font-weight: 900;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-menu .name {
  display: grid;
  min-width: 0;
}

.user-menu strong,
.user-menu span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-menu span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-logout {
  width: 100%;
  justify-content: flex-start;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  transition: margin-left 220ms ease;
}

.global-menu-button {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 66;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  transition: left 220ms ease, box-shadow 220ms ease;
}

.app-shell:not(.sidebar-hidden) .global-menu-button {
  left: calc(var(--sidebar) + 14px);
}

.page-route:not(.sidebar-hidden) .main {
  margin-left: var(--sidebar);
}

.content {
  padding: 0;
  overflow: auto;
  min-width: 0;
}

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  gap: 14px;
}

.cards {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
  padding: 16px;
  min-width: 0;
}

.metric {
  display: grid;
  gap: 8px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric strong {
  font-size: 26px;
  line-height: 1;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2,
.section-head h3 {
  margin: 0;
  font-size: 16px;
}

.table-shell {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
  flex-wrap: wrap;
}

.table-tools .input {
  max-width: 420px;
}

.table-wrap {
  overflow: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 13px;
  border-bottom: 1px solid #edf2f7;
  vertical-align: middle;
  font-size: 13px;
}

.data-table th {
  color: #475569;
  font-weight: 850;
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tr:hover td {
  background: #fbfdff;
}

.stack {
  display: grid;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.row.nowrap {
  flex-wrap: nowrap;
}

.muted {
  color: var(--muted);
}

.strong {
  font-weight: 850;
}

.empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.activity-list {
  display: grid;
  gap: 8px;
}

.log-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.log-controls .btn.active-filter {
  border-color: #9db9f7;
  background: #edf4ff;
  color: #1746a2;
}

.log-date {
  width: 132px;
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

.load-more-row {
  display: flex;
  justify-content: center;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fbfdff;
}

.activity-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid #edf2f7;
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-item strong {
  font-size: 13px;
}

.activity-item span {
  color: var(--muted);
  font-size: 12px;
}

.folder-grid,
.user-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.entity-card {
  display: grid;
  gap: 14px;
}

.entity-card h3 {
  margin: 0;
  font-size: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.45);
  z-index: 50;
}

.modal {
  width: min(680px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal.wide {
  width: min(960px, 100%);
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 8px;
}

.toast {
  width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  background: #111827;
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.editor-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  min-width: 0;
  background: #f7fafc;
}

.editor-titlebar {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) minmax(0, auto);
  align-items: center;
  gap: 12px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  min-width: 0;
}

.editor-title-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.sheet-menu-button {
  align-self: flex-start;
  margin-top: 1px;
}

.app-shell:not(.sidebar-hidden) .editor-titlebar .sheet-menu-button {
  position: fixed;
  top: 10px;
  left: calc(var(--sidebar) + 10px);
  z-index: 65;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.editor-titlebar h1 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-name-row {
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.inline-name-button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  margin: 0;
  max-width: 100%;
  text-align: left;
  cursor: text;
  font: inherit;
  font-weight: 800;
}

.workbook-name-button {
  font-size: 16px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-name-button {
  color: #1746a2;
  font-size: 13px;
}

.inline-name-button:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.inline-name-input {
  min-height: 30px;
  border: 1px solid #8fb3ff;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  font: inherit;
  font-weight: 800;
  outline: none;
  padding: 4px 8px;
}

.workbook-name-input {
  width: min(360px, 48vw);
  font-size: 16px;
}

.table-name-input {
  width: min(260px, 38vw);
  font-size: 13px;
}

.editor-actions {
  margin-left: 0;
  justify-self: end;
  justify-content: flex-end;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.btn.compact {
  min-height: 26px;
  padding: 4px 8px;
  font-size: 11px;
}

.presence {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 8px;
  overflow: visible;
}

.presence .avatar-sm {
  margin-left: -6px;
  box-shadow: 0 0 0 2px #fff;
  position: relative;
}

.presence .avatar-sm:first-child {
  margin-left: 0;
}

.presence .avatar-sm::after {
  content: "";
  width: 8px;
  height: 8px;
  position: absolute;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  background: #22c55e;
  border: 1px solid #fff;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.toolbar .btn,
.toolbar .select,
.toolbar .input {
  min-height: 28px;
  height: 28px;
  font-size: 11px;
  padding: 4px 7px;
  border-radius: 6px;
}

.toolbar .btn:disabled,
.toolbar .select:disabled,
.toolbar .input:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.toolbar .btn.icon {
  width: 28px;
  min-width: 28px;
}

.toolbar input[type="color"] {
  width: 30px;
  min-width: 30px;
  padding: 2px;
}

.app-tooltip {
  position: fixed;
  z-index: 120;
  max-width: 220px;
  padding: 5px 7px;
  border-radius: 6px;
  background: #172033;
  color: #fff;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.color-tool {
  position: relative;
  overflow: hidden;
}

.color-tool.disabled {
  opacity: 0.42;
  pointer-events: none;
}

.color-tool input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.font-color-icon {
  color: #172033;
  font-weight: 900;
  border-bottom: 3px solid currentColor;
  line-height: 1;
}

.paint-icon {
  width: 16px;
  height: 14px;
  border: 2px solid #475569;
  border-radius: 3px 3px 5px 5px;
  background: #ffffff;
  box-shadow: inset 0 -7px 0 var(--paint-color, #f8c7c7);
}

.border-color-icon {
  width: 17px;
  height: 17px;
  border: 3px solid #334155;
  border-radius: 3px;
  background: #fff;
}

.toolbar .select-format {
  width: 118px;
}

.toolbar .select-type {
  width: 74px;
}

.formula-bar {
  display: grid;
  grid-template-columns: 72px 34px minmax(180px, 400px) minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.formula-name {
  color: #475569;
  font-weight: 850;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 9px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
}

.formula-input {
  height: 32px;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 7px 10px;
  outline: none;
}

.formula-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.formula-actions .btn {
  min-height: 28px;
  height: 28px;
  padding: 3px 7px;
  font-size: 11px;
  flex: 0 0 auto;
}

.formula-actions .btn.icon {
  width: 28px;
  padding: 3px;
}

.formula-fx {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #f8fafc;
  font-weight: 850;
  font-size: 12px;
}

.formula-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.sheet-area {
  overflow: auto;
  min-width: 0;
  min-height: 0;
  background: #eef2f7;
}

.sheet-grid {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: #fff;
  min-width: max-content;
}

.sheet-grid th,
.sheet-grid td {
  border-right: 1px solid #dbe4ee;
  border-bottom: 1px solid #dbe4ee;
  padding: 0;
  height: 28px;
  min-height: 28px;
  position: relative;
  overflow: visible;
}

.sheet-grid th {
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  user-select: none;
  position: sticky;
  z-index: 5;
}

.sheet-grid .corner {
  left: 0;
  top: 0;
  width: 46px;
  min-width: 46px;
  z-index: 8;
}

.sheet-grid .col-head {
  top: 0;
}

.sheet-grid .row-head {
  left: 0;
  width: 46px;
  min-width: 46px;
  z-index: 7;
}

.cell {
  width: 100%;
  height: 100%;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 7px;
  overflow: visible;
  white-space: nowrap;
  text-overflow: clip;
  outline: none;
  font-size: 13px;
  line-height: 1.2;
  background: transparent;
  position: relative;
  z-index: 1;
}

.cell[contenteditable="true"] {
  cursor: text;
  caret-color: var(--brand);
  user-select: text;
}

.cell.has-newline {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cell.wrap {
  white-space: normal;
  align-items: flex-start;
  overflow-wrap: anywhere;
}

.cell.editing {
  display: block;
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--brand), 0 0 0 3px rgba(37, 99, 235, 0.14), 0 10px 24px rgba(15, 23, 42, 0.08);
  cursor: text;
  min-width: max(100%, 180px);
  min-height: 40px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: left !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  border-radius: 4px;
  padding: 7px 9px;
  z-index: 20;
}

.cell input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.sheet-grid th.selected {
  box-shadow: inset 0 0 0 2px var(--brand), 0 0 0 1px var(--brand);
  z-index: 12;
}

.sheet-grid td.selected {
  z-index: 12;
  background: #fff;
}

.sheet-grid td.selected .cell {
  background: #eff6ff;
  min-width: max-content;
  z-index: 16;
}

.sheet-grid td.selected .cell.editing {
  background: #fff;
}

.sheet-grid td.selected::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 2px solid var(--brand);
  pointer-events: none;
  z-index: 24;
}

.sheet-grid td.editing-cell {
  z-index: 32;
}

.sheet-grid td.editing-cell::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px solid var(--brand-2);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.14);
  pointer-events: none;
  z-index: 34;
}

.sheet-grid td.range-selected {
  background: #eff6ff;
}

.sheet-grid td.fill-range {
  background: #ecfdf5;
  box-shadow: inset 0 0 0 1px #22c55e;
}

.fill-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--brand);
  cursor: crosshair;
  z-index: 30;
}

.sheet-grid td.locked .cell::after {
  content: "L";
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 9px;
  color: #64748b;
}

.sheet-grid td.masked .cell {
  color: #475569;
  font-weight: 850;
}

.resizer-x,
.resizer-y {
  position: absolute;
  background: transparent;
  z-index: 9;
}

.resizer-x {
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
}

.resizer-y {
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 8px;
  cursor: row-resize;
}

.tabbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
  overflow-x: auto;
}

.tab-wrap {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.tab {
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  background: #edf4ff;
  border-color: #b9cffd;
  color: #1746a2;
}

.tab-name-input {
  width: 150px;
  min-height: 32px;
  padding: 5px 10px;
}

.context-menu {
  position: fixed;
  z-index: 70;
  width: 230px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
}

.context-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 32px;
  padding: 7px 9px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.context-menu-title {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-menu button.danger-item {
  color: #b42318;
}

.context-menu button:disabled {
  color: #aab5c4;
  cursor: not-allowed;
  background: transparent;
}

.context-menu button:hover {
  background: #f1f5f9;
}

.fullscreen .sidebar {
  display: none;
}

.fullscreen.app-shell {
  grid-template-columns: 1fr;
}

.fullscreen .main {
  grid-template-rows: 1fr;
}

.fullscreen .content {
  padding: 0;
}

.fullscreen .editor-shell {
  height: 100vh;
}

.profile-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.profile-hero .avatar {
  width: 64px;
  height: 64px;
  font-size: 20px;
}

.settings-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.7fr);
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .cards {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .split,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .login-page {
    grid-template-columns: 1fr;
  }

  .login-visual {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    width: min(300px, 88vw);
  }

  .app-shell.mobile-open .sidebar {
    transform: translateX(0);
  }

  .app-shell:not(.sidebar-hidden) .sidebar {
    transform: translateX(0);
  }

  .main {
    min-height: 100vh;
  }

  .content {
    padding: 0;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .toolbar {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .editor-titlebar {
    grid-template-columns: 1fr;
  }

  .app-shell:not(.sidebar-hidden) .editor-titlebar .sheet-menu-button {
    left: calc(min(300px, 88vw) + 10px);
  }

  .editor-actions {
    justify-self: stretch;
    justify-content: flex-start;
  }

  .editor-shell {
    height: 100vh;
  }
}
