:root {
  color-scheme: dark;
  --bg: #272832;
  --panel: #343541;
  --panel-2: #2e2f3a;
  --line: #474955;
  --text: #f3f3f5;
  --muted: #b7b8c2;
  --accent: #15d39a;
  --accent-dark: #0eb783;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1560px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar,
.toolbar,
.pager,
.actions,
.entry-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  font-weight: 650;
}

h2 {
  margin-bottom: 18px;
  font-size: 22px;
}

h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 18px;
}

.toolbar input[type="search"] {
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 44px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #252631;
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
}

.primary,
.secondary,
.ghost,
.file-button {
  min-height: 42px;
  border-radius: 6px;
  padding: 0 15px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.toolbar .file-button {
  height: 44px;
  min-height: 44px;
  margin: 0;
}

.primary {
  background: var(--accent);
  color: #07251c;
  font-weight: 750;
}

.primary:hover {
  background: var(--accent-dark);
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
  justify-self: start;
}

.secondary,
.file-button {
  background: var(--panel);
  border: 1px solid var(--line);
}

.ghost {
  background: transparent;
  color: var(--muted);
}

.ghost:hover,
.secondary:hover,
.file-button:hover {
  color: var(--text);
  border-color: var(--accent);
}

.file-button input {
  display: none;
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  align-items: start;
}

.table-wrap,
.detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

col[data-col="orders"] {
  width: 170px;
}

col[data-col="name"] {
  width: 300px;
}

col[data-col="address"] {
  width: 270px;
}

col[data-col="postal_code"] {
  width: 100px;
}

col[data-col="city"] {
  width: 190px;
}

col[data-col="country"] {
  width: 90px;
}

col[data-col="updated_at"] {
  width: 150px;
}

col[data-col="notes"] {
  width: 260px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  position: relative;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  user-select: none;
}

td {
  color: #dcdee5;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #3b3d49;
}

.object-name {
  color: var(--accent);
  font-weight: 700;
}

.orders {
  min-width: 0;
}

.pill {
  display: inline-block;
  margin: 0 5px 5px 0;
  border: 1px solid #5b5e6d;
  border-radius: 999px;
  padding: 3px 8px;
  color: #eefaf6;
  background: #273b38;
  font-size: 12px;
}

.notes-preview {
  color: var(--muted);
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.sort-button {
  width: 100%;
  justify-content: flex-start;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  padding: 4px 20px 4px 0;
  text-align: left;
  font-weight: 750;
}

.sort-button::after {
  content: "";
  position: absolute;
  right: 16px;
  opacity: 0.35;
}

th.sorted[data-direction="asc"] .sort-button::after {
  content: "↑";
  opacity: 1;
}

th.sorted[data-direction="desc"] .sort-button::after {
  content: "↓";
  opacity: 1;
}

.sort-button:hover {
  color: var(--accent);
}

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

.col-resizer::after {
  content: "";
  position: absolute;
  top: 12px;
  right: 3px;
  width: 1px;
  height: calc(100% - 24px);
  background: transparent;
}

.col-resizer:hover::after,
.resizing-column .col-resizer::after {
  background: var(--accent);
}

.resizing-column {
  cursor: col-resize;
  user-select: none;
}

.column-menu {
  position: absolute;
  z-index: 20;
  display: none;
  min-width: 190px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #262832;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  padding: 8px;
}

.column-menu.open {
  display: block;
}

.column-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  border-radius: 4px;
  padding: 8px;
  color: var(--text);
  cursor: pointer;
}

.column-menu-item:hover {
  background: #343743;
}

.column-menu-item input {
  width: auto;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 30px;
}

.login-box h1 {
  margin-bottom: 24px;
}

.login-box .primary {
  width: 100%;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
}

.auth-tab {
  min-height: 38px;
  border-radius: 6px;
  background: #252631;
  color: var(--muted);
  padding: 7px;
}

.auth-tab.active {
  background: var(--accent);
  color: #07251c;
  font-weight: 750;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.error-text {
  min-height: 22px;
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.users-list {
  display: grid;
  gap: 10px;
  max-height: 60vh;
  overflow: auto;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pager {
  justify-content: space-between;
  min-height: 58px;
  padding: 0 18px;
  color: var(--muted);
}

.detail {
  position: sticky;
  top: 18px;
  padding: 20px;
}

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

.hint {
  margin-bottom: 16px;
  color: var(--muted);
}

.detail-meta {
  position: relative;
  display: grid;
  gap: 8px 12px;
  margin: 0 0 18px;
}

.detail-label {
  color: var(--muted);
  white-space: nowrap;
}

.detail-value {
  word-break: break-word;
}

.detail-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--detail-resizer-left, 138px);
  width: 10px;
  transform: translateX(-6px);
  cursor: col-resize;
}

.detail-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  width: 1px;
  background: transparent;
}

.detail-resizer:hover::after {
  background: var(--accent);
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 18px 0;
}

.entry-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.entry-row {
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #2c2e39;
  padding: 10px 12px;
}

.entry-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.entry-main span,
.entry-main strong {
  overflow-wrap: anywhere;
}

.entry-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.entry-actions .ghost {
  min-height: 30px;
  padding: 0 8px;
}

.note-entry {
  align-items: start;
}

.note-text {
  line-height: 1.45;
}

.entry-meta {
  display: block;
  border-top: 1px solid var(--line);
  padding-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.order-form {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
}

.notes-form {
  display: grid;
  gap: 8px;
}

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

dialog {
  width: min(620px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 22px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.56);
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
  color: var(--muted);
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.check input {
  width: auto;
}

.folder-options {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #2b2d38;
  margin: -2px 0 14px 28px;
  padding: 12px;
}

.folder-options label {
  margin-bottom: 8px;
}

.folder-options .hint {
  margin-bottom: 0;
}

.actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 980px) {
  .shell {
    width: min(100vw - 24px, 760px);
  }

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

  .detail {
    position: static;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  th:nth-child(4),
  td:nth-child(4),
  th:nth-child(6),
  td:nth-child(6),
  th:nth-child(8),
  td:nth-child(8) {
    display: none;
  }

  th,
  td {
    padding: 13px 10px;
  }
}
