:root {
  --bg: #0f1216;
  --surface: #171c22;
  --border: #262d36;
  --text: #e6eaef;
  --muted: #8a94a3;
  --accent: #4f8cff;
  --danger: #ff5c6c;
  --radius: 10px;
}

/*
 * Light theme. The settings service always resolves `theme` to a concrete
 * light/dark value on `<html data-theme>` (including `system`, via
 * prefers-color-scheme), so a single attribute override is enough.
 */
:root[data-theme='light'] {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #d8dde5;
  --text: #1a1f26;
  --muted: #5c6672;
  --accent: #2f6fe0;
  --danger: #d64550;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 1rem;
}

.card {
  max-width: 380px;
  margin: 3rem auto;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

.link {
  background: none;
  color: var(--accent);
  padding: 0.3rem 0.5rem;
  font-weight: 500;
}

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

.row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.row.between {
  justify-content: space-between;
}

.create {
  margin: 1rem 0 1.5rem;
}

.create input {
  flex: 1;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

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

/* Status badges (workflow states, see docs/workflows.md). Muted palette:
   each state tints the surface via color-mix so both themes work. */
.badge {
  display: inline-block;
  padding: 0 0.55em;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.status-draft {
  color: var(--muted);
}

.badge.status-submitted {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.badge.status-approved {
  color: #3fb950;
  border-color: color-mix(in srgb, #3fb950 45%, var(--border));
  background: color-mix(in srgb, #3fb950 12%, var(--surface));
}

.badge.status-rejected {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}

.badge.status-ordered {
  color: #b07cf7;
  border-color: color-mix(in srgb, #b07cf7 45%, var(--border));
  background: color-mix(in srgb, #b07cf7 12%, var(--surface));
}

.badge.status-received {
  color: #2fbf9f;
  border-color: color-mix(in srgb, #2fbf9f 45%, var(--border));
  background: color-mix(in srgb, #2fbf9f 12%, var(--surface));
}

.badge.status-closed {
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 12%, var(--surface));
}

.empty {
  padding: 1.5rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.error {
  margin: 0;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 92, 108, 0.12);
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.9rem;
}

a {
  color: var(--accent);
}

/* ---- data table ---- */
.data-table-scroll {
  overflow-x: auto;
}

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

.data-table th,
.data-table td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid #e3e3e8;
  white-space: nowrap;
}

/* Compact table density (User setting `tableDensity`), applied to <html>. */
:root[data-density='compact'] .data-table th,
:root[data-density='compact'] .data-table td {
  padding: 0.15rem 0.4rem;
}

.data-table-filters th {
  font-weight: 400;
}

.data-table thead th {
  font-weight: 600;
}

.data-table-sort {
  font: inherit;
  font-weight: 600;
  padding: 0;
}

.data-table-filters input,
.data-table-filters select {
  width: 100%;
  min-width: 5rem;
  font-size: 0.85rem;
  padding: 0.2rem 0.35rem;
}

.data-table-range {
  display: flex;
  gap: 0.25rem;
}

.data-table-range input {
  min-width: 4rem;
}

.data-table tbody.is-loading {
  opacity: 0.5;
}

.data-table-toolbar {
  margin-bottom: 0.5rem;
}

.data-table-search {
  max-width: 18rem;
}

.data-table-menu {
  position: relative;
}

.data-table-menu summary {
  cursor: pointer;
}

.data-table-menu ul {
  position: absolute;
  right: 0;
  z-index: 10;
  margin: 0.25rem 0 0;
  padding: 0.5rem;
  list-style: none;
  background: #fff;
  border: 1px solid #e3e3e8;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgb(0 0 0 / 8%);
  min-width: 14rem;
}

.data-table-menu li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0;
}

.data-table-move {
  display: flex;
  gap: 0.25rem;
}

.data-table-footer {
  margin-top: 0.5rem;
}

/* Toasts */
.toast-stack {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
  max-width: 24rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 10px rgb(0 0 0 / 35%);
}
.toast-success { border-color: #3fb950; }
.toast-error { border-color: var(--danger); }
.toast-info { border-color: var(--accent); }
.toast-dismiss {
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  margin-left: auto;
}

/* Email-verification banner (soft gate) */
.verify-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
}
.verify-banner button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}
.verify-banner__dismiss {
  margin-left: auto;
  border: none;
  background: none;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0 0.25rem;
}

/* Notification bell */
.notification-bell {
  position: relative;
}

.notification-bell summary {
  cursor: pointer;
  list-style: none;
}

.notification-bell .badge {
  background: var(--danger);
  color: var(--bg);
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 0 0.4em;
  vertical-align: top;
}

.notification-panel {
  position: absolute;
  right: 0;
  min-width: 20rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgb(0 0 0 / 35%);
  padding: 0.5rem;
  z-index: 50;
}

.notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 20rem;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  color: var(--text);
  font-weight: 400;
  cursor: pointer;
  padding: 0.4rem 0.5rem;
}

.notification-item.unread {
  font-weight: 600;
}

/* Visually hidden but available to assistive tech (live regions, hidden inputs). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-upload .dropzone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.file-upload .dropzone.dragging {
  border-color: var(--accent, #4a90d9);
  background: color-mix(in srgb, var(--accent, #4a90d9) 8%, var(--surface));
}

.file-upload .dropzone-hint {
  margin: 0;
}

.file-upload .hint {
  flex-basis: 100%;
  margin: 0.25rem 0 0;
  font-size: 0.85em;
}

.file-upload .upload-tasks {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.file-upload .upload-task {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-upload .upload-task .filename {
  font-weight: 600;
}

.file-upload .upload-task.error .error {
  color: var(--danger, #c0392b);
}

.file-upload .upload-task.success .success {
  color: var(--success, #2e7d32);
}

/* Global search (command palette, see components/command-palette.gts) */

.search-trigger kbd {
  padding: 0 0.3rem;
  margin-left: 0.25rem;
  font-size: 0.8em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.command-palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 10vh;
  background: rgb(0 0 0 / 45%);
}

.command-palette {
  width: min(560px, 92vw);
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 40px rgb(0 0 0 / 35%);
}

.command-palette-input {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.palette-hint,
.palette-empty {
  margin: 0.6rem 0.25rem 0.1rem;
}

.palette-heading {
  margin-top: 0.6rem;
  padding: 0 0.35rem 0.2rem;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.palette-option {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
}

.palette-option.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
}

.palette-secondary {
  font-size: 0.9em;
}

/* Deep-link landing flash (utils/highlight.ts adds/removes the class) */

@keyframes highlight-flash {
  0% {
    background-color: color-mix(in srgb, var(--accent) 35%, transparent);
  }

  100% {
    background-color: transparent;
  }
}

.highlight-flash {
  animation: highlight-flash 1.6s ease-out;
}
