:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dfe3e8;
  --line-strong: #c9d1dc;
  --text: #1f2937;
  --muted: #667085;
  --brand: #138a35;
  --brand-dark: #0f6f2c;
  --brand-soft: #e8f5ec;
  --blue: #2563eb;
  --danger: #c93c37;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1100px;
  color: var(--text);
  background: var(--bg);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    Arial,
    sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: #151b23;
  color: #d8dee9;
  border-right: 1px solid #0d1117;
  padding: 18px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: #cbd5e1;
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-item.active {
  background: var(--brand);
  color: #fff;
}

.main {
  min-width: 0;
  background: var(--bg);
}

.page {
  min-height: 100vh;
  padding: 22px 26px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  background: #fff;
}

.btn:hover {
  border-color: #aeb8c6;
  background: #f9fafb;
}

.btn.primary {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.btn.primary:hover {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
}

.btn.danger {
  color: var(--danger);
  border-color: #f0b5b2;
}

.btn.icon {
  width: 34px;
  padding: 0;
}

.btn.active {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-soft);
}

.icon-sm,
.btn svg,
.nav-item svg,
.brand svg {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.tables-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.table-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.table-actions-left,
.table-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-search {
  width: 260px;
  height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: 0;
}

.table-search:focus {
  border-color: var(--blue);
}

.selection-count {
  color: var(--muted);
  font-size: 13px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.table-list-toolbar {
  display: grid;
  grid-template-columns: 38px 1fr 145px 132px;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  color: var(--muted);
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.table-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 145px 132px;
  align-items: center;
  min-height: 58px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.table-row:last-child {
  border-bottom: 0;
}

.table-row:hover {
  background: #f3f8ff;
}

.table-name-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.table-icon {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 5px;
  color: #fff;
  background: #1da43a;
}

.table-title-button {
  overflow: hidden;
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-title-button:hover {
  color: var(--brand);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.empty-list {
  display: grid;
  min-height: 150px;
  place-items: center;
  color: var(--muted);
}

.empty-page {
  min-height: calc(100vh - 44px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.univer-editor-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  min-height: 720px;
  padding: 0;
  background: #eef1f5;
}

.editor-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.univer-host {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #fff;
}

.univer-error,
.univer-loading {
  display: grid;
  height: 100%;
  min-height: 360px;
  place-items: center;
  background: #fff;
}

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

.univer-error-card {
  display: grid;
  gap: 14px;
  justify-items: center;
  max-width: 520px;
  padding: 24px;
  text-align: center;
}

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

.workbook-title {
  width: 260px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  font-weight: 700;
}

.workbook-title:hover,
.workbook-title:focus {
  border-color: var(--line-strong);
  background: #fff;
  outline: 0;
}

.save-state {
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-right: 8px;
  border-right: 1px solid var(--line);
}

.toolbar-group:last-child {
  border-right: 0;
}

.toolbar input[type="color"] {
  width: 34px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
}

.search-input {
  width: 170px;
  height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: 0;
}

.search-input:focus {
  border-color: var(--blue);
}

.formula-bar {
  display: grid;
  grid-template-columns: 76px 32px minmax(0, 1fr);
  align-items: center;
  min-height: 38px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.cell-ref {
  color: #0f5f2b;
  font-weight: 700;
}

.fx-label {
  color: #111827;
  font-style: italic;
  font-weight: 700;
}

.formula-input {
  width: 100%;
  height: 29px;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 5px;
  outline: 0;
}

.formula-input:focus {
  border-color: var(--line-strong);
  background: #fbfdff;
}

.grid-wrap {
  min-height: 0;
  padding: 8px;
}

@media (max-width: 1180px) {
  body {
    min-width: 980px;
  }

  .app-shell {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .toolbar {
    flex-wrap: wrap;
  }
}
