:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0a0a0a;
  --elevated: #111111;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f5f5;
  --muted: #8a8a8a;
  --faint: #5c5c5c;
  --accent: #ffffff;
  --danger: #ff453a;
  --ok: #30d158;
  --warn: #ffd60a;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }

.wrap {
  width: min(400px, calc(100vw - 2.5rem));
  max-width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 0;
  overflow-x: hidden;
}
/* iPhone: vertical centering + keyboard = page jump on focus */
@media (max-width: 720px) {
  .wrap {
    justify-content: flex-start;
    padding: 2.25rem 0 4rem;
  }
}

.brand {
  text-align: center;
  margin-bottom: 2rem;
}
.brand-badge { display: none; }
.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 560;
  letter-spacing: -0.03em;
}
.brand p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.card {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  animation: rise 0.35s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 560;
  letter-spacing: -0.03em;
  text-align: center;
}
.card .sub {
  margin: 0 0 1.5rem;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
  text-align: center;
}

label {
  display: block;
  margin: 0 0 0.45rem;
  color: var(--faint);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  background: var(--elevated);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  outline: none;
  font-size: 16px; /* iOS: <16px triggers zoom/jump on focus */
  transition: border-color 0.15s ease, background 0.15s ease;
}
/* Native iOS date control is wider than the field — clip & normalize */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  line-height: 1.25;
}
input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}
input:focus,
select:focus,
textarea:focus {
  border-color: rgba(255, 255, 255, 0.35);
  background: #141414;
}

.file-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 132px;
  padding: 1.15rem 1rem;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.file-drop:hover,
.file-drop:focus-within {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
}
.file-drop.dragover {
  border-color: #fff;
  border-style: solid;
  background: rgba(255, 255, 255, 0.08);
}
.file-drop.has-file {
  border-style: solid;
  border-color: rgba(48, 209, 88, 0.35);
  background: rgba(48, 209, 88, 0.06);
}
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
  background: transparent;
}
.file-drop-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.file-drop-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.file-drop-title {
  font-size: 0.95rem;
  font-weight: 560;
  letter-spacing: -0.02em;
  color: var(--text);
}
.file-drop-sub {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}
.file-drop-name {
  font-size: 0.82rem;
  color: var(--ok);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 0.5rem;
}
textarea { min-height: 96px; resize: vertical; }
input:disabled {
  opacity: 0.55;
}

.row {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.row > * { flex: 1; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 980px;
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  font-weight: 560;
  letter-spacing: -0.01em;
  transition: opacity 0.15s ease, transform 0.08s ease;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  width: 100%;
  margin-top: 1rem;
  background: #fff;
  color: #000;
}
.btn-primary:hover { opacity: 0.92; }
.btn-primary .spinner {
  border-color: rgba(0,0,0,0.2);
  border-top-color: #000;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-strong);
}
.btn-danger {
  background: transparent;
  color: #ff6961;
  border: 1px solid rgba(255, 69, 58, 0.35);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 0;
  width: 100%;
  margin-top: 0.75rem;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin: 0.25rem 0 0.5rem;
}
.device-btn {
  background: var(--elevated);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 1rem 0.4rem;
  cursor: pointer;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.device-btn.selected {
  border-color: #fff;
  background: #161616;
}

.msg {
  margin-top: 1rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  border: 1px solid var(--line);
  background: var(--surface);
}
.msg-info { color: var(--text); }
.msg-ok {
  color: #d2f5d8;
  border-color: rgba(48, 209, 88, 0.25);
}
.msg-err {
  color: #ffb4ae;
  border-color: rgba(255, 69, 58, 0.28);
}
.msg-warn {
  color: #ffe8a3;
  border-color: rgba(255, 214, 10, 0.25);
}

.slot {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  margin-top: 0.75rem;
  background: var(--surface);
}
.slot .meta {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}
.slot a.link {
  word-break: break-all;
  font-size: 0.86rem;
  color: var(--text);
}

.issue-status {
  margin-top: 0.65rem;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d0d0d;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.4;
}
.issue-status strong {
  color: var(--text);
  font-weight: 560;
}

.delivery-card {
  margin-top: 0.25rem;
  padding: 1.1rem;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  text-align: center;
}
.delivery-card .label {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.65rem;
}
.delivery-card .link-box {
  word-break: break-all;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text);
  padding: 0.85rem;
  border-radius: 12px;
  background: #0a0a0a;
  border: 1px solid var(--line);
  text-align: left;
  margin-bottom: 0.75rem;
}
.delivery-actions {
  display: grid;
  gap: 0.5rem;
}

.pending-screen .wait-panel {
  text-align: center;
  padding: 0.75rem 0 1.25rem;
}
.pending-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 560;
  letter-spacing: -0.02em;
}
.pulse-ring {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.15rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
}
.pulse-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.22);
  animation: ping 1.6s ease-out infinite;
}
.pulse-ring .hourglass {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
  border-top-color: #fff;
  animation: spin 0.85s linear infinite;
}
@keyframes ping {
  0% { transform: scale(0.85); opacity: 0.8; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

.working-screen .steps {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.5rem;
}
.working-screen .step {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--faint);
  font-size: 0.9rem;
  transition: color 0.25s ease, opacity 0.25s ease;
}
.working-screen .step .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
  transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}
.working-screen .step.active {
  color: var(--text);
}
.working-screen .step.active .dot {
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.12);
  transform: scale(1.15);
  animation: pulse 1.2s ease-in-out infinite;
}
.working-screen .step.done {
  color: var(--muted);
}
.working-screen .step.done .dot {
  background: #6a6a6a;
}

.tv-success-screen {
  text-align: center;
  animation: rise 0.4s ease both;
}
.success-burst {
  width: 88px;
  height: 88px;
  margin: 0.25rem auto 1.25rem;
  position: relative;
  display: grid;
  place-items: center;
}
.success-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(48, 209, 88, 0.45);
  animation: successPop 0.55s ease-out both, successPulse 1.6s ease-out 0.45s 2;
}
.success-check {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #30d158;
  color: #04140a;
  font-size: 1.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  animation: successPop 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
  box-shadow: 0 0 0 8px rgba(48, 209, 88, 0.12);
}
@keyframes successPop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes successPulse {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.55); opacity: 0; }
}

.pin-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.35rem 0 0.25rem;
  flex-wrap: nowrap;
}
.pin-box {
  width: 2.15rem;
  height: 2.55rem;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 560;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--elevated);
  padding: 0;
}
.pin-box:focus {
  border-color: rgba(255,255,255,0.4);
  outline: none;
}
.pin-dash {
  color: var(--muted);
  font-size: 1.1rem;
  padding: 0 0.15rem;
}
.ext-hint {
  margin-top: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.device-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.toggle-row:last-child { border-bottom: 0; }
.switch {
  position: relative;
  width: 46px;
  height: 28px;
  background: #2a2a2a;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: background 0.2s ease;
}
.switch.on { background: #fff; }
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #111;
  transition: transform 0.2s ease;
}
.switch.on::after {
  transform: translateX(18px);
  background: #000;
}

.hidden { display: none !important; }
.footer { display: none; }

.spinner {
  width: 14px;
  height: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.75s linear infinite;
  vertical-align: -2px;
  margin-right: 0.45rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Admin denser layout still inherits the same tokens */
.admin-shell .wrap {
  width: min(920px, calc(100vw - 2.5rem));
  justify-content: flex-start;
  padding-top: 2.5rem;
}
.admin-shell .brand {
  text-align: left;
  margin-bottom: 1.25rem;
}
.admin-shell .card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.25rem;
  background: var(--surface);
}
.admin-shell .card h2,
.admin-shell .card .sub { text-align: left; }

@media (max-width: 420px) {
  .device-grid { grid-template-columns: 1fr; }
  .wrap { width: min(100vw - 2rem, 400px); }
}

section {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.turnstile-wrap {
  margin: 0.85rem 0 0.15rem;
  display: flex;
  justify-content: center;
  min-height: 0;
}
.turnstile-wrap:empty { display: none; }

/* Custom desktop date picker */
.dp {
  position: relative;
  width: 100%;
  min-width: 140px;
}
.dp-display {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--elevated);
  border-radius: 12px;
  padding: 0.9rem 2.4rem 0.9rem 1rem;
  outline: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 16px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.dp-display:focus,
.dp.open .dp-display {
  border-color: rgba(255, 255, 255, 0.35);
  background-color: #141414;
}
.dp-pop {
  display: none;
  position: absolute;
  z-index: 80;
  top: calc(100% + 6px);
  left: 0;
  width: min(292px, 92vw);
  padding: 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #121212;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  animation: rise 0.18s ease both;
}
.dp.open .dp-pop { display: block; }
.dp-pop-portal {
  display: block;
  position: fixed;
  z-index: 10000;
  top: 0;
  left: 0;
}
.dp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.dp-title,
.dp-title-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 560;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: 8px;
}
.dp-title-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}
.dp-nav {
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.dp-nav:hover { border-color: var(--line-strong); }
.dp-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin: 0.15rem 0 0.25rem;
}
.dp-chip {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}
.dp-chip:hover {
  background: rgba(255, 255, 255, 0.1);
}
.dp-chip.today {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}
.dp-chip.selected {
  background: #fff;
  color: #000;
  font-weight: 600;
}
.dp-chip.selected:hover {
  background: #fff;
}
.dp-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 0.25rem;
  color: var(--faint);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
}
.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.dp-day {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.88rem;
}
.dp-day.empty {
  cursor: default;
  pointer-events: none;
}
.dp-day:hover:not(.empty) {
  background: rgba(255, 255, 255, 0.08);
}
.dp-day.today {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}
.dp-day.selected {
  background: #fff;
  color: #000;
  font-weight: 600;
}
.dp-day.selected:hover {
  background: #fff;
}
.dp-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
}
.dp-foot button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0.25rem 0.35rem;
  border-radius: 8px;
}
.dp-foot button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

td .dp { min-width: 150px; }
td .dp-display { padding: 0.45rem 2rem 0.45rem 0.65rem; border-radius: 10px; font-size: 0.9rem; }
