:root {
  color-scheme: light;
  --bg: #e4ddd4;
  --side: rgba(236, 230, 222, 0.94);
  --line: #d4c8ba;
  --text: #3a342e;
  --muted: #7d7268;
  --accent: #d48962;
  --accent-text: #3a261c;
  --accent-dim: rgba(212, 137, 98, 0.18);
  --card: #efe8e0;
  --green: #2f7d58;
  --red: #b85a54;
  --blue: #6a96b4;
  --nav: #5a6874;
  --nav-active-bg: #d5e3ee;
  --nav-active: #2c4a5e;
  --input: #f3eee8;
  --hover: #e7ddd2;
  --row-line: #ddd2c6;
  --id: #5a6c7a;
  --link: #3d6584;
  --btn: #dce8f0;
  --flash-bg: #dceee4;
  --flash-text: #1e6240;
  --flash-err-bg: #f3ddd8;
  --flash-err-text: #864038;
  --drop: #e9e1d8;
  --danger: #a15c56;
  --danger-line: #e2b8b2;
  --dot-done: #cfe8db;
  --dot-wait: #f0d8c6;
  --dot-new: #d0e2ee;
  --dot-cancel: #edd4ce;
  --glow-blue: rgba(126, 160, 186, 0.22);
  --glow-peach: rgba(214, 150, 110, 0.2);
  --foot: #6a5e54;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b2128;
  --side: rgba(28, 36, 44, 0.94);
  --line: #3a4652;
  --text: #f3e7d4;
  --muted: #b7a898;
  --accent: #e0a06a;
  --accent-text: #2c2118;
  --accent-dim: rgba(224, 160, 106, 0.18);
  --card: #24303a;
  --green: #8fcfb0;
  --red: #e7a8a0;
  --blue: #9ec4dc;
  --nav: #e7dccb;
  --nav-active-bg: #31404c;
  --nav-active: #ffe7cf;
  --input: #1a222a;
  --hover: #2e3c48;
  --row-line: #33414d;
  --id: #e4d5c4;
  --link: #f0dcc4;
  --btn: #31404c;
  --flash-bg: #243c34;
  --flash-text: #d4f3e4;
  --flash-err-bg: #3d2c32;
  --flash-err-text: #ffd4cc;
  --drop: #1e2830;
  --danger: #e7b4ac;
  --danger-line: #7a4e52;
  --dot-done: #1e3c34;
  --dot-wait: #3a3228;
  --dot-new: #243848;
  --dot-cancel: #3a2c30;
  --glow-blue: rgba(120, 160, 190, 0.16);
  --glow-peach: rgba(224, 160, 106, 0.16);
  --foot: #e6d5c2;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1100px 520px at 0% -10%, var(--glow-blue), transparent 55%),
    radial-gradient(900px 480px at 100% 0%, var(--glow-peach), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }

.layout { display: flex; min-height: 100vh; }
.side {
  width: 248px;
  flex: none;
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  backdrop-filter: blur(8px);
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px; }
.side-hide, .side-show {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.side-hide { margin-left: auto; padding: 0; }
.side-show {
  display: none;
  position: fixed;
  z-index: 40;
  top: 14px;
  left: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}
html[data-side="hidden"] .side { display: none; }
html[data-side="hidden"] .side-show { display: inline-block; }
.mark {
  width: 28px;
  height: 28px;
  background: linear-gradient(160deg, #f3b183, #7eb4d4);
  clip-path: polygon(50% 8%, 92% 88%, 8% 88%);
}
.brand b { font-size: 18px; letter-spacing: 0.02em; }
.rate-box { padding: 0 8px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.rate-box strong { display: block; color: var(--text); font-size: 14px; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--nav);
}
.nav a.active { background: var(--nav-active-bg); color: var(--nav-active); }
.emoji-nav { font-size: 22px; line-height: 1; }
.op-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.op-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.op-card span { color: var(--muted); }
.op-add {
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border-style: dashed;
  color: var(--text);
  font-size: 36px;
  line-height: 1;
}
.op-add:hover { border-color: var(--accent); background: var(--accent-dim); }
.op-card .frozen { color: var(--danger); }
.title-row h1 { margin: 0; }
.side-foot { margin-top: auto; padding: 8px; color: var(--foot); font-size: 13px; }
.side-foot form { margin-top: 8px; }
.side-foot button, .theme-btn {
  background: none;
  border: 0;
  color: var(--foot);
  cursor: pointer;
  padding: 0;
}
.theme-btn { display: block; margin-bottom: 10px; }

.main { flex: 1; min-width: 0; padding: 28px 28px 48px; }
h1 { margin: 0 0 18px; font-size: 28px; font-weight: 650; }
.toolbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs a {
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid transparent;
}
.tabs a.active { color: var(--accent-text); border-color: var(--accent); background: var(--accent-dim); }
.tabs span { color: var(--muted); margin-left: 6px; }
.search input, .login input {
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  width: 220px;
}
.note { color: var(--muted); margin: 18px 0; }
.flash { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--flash-bg); color: var(--flash-text); }
.flash.err { background: var(--flash-err-bg); color: var(--flash-err-text); }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}
td { padding: 14px 10px; border-bottom: 1px solid var(--row-line); vertical-align: top; }
tr.order { cursor: pointer; }
tr.order:hover { background: var(--hover); }
.id { font-family: Consolas, monospace; font-size: 12px; color: var(--id); max-width: 180px; word-break: break-all; }
.id-copy {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
  word-break: break-all;
}
.id-copy:hover { color: var(--link); }
.people { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.person {
  display: flex;
  gap: 10px;
  align-items: baseline;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--input);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}
.person.picked { border-color: var(--accent); background: var(--accent-dim); }
.person span { color: var(--muted); font-size: 12px; }
.status { display: flex; gap: 8px; align-items: center; }
.poker-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}
.poker-cards {
  position: relative;
  width: 64px;
  height: 68px;
  flex: none;
  filter: drop-shadow(8px 12px 0 rgba(0, 0, 0, 0.22));
}
.mini-card {
  position: absolute;
  width: 46px;
  height: 62px;
  border-radius: 5px;
  border: 1px solid #d0d0d0;
  background: #fff;
  opacity: 0.55;
}
.mini-card.diamond {
  --suit: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 26'%3E%3Cpath fill='%23000' d='M10 0 L20 13 L10 26 L0 13 Z'/%3E%3C/svg%3E");
  left: 0;
  bottom: 0;
  z-index: 1;
  color: #e31b23;
  transform: rotate(-7deg);
  transform-origin: 72% 118%;
}
.mini-card.spade {
  --suit: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 64'%3E%3Cpath fill='%23000' d='M28 1C28 1 6 18 6 33c0 8.2 6.2 14 14 14 2.6 0 4.4-1.2 6.6-3.2 2.2 2 4 3.2 6.6 3.2 7.8 0 14-5.8 14-14C47.2 18 28 1 28 1zM22.4 45.2 18 62h20l-4.4-16.8c-2.2 1.7-4.2 2.3-5.6 1.7-1.4.6-3.4 0-5.6-1.7z'/%3E%3C/svg%3E");
  left: 14px;
  bottom: 0;
  z-index: 2;
  color: #1a1a1a;
  transform: rotate(6deg);
  transform-origin: 28% 118%;
}
.mini-card .idx {
  position: absolute;
  top: 3px;
  left: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.mini-card .idx b {
  font-family: Arial, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.mini-card .idx i,
.mini-card .face,
.mini-card .toe {
  display: block;
  background: currentColor;
  -webkit-mask: var(--suit) center / contain no-repeat;
  mask: var(--suit) center / contain no-repeat;
}
.mini-card .idx i { width: 8px; height: 9px; margin-top: 1px; }
.mini-card .face {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 22px;
  height: 26px;
  transform: translate(-50%, -50%);
}
.mini-card .toe {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 9px;
}
.poker-switch {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
}
.poker-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
}
.poker-toggle.on .mini-card { opacity: 1; }
.poker-toggle.on .mini-card.diamond { color: #ff2a2a; }
.poker-toggle.on .mini-card.spade { color: #141414; }
.poker-toggle.on .mini-card .idx b,
.poker-toggle.on .mini-card .idx i,
.poker-toggle.on .mini-card .face,
.poker-toggle.on .mini-card .toe {
  animation: suit-glow 1.5s ease-in-out infinite;
}
.poker-toggle.on .mini-card.diamond .idx b { text-shadow: 0 0 6px #ff6a6a; }
.poker-toggle.on .mini-card.spade .idx b { text-shadow: 0 0 6px #9ec0ff; }
.poker-toggle.on .poker-switch { background: var(--accent-dim); }
.poker-toggle.on .poker-switch::after {
  left: 18px;
  background: var(--accent);
}
@keyframes suit-glow {
  50% { filter: brightness(1.35); }
}
.dot { width: 18px; height: 18px; border-radius: 50%; margin-top: 2px; flex: none; }
.dot.done { background: var(--dot-done); box-shadow: inset 0 0 0 5px var(--green); }
.dot.waiting, .dot.confirming { background: var(--dot-wait); box-shadow: inset 0 0 0 5px var(--accent); }
.dot.processing { background: var(--dot-new); box-shadow: inset 0 0 0 5px var(--blue); }
.dot.cancelled { background: var(--dot-cancel); box-shadow: inset 0 0 0 5px var(--red); }
.status b { display: block; font-weight: 600; }
.status small, .muted, .time small { color: var(--muted); }
.status small.when { display: block; line-height: 1.35; margin-top: 2px; }
.age {
  display: inline-block;
  margin-top: 2px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.req { font-variant-numeric: tabular-nums; }
.copy {
  margin-left: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.money b { display: block; }
.time { line-height: 1.45; }
.linkish { color: var(--link); }

.deal { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr); gap: 18px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(90, 50, 30, 0.06);
}
.card h2 { margin: 0 0 8px; font-size: 16px; }
.req-big { font-size: 22px; letter-spacing: 0.03em; margin: 8px 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-top: 14px; }
.grid span { display: block; color: var(--muted); font-size: 12px; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  cursor: pointer;
  background: var(--btn);
}
.btn.gold { background: var(--accent); color: var(--accent-text); font-weight: 650; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger-line); }
.drop {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 16px;
  background: var(--drop);
}
.drop.over { border-color: var(--accent); background: var(--accent-dim); }
.drop .btn { width: 100%; margin-top: 12px; }
.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.mono { font-family: Consolas, monospace; font-size: 0.72em; word-break: break-all; }
.copy-btn {
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}
.previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.preview {
  width: 220px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--input);
}
.preview img, .preview-doc {
  width: 220px;
  height: 168px;
  object-fit: contain;
  display: grid;
  place-items: center;
  background: var(--drop);
}
.preview figcaption {
  padding: 6px 8px 0;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}
.preview form { margin: 0; }
.preview button {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  padding: 6px 8px 8px;
}
.staff-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  width: min(760px, 100%);
}
.staff-stack > * { margin: 0; }
.email-plaque {
  display: inline-block;
  margin: 8px 0 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--text);
  font-weight: 650;
}
.email-form { margin: 10px 0 4px; }
.email-form input {
  width: 100%;
  max-width: 360px;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.email-form .btn { margin-top: 10px; }
.op-card .email-plaque { margin: 0; font-size: 12px; font-weight: 600; }
.role-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}
.role-select { position: relative; display: inline-flex; align-items: center; }
.role-current {
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  padding: 2px 18px 2px 0;
}
.role-list {
  position: absolute;
  z-index: 8;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(20, 12, 8, 0.28);
}
.role-list[hidden] { display: none; }
.role-list button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.role-list button:hover,
.role-list button.on { background: var(--hover); }
.role-select::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 50%;
  margin-top: -2px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
  pointer-events: none;
}
.password-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.form .password-row input {
  flex: 1 1 220px;
  width: auto;
  max-width: none;
  min-width: 180px;
}
.form .password-row .btn { margin: 0; white-space: nowrap; }
.staff-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.staff-actions form { margin: 0; }
.password-once { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.form label { display: block; margin: 12px 0 6px; color: var(--muted); }
.password-row + label,
.form .password-row { margin-top: 0; }
.card.form > label:first-child { margin-top: 0; }
.form select,
.form input {
  width: 100%;
  max-width: 360px;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.form .btn { margin-top: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
dialog {
  width: min(560px, 92vw);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  padding: 18px;
}
dialog::backdrop { background: rgba(20, 12, 8, 0.55); }
dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.file-btn {
  display: inline-block;
  margin-top: 8px;
  background: var(--btn);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.file-btn input { display: none; }
.file-name { color: var(--muted); margin-top: 8px; }
.back { color: var(--muted); display: inline-block; margin-bottom: 12px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 16px 40px rgba(90, 50, 30, 0.08);
}
.login h1 { font-size: 26px; }
.login label { display: block; margin: 12px 0 6px; color: var(--muted); }
.login input { width: 100%; padding: 10px 12px; }
.login button.btn { width: 100%; margin-top: 16px; }
.login .theme-btn { margin: 14px 0 0; }

@media (max-width: 960px) {
  .layout { display: block; }
  .side { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .deal { grid-template-columns: 1fr; }
  .main { padding: 18px 14px 32px; }
}
