:root {
  --ubc-bg: #f8fafc;
  --ubc-surface: #ffffff;
  --ubc-surface-2: #f1f5f9;
  --ubc-border: #dbe4ee;
  --ubc-border-strong: #c5d0dd;
  --ubc-text: #0f172a;
  --ubc-muted: #64748b;
  --ubc-primary: #2563eb;
  --ubc-primary-soft: #dbeafe;
  --ubc-success: #10b981;
  --ubc-success-dark: #059669;
  --ubc-danger: #dc2626;
  --ubc-total: #ecfeff;
  --ubc-cumulative: #eef2ff;
  --ubc-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --ubc-radius: 12px;
  --ubc-cell-h: 28px;
  --ubc-font: Inter, Arial, Helvetica, sans-serif;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--ubc-bg);
  color: var(--ubc-text);
  font-family: var(--ubc-font);
  font-size: 13px;
}

* {
  box-sizing: border-box;
}

.ubc-app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ubc-bg);
}

.ubc-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px;
  margin: 12px 12px 0;
  border: 1px solid var(--ubc-border);
  border-radius: var(--ubc-radius);
  background: var(--ubc-surface);
  box-shadow: var(--ubc-shadow);
  flex-wrap: wrap;
}

.ubc-title {
  font-weight: 700;
  font-size: 15px;
  min-width: 150px;
  align-self: center;
}

.ubc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
}

.ubc-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ubc-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.ubc-select,
.ubc-input {
  height: 34px;
  border: 1px solid var(--ubc-border-strong);
  border-radius: 9px;
  background: #fff;
  padding: 0 10px;
  font: inherit;
  color: var(--ubc-text);
}

.ubc-select:focus,
.ubc-input:focus {
  outline: none;
  border-color: var(--ubc-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.ubc-btn {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--ubc-border-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--ubc-text);
  cursor: pointer;
  font: inherit;
}

.ubc-btn:hover {
  background: #f8fafc;
}

.ubc-btn-primary {
  background: var(--ubc-success);
  border-color: var(--ubc-success);
  color: white;
}

.ubc-btn-primary:hover {
  background: var(--ubc-success-dark);
}

.ubc-btn-small {
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: 7px;
}

.ubc-status {
  margin-left: auto;
  align-self: center;
  color: var(--ubc-muted);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--ubc-surface-2);
  font-size: 12px;
}

.ubc-grid-wrap {
  flex: 1;
  overflow: auto;
  margin: 12px;
  border: 1px solid var(--ubc-border);
  border-radius: var(--ubc-radius);
  background: var(--ubc-surface);
  box-shadow: var(--ubc-shadow);
}

.ubc-grid {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.ubc-grid th,
.ubc-grid td {
  height: var(--ubc-cell-h);
  min-height: var(--ubc-cell-h);
  border-right: 1px solid var(--ubc-border);
  border-bottom: 1px solid var(--ubc-border);
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  background: #fff;
}

.ubc-grid thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 30px;
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
  text-align: center;
  border-bottom: 1px solid var(--ubc-border-strong);
}

.ubc-resizable {
  position: relative;
}

.ubc-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 20;
}

.ubc-resizer:hover {
  background: rgba(37, 99, 235, .18);
}

body.ubc-resizing,
body.ubc-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.ubc-row-group td {
  background: #f8fafc;
  font-weight: 700;
}

.ubc-group-title-cell {
  padding: 4px 6px !important;
}

.ubc-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ubc-tree-toggle {
  width: 22px;
  height: 22px;
  border: 1px solid var(--ubc-border-strong);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ubc-tree-toggle:hover {
  background: #f1f5f9;
}

.ubc-group-label {
  font-weight: 700;
  color: #0f172a;
}

.ubc-group-actions {
  margin-left: auto;
  opacity: 0;
  transition: opacity .12s;
}

.ubc-row-group:hover .ubc-group-actions {
  opacity: 1;
}

.ubc-cell-num {
  text-align: right;
}

.ubc-input-cell {
  padding: 0 !important;
  position: relative;
}

.ubc-num-input {
  width: 100%;
  height: 27px;
  min-height: 27px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 3px 6px;
  text-align: right;
  font: inherit;
  color: var(--ubc-text);
}

.ubc-num-input:focus {
  outline: none;
  background: transparent;
}

.ubc-input-cell:hover {
  background: #f8fbff !important;
}

.ubc-cell-selected,
.ubc-cell-selected:hover,
.ubc-cell-selected:focus-within {
  background: var(--ubc-primary-soft) !important;
}

.ubc-cell-selected .ubc-num-input,
.ubc-cell-selected:hover .ubc-num-input,
.ubc-cell-selected .ubc-num-input:focus {
  background: transparent !important;
}

.ubc-cell-anchor {
  box-shadow: inset 0 0 0 2px var(--ubc-primary);
}

.ubc-row-grand td {
  background: var(--ubc-total);
  font-weight: 800;
}

.ubc-row-cumulative td {
  background: var(--ubc-cumulative);
  font-weight: 800;
}

.ubc-total-label {
  text-align: right;
  font-weight: 800;
}

.ubc-context-menu {
  position: fixed;
  display: none;
  min-width: 180px;
  padding: 6px;
  background: white;
  border: 1px solid var(--ubc-border);
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, .18);
  z-index: 2147483647;
}

.ubc-context-menu button {
  display: block;
  width: 100%;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: white;
  text-align: left;
  padding: 0 10px;
  cursor: pointer;
  color: var(--ubc-text);
  font: inherit;
}

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

.ubc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.ubc-modal {
  width: 430px;
  max-width: calc(100vw - 32px);
  padding: 18px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 48px rgba(15, 23, 42, .22);
}

.ubc-modal-wide {
  width: 740px;
}

.ubc-modal h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.ubc-note {
  margin-bottom: 12px;
  color: var(--ubc-muted);
  line-height: 1.45;
}

.ubc-modal-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.ubc-modal-row label,
.ubc-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ubc-muted);
}

.ubc-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.ubc-copy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.ubc-copy-target {
  min-height: 100px;
  padding: 12px;
  border: 1px solid var(--ubc-border);
  border-radius: 12px;
  background: #f8fafc;
  line-height: 1.5;
  margin-bottom: 12px;
}

.ubc-check {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ubc-copy-help {
  color: var(--ubc-muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 10px;
}
