:root {
  color-scheme: light;
  font-family: "Space Grotesk", system-ui, sans-serif;
  --bg: #f4efe7;
  --ink: #1e1a14;
  --muted: #7b6f5d;
  --card: #fffaf3;
  --accent: #e07a2f;
  --accent-dark: #b85e1e;
  --border: #e0d3c3;
  --shadow: 0 20px 40px rgba(30, 26, 20, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  overflow-x: hidden;
  background: radial-gradient(circle at top left, #fff3de 0%, #f4efe7 45%, #efe6db 100%);
  color: var(--ink);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 28px 80px;
  width: 100%;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 24px;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  width: 100%;
}

.brand {
  min-width: 0;
}

.espresso-art {
  width: 180px;
}

.espresso-art svg {
  width: 100%;
  height: auto;
  display: block;
}

.brand h1 {
  margin: 6px 0;
  font-size: 32px;
  letter-spacing: -0.02em;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 11px;
  color: var(--muted);
  margin: 0;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.status {
  text-align: right;
  display: grid;
  justify-items: end;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #efe1cf;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.status-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

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

button {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}

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

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

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}

button.ghost:hover {
  background: #f0e3d3;
}

button.ghost.danger {
  color: #9e1b1b;
  border-color: #e5b7b7;
}

.content {
  margin-top: 20px;
  display: grid;
  gap: 24px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding: 18px 20px;
  background: var(--card);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.top-controls {
  grid-column: 1 / -1;
  margin-top: 2px;
  padding: 14px 0 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.active-chips {
  display: flex;
  gap: 8px;
  align-items: center;
  grid-column: 1 / 3;
  flex-wrap: wrap;
}

.chip {
  background: #f3e4d3;
  color: var(--ink);
  border: 1px solid #e4ccae;
  padding: 8px 14px;
}

.chip.is-selected {
  background: #3c2a1f;
  color: #fff6ed;
  border-color: #3c2a1f;
}

.active-summary {
  color: #5f4a36;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  grid-column: 3 / 5;
  white-space: nowrap;
}

.search {
  grid-column: 1 / 3;
}

.filters {
  min-width: 0;
}

.controls label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 6px;
}

.controls input,
.controls select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.filters.inline label {
  text-transform: none;
  letter-spacing: normal;
  font-size: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.table-panel {
  background: var(--card);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px 20px 24px;
}

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

.table-header h2 {
  margin: 0;
}

.summary {
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

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

thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 8px;
  border-bottom: 1px solid #eee1d0;
  vertical-align: top;
}

tbody tr.row-active {
  background: #fff5e9;
}

tbody tr.row-active td:first-child {
  font-weight: 700;
}

tbody tr.row-inactive {
  opacity: 0.72;
}

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

.row-actions button {
  padding: 6px 12px;
  font-size: 12px;
}

.notes {
  max-width: 280px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty {
  margin-top: 16px;
  padding: 20px;
  border-radius: 14px;
  background: #f7ecde;
  color: var(--muted);
}

.fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  padding: 14px 22px;
  border-radius: 999px;
  box-shadow: 0 12px 24px rgba(30, 26, 20, 0.18);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.5);
  display: grid;
  place-items: center;
  padding: 20px;
}

.hidden {
  display: none;
}

body.view-only .table-wrap th:last-child,
body.view-only .table-wrap td:last-child {
  display: none;
}

.modal-card {
  width: min(520px, 90vw);
  background: #fff;
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}

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

.modal-card label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-top: 12px;
}

.modal-card input,
.modal-card select,
.modal-card textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin: 12px 0 0;
}

.offline .status-pill {
  background: #f6c6a3;
}

@media (max-width: 900px) {
  .page {
    padding: 20px 16px 96px;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 14px;
    padding: 20px;
  }

  .espresso-art {
    width: 140px;
    justify-self: start;
  }

  .status {
    text-align: left;
    justify-items: start;
  }

  .status-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

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

  .top-controls {
    margin-top: 0;
    padding-top: 8px;
  }

  .active-chips,
  .active-summary,
  .search {
    grid-column: auto;
  }

  .active-summary {
    justify-content: flex-start;
    white-space: normal;
  }

  .table-panel {
    padding: 14px 12px 18px;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    table-layout: auto;
    min-width: 760px;
  }

  thead th {
    font-size: 11px;
    letter-spacing: 0.08em;
    padding: 8px 6px;
    white-space: nowrap;
  }

  tbody td {
    font-size: 12px;
    padding: 8px 5px;
    white-space: nowrap;
  }

  .notes {
    display: block;
    max-width: 220px;
    -webkit-line-clamp: 1;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .row-actions button {
    white-space: nowrap;
    min-width: 48px;
    font-size: 11px;
    padding: 5px 10px;
  }
}
