:root {
  --ink: #111111;
  --paper: #f4f1ea;
  --gold: #8e6f3e;
  --card: #ffffff;
  --line: #ddd6c8;
  --muted: #6b665c;
  --red: #9b2c2c;
  --green: #2f6b45;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
h1 { font-size: 1.5rem; margin: 0 0 1rem; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin: 0 0 1rem; font-weight: 600; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.loading, .empty { color: var(--muted); text-align: center; padding: 3rem 1rem; }
.empty.error { color: var(--red); }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--ink); background: transparent; border-radius: 6px;
  padding: 0.55rem 1rem; cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { background: rgba(17, 17, 17, 0.06); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--ink); color: var(--paper); }
button.primary:hover:not(:disabled) { background: var(--gold); border-color: var(--gold); }
button.danger { border-color: var(--red); color: var(--red); }
button.small { padding: 0.3rem 0.7rem; font-size: 0.87rem; }
button.link { border: 0; padding: 0; color: var(--gold); text-decoration: underline; background: none; }
button.link:hover:not(:disabled) { background: none; color: var(--ink); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
textarea { resize: vertical; }
.field { display: block; margin-bottom: 0.9rem; }
.field > span { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; }
.field small { display: block; color: var(--muted); margin-top: 0.25rem; overflow-wrap: anywhere; }
.grid2, .grid3 { display: grid; gap: 0.75rem; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: 1fr 1fr 1fr; }

.brand { display: flex; align-items: baseline; gap: 0.6rem; }
.brand strong { font-size: 1.35rem; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700; }
.brand span { color: var(--gold); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem; }

/* Sign-in */
.auth { max-width: 400px; margin: 0 auto; padding: 12vh 1rem 2rem; }
.auth .brand { justify-content: center; margin-bottom: 1.5rem; flex-direction: column; align-items: center; gap: 0.2rem; }
.auth form button.primary { width: 100%; margin-top: 0.25rem; }
.links { display: flex; justify-content: space-between; gap: 1rem; margin: 1rem 0 0; flex-wrap: wrap; }

/* Layout */
header {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 0.9rem 1.5rem; background: var(--ink); color: var(--paper);
}
header .brand span { color: #c9a56b; }
nav { display: flex; gap: 0.25rem; flex-wrap: wrap; flex: 1; }
.tab { border: 0; color: var(--paper); opacity: 0.7; padding: 0.4rem 0.8rem; border-radius: 6px; }
.tab:hover:not(:disabled) { background: rgba(244, 241, 234, 0.12); opacity: 1; }
.tab.on { opacity: 1; background: rgba(244, 241, 234, 0.16); }
.badge { background: var(--gold); color: #fff; border-radius: 999px; padding: 0 0.45rem; margin-left: 0.4rem; font-size: 0.75rem; }
.me { display: flex; gap: 0.9rem; align-items: center; font-size: 0.87rem; }
.me button.link { color: #c9a56b; }
.me button.link:hover:not(:disabled) { color: var(--paper); }
.view { max-width: 1180px; margin: 0 auto; padding: 1.5rem; }

.toolbar { display: flex; gap: 0.6rem; margin-bottom: 1rem; align-items: center; flex-wrap: wrap; }
.toolbar input[type="search"] { flex: 1; min-width: 220px; }
.toolbar select { width: auto; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
th, td { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.title { font-weight: 600; }
.artist { color: var(--muted); font-size: 0.9rem; }
.tag { margin-left: 0.5rem; font-size: 0.72rem; font-weight: 600; color: var(--gold); border: 1px solid var(--gold); border-radius: 4px; padding: 0.05rem 0.35rem; vertical-align: 1px; }
.rowactions { text-align: right; white-space: nowrap; }
.rowactions button { margin-left: 0.35rem; }
.pager { display: flex; gap: 0.6rem; align-items: center; justify-content: flex-end; margin-top: 0.9rem; color: var(--muted); }

.pill { font-size: 0.75rem; font-weight: 600; border-radius: 999px; padding: 0.1rem 0.6rem; white-space: nowrap; }
.pill.open { background: #f3e6cf; color: #7a5a22; }
.pill.invited { background: #e4e1da; color: #55504a; }
.pill.resolved { background: #dcebe0; color: var(--green); }

.cards { display: grid; gap: 0.75rem; }
.ticket { padding: 1rem 1.25rem; }
.ticket p:last-child { margin-bottom: 0; }
.tickethead { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; margin-bottom: 0.25rem; }
.note { border-left: 3px solid var(--gold); padding-left: 0.75rem; }

.actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.25rem; flex-wrap: wrap; }
.actions.left { justify-content: flex-start; margin-top: 0.75rem; }
.spacer { flex: 1; }

/* Upload */
.drop {
  border: 2px dashed var(--gold); border-radius: 10px; padding: 2.25rem 1rem; text-align: center;
  cursor: pointer; margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.2rem; background: rgba(142, 111, 62, 0.05);
}
.drop.over { background: rgba(142, 111, 62, 0.16); }
.drop span { color: var(--muted); }
.queue td { padding: 0.3rem 0.35rem; }
.queue input { padding: 0.35rem 0.5rem; }
.queue .narrow { width: 12%; }
.queue .tiny { width: 7%; }
.status { font-size: 0.85rem; white-space: nowrap; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.status.done { color: var(--green); }
.status.failed, .status.duplicate { color: var(--red); }

dialog { border: 0; border-radius: 12px; padding: 1.5rem; width: min(560px, calc(100vw - 2rem)); color: var(--ink); background: var(--card); }
dialog::backdrop { background: rgba(17, 17, 17, 0.55); }

#toast {
  position: fixed; inset: auto auto 1.5rem 50%; transform: translateX(-50%); margin: 0; border: 0;
  background: var(--ink); color: var(--paper); padding: 0.7rem 1.1rem; border-radius: 8px;
  max-width: calc(100vw - 2rem);
}
#toast.error { background: var(--red); }

.pick { width: 2.2rem; text-align: center; padding-right: 0; }
.pick input { width: 1.05rem; height: 1.05rem; accent-color: var(--gold); cursor: pointer; }
#dock { position: fixed; left: 0; right: 0; bottom: 0; background: var(--ink); color: var(--paper); box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.2); }
.dockrow { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1.5rem; max-width: 1180px; margin: 0 auto; flex-wrap: wrap; }
.dockrow + .dockrow:not(.hidden) { border-top: 1px solid rgba(244, 241, 234, 0.2); }
.dockrow button { border-color: var(--paper); color: var(--paper); }
.dockrow button:hover:not(:disabled) { background: rgba(244, 241, 234, 0.15); }
.dockrow button.primary { background: var(--gold); border-color: var(--gold); color: #fff; }
.dockrow audio { flex: 1; min-width: 220px; height: 36px; }
.nowplaying { font-weight: 600; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.docked .view { padding-bottom: 9rem; }
body.docked #toast { bottom: 8.5rem; }
.cartlist { max-height: 50vh; overflow: auto; }
.cartitem { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.toolbar input[type="text"], .toolbar input[type="email"] { flex: 1; min-width: 180px; }

@media (max-width: 760px) {
  .opt { display: none; }
  header { padding: 0.75rem 1rem; gap: 0.75rem; }
  .view { padding: 1rem; }
  .rowactions button { margin: 0.15rem 0 0.15rem 0.3rem; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .team th:nth-child(5), .team td:nth-child(5) { display: none; }
}
