/* Colors adapt via light-dark(): "auto" follows the OS, data-theme on <html> forces a mode. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f4f5f7, #11151b);
  --surface: light-dark(#ffffff, #1a2029);
  --text: light-dark(#1c2430, #e6e9ee);
  --muted: light-dark(#5f6b7a, #9aa5b4);
  --border: light-dark(#d9dee5, #2d3643);
  --primary: light-dark(#0f766e, #14b8a6);
  --primary-hover: light-dark(#0b5f58, #2dd4bf);
  --primary-text: light-dark(#ffffff, #062421);
  --danger: light-dark(#b42318, #f97066);
  --success: light-dark(#15803d, #4ade80);
  --open: light-dark(#b45309, #fbbf24);
  --open-bg: light-dark(#fef3c7, #3b2d0a);
  --assigned: light-dark(#1d4ed8, #93c5fd);
  --assigned-bg: light-dark(#dbeafe, #172a4d);
  --done: light-dark(#15803d, #86efac);
  --done-bg: light-dark(#dcfce7, #12321f);
  --cancelled: light-dark(#5f6b7a, #9aa5b4);
  --cancelled-bg: light-dark(#e5e7eb, #262d38);
  --radius: 10px;
  --shadow: 0 1px 2px light-dark(rgb(0 0 0 / 0.06), transparent), 0 1px 3px light-dark(rgb(0 0 0 / 0.08), transparent);
}

:root[data-theme='light'] {
  color-scheme: light;
}

:root[data-theme='dark'] {
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

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

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

h3 {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* --- Top bar --- */

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

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar nav a {
  color: var(--text);
  text-decoration: none;
}

/* --- Panels & layout --- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.panel.narrow {
  max-width: 420px;
  margin: 2rem auto;
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  align-items: start;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.page-header h1 {
  margin: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem;
}

.grow {
  flex: 1 1 10rem;
  min-width: 0;
}

.inline {
  display: inline;
}

.hint {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: normal;
  margin: 0.25rem 0;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.notice,
.error {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  margin: 0 0 1rem;
}

.notice {
  background: var(--done-bg);
  color: var(--done);
}

.error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

/* --- Forms --- */

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 600;
  font-size: 0.9rem;
}

label.checkbox {
  flex-direction: row;
  align-items: center;
  font-weight: normal;
}

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

input:not([type='checkbox']),
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-weight: normal;
}

.row > input,
.row > select {
  width: auto;
}

.row > input.grow,
.row > select.grow {
  flex: 1 1 10rem;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
.button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.button:hover {
  border-color: var(--muted);
}

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

button.primary,
.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

button.primary:hover,
.button.primary:hover {
  background: var(--primary-hover);
}

button.success {
  background: var(--success);
  border-color: var(--success);
  color: var(--primary-text);
}

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

button.link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  font-weight: normal;
  color: var(--muted);
}

/* --- Board --- */

.new-request {
  margin-bottom: 1.25rem;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}

.new-request > summary {
  list-style: none;
  width: 100%;
  min-height: 3rem;
  font-size: 1.05rem;
}

.new-request > summary::-webkit-details-marker {
  display: none;
}

.new-request[open] > summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.new-request > form {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}

.qty-input {
  flex: 0 0 6rem;
}

#board .lanes {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  align-items: start;
}

.board-footer {
  margin-top: 1rem;
  text-align: center;
}

.board-footer button.link {
  text-decoration: underline;
}

h2.spaced {
  margin-top: 1.75rem;
}

.lane h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.count {
  display: inline-block;
  min-width: 1.6rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--border);
  font-size: 0.8rem;
  text-align: center;
}

.card {
  margin-bottom: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--open);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card.status-assigned {
  border-left-color: var(--assigned);
}

.card.status-done {
  border-left-color: var(--done);
  opacity: 0.8;
}

.card.status-cancelled {
  border-left-color: var(--cancelled);
  opacity: 0.7;
}

.card.status-cancelled .item {
  text-decoration: line-through;
}

.card.mine {
  outline: 2px solid var(--assigned);
  outline-offset: -1px;
}

.card > summary {
  list-style: none;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
}

.card > summary::-webkit-details-marker {
  display: none;
}

.card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5rem;
  font-size: 1.1rem;
}

.qty {
  font-weight: 700;
}

.item {
  font-weight: 600;
}

.location::before {
  content: '→ ';
  color: var(--muted);
}

.location {
  font-size: 0.95rem;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.6rem;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.note {
  margin: 0.4rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.card-actions {
  padding: 0 0.9rem 0.8rem;
  border-top: 1px dashed var(--border);
}

.card-actions .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.assign-form {
  display: flex;
  gap: 0.5rem;
  flex: 1 1 14rem;
}

.assign-form select {
  flex: 1;
  width: auto;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge.open {
  background: var(--open-bg);
  color: var(--open);
}

.badge.assigned {
  background: var(--assigned-bg);
  color: var(--assigned);
}

.badge.done {
  background: var(--done-bg);
  color: var(--done);
}

.badge.cancelled {
  background: var(--cancelled-bg);
  color: var(--cancelled);
}

/* --- Lists --- */

.team-list,
.name-list,
.invite-list,
.member-list,
.admin-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.team-list li a {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.team-name {
  font-size: 1.1rem;
  font-weight: 600;
}

.team-counts {
  display: flex;
  gap: 0.4rem;
}

.name-list li,
.member-list li,
.admin-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.invite-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.admin-list .hint {
  margin: 0;
}

@media (max-width: 520px) {
  main {
    padding: 0.75rem;
  }

  .topbar nav {
    gap: 0.75rem;
    font-size: 0.9rem;
  }
}
