:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d1d5db;
  --primary: #0f766e;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 10% 0%, #ecfeff 0%, var(--bg) 45%);
}

a {
  color: var(--primary);
  text-decoration: none;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.container-wide {
  max-width: none;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  background: #f9fafb;
}

.inline-form {
  margin: 0;
}

.chip-button {
  width: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  background: #f9fafb;
  color: var(--text);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

h1,
h2,
h3 {
  margin: 0 0 12px;
}

form p {
  margin: 0 0 12px;
}

input,
select,
textarea,
button {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

button,
.btn {
  display: inline-block;
  width: auto;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  padding: 8px 14px;
}

.btn-outline {
  background: white;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-danger {
  background: var(--danger);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.filters-scroll {
  max-height: 300px;
  overflow-y: auto;
  padding-right: 6px;
  align-content: start;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.row-data-table {
  --default-cell-width: 180px;
  --row-cell-height: 100px;
  width: max-content;
  min-width: 100%;
}

.row-data-table col {
  width: var(--default-cell-width);
  min-width: var(--default-cell-width);
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 10px;
  vertical-align: top;
}

.row-data-table th.resizable-col-header {
  position: relative;
  padding-right: 18px;
}

.row-data-table th.resizable-col-header > a,
.row-data-table th.resizable-col-header > span:first-child {
  display: inline-block;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}

.col-resize-handle::after {
  content: "";
  position: absolute;
  top: 18%;
  bottom: 18%;
  left: 4px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
}

.row-data-table th.resizable-col-header:hover .col-resize-handle::after {
  background: color-mix(in srgb, var(--primary) 45%, white);
}

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

.row-fixed-height,
.row-fixed-height td {
  height: var(--row-cell-height);
}

.cell-scroll {
  height: var(--row-cell-height);
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.inline-edit-cell {
  cursor: pointer;
}

.inline-edit-cell:hover {
  outline: 1px dashed var(--primary);
  outline-offset: -2px;
  background: #f0fdfa;
}

.inline-edit-empty::before {
  content: "Click to edit";
  color: var(--muted);
}

.inline-editor {
  display: grid;
  gap: 6px;
}

.inline-editor .inline-editor-control {
  width: 100%;
}

.inline-editor-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.inline-editor-actions .btn,
.inline-editor-actions .btn-outline {
  padding: 4px 8px;
  font-size: 12px;
}

.inline-editor-error {
  font-size: 12px;
}

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

.messages {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.messages li {
  border: 1px solid var(--line);
  border-left-width: 4px;
  background: white;
  padding: 10px;
  margin-bottom: 8px;
}

.messages .success {
  border-left-color: #15803d;
}

.messages .warning {
  border-left-color: #a16207;
}

.messages .error {
  border-left-color: #b91c1c;
}

.table-settings-dialog {
  width: min(680px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

.table-settings-dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.table-settings-form {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.columns-settings-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.columns-settings-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f9fafb;
}

.columns-settings-title {
  font-weight: 500;
  min-width: 0;
  overflow-wrap: anywhere;
}

.columns-settings-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.columns-settings-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
}

.columns-settings-checkbox input {
  width: auto;
  margin: 0;
}

.tabulator-toolbar {
  margin-bottom: 10px;
}

.tabulator-host {
  --tabulator-default-cell-height: 100px;
  --tabulator-default-cell-width: 180px;
}

.tabulator-host .tabulator {
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
}

.tabulator-host .tabulator-header {
  background: #f9fafb;
  border-bottom: 1px solid var(--line);
}

.tabulator-host .tabulator-col {
  background: #f9fafb;
}

.tabulator-host .tabulator-row {
  background: white;
}

.tabulator-host .tabulator-row.tabulator-row-even {
  background: #fcfcfd;
}

.tabulator-host .tabulator-cell,
.tabulator-host .tabulator-col .tabulator-col-content {
  padding: 8px;
}

.tabulator-host .tabulator-cell {
  vertical-align: top;
  min-width: 1px;
}

.tabulator-host .tabulator-cell-wrap {
  height: var(--tabulator-default-cell-height);
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tabulator-host .tabulator-cell-wrap-empty::before {
  content: "Click to edit";
  color: var(--muted);
}

.tabulator-host .tabulator-cell.tabulator-editing .tabulator-cell-wrap-empty::before {
  content: "";
}

.tabulator-host .tabulator-cell input,
.tabulator-host .tabulator-cell textarea,
.tabulator-host .tabulator-cell select {
  width: 100%;
  box-sizing: border-box;
}

.tabulator-host .tabulator-frozen {
  background: #f7fafc;
}

.tabulator-host .tabulator-footer {
  border-top: 1px solid var(--line);
  background: white;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  th,
  td {
    padding: 8px;
  }
}
