/* Spyder Controls RMA — shared styles (look & feel of the Rally booking app) */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --sunken: #f7f8fa;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-2: #eef0f3;
  --primary: #007aff;
  --primary-press: #0066d6;
  --primary-soft: #e8f2ff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --success: #1f9d55;
  --success-soft: #e7f6ee;
  --warn: #b7791f;
  --warn-soft: #fdf4e3;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(17,24,39,.04);
  --focus: 0 0 0 4px rgba(0,122,255,.16);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: 30px; font-weight: 700; line-height: 1.15; }
h2 { font-size: 17px; font-weight: 650; }
p { margin: 0; }
.ico { flex: none; display: inline-block; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ---------- Page shells ---------- */
.page { max-width: 640px; margin: 0 auto; padding: 36px 20px 64px; }
.page-head { margin-bottom: 22px; }
.page-head p { color: var(--muted); margin-top: 6px; }
.brand-line { display: flex; justify-content: flex-start; margin-bottom: 22px; }
.logo { display: block; height: auto; width: 150px; }
.logo-top { width: 132px; flex: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--text); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }

/* ---------- Form controls ---------- */
.field { margin-bottom: 16px; }
.field > label, .label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.req { color: var(--danger); margin-left: 2px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 11px 14px;
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none;
}
textarea.input { min-height: 112px; resize: vertical; line-height: 1.5; }
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--primary); box-shadow: var(--focus); }
select.input {
  padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.input.is-invalid, .is-invalid .input { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 4px rgba(229,72,77,.14); }
.error-text { color: var(--danger); font-size: 12.5px; margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* Choice tiles (checkboxes & radios) */
.choices { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color .15s, background .15s; font-size: 14.5px; line-height: 1.4;
}
.choice:hover { border-color: #cfd4dc; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .box {
  flex: none; width: 20px; height: 20px; margin-top: 0; border: 1.5px solid #c4c9d2; border-radius: 6px;
  display: grid; place-items: center; transition: all .15s; background: #fff;
}
.choice input[type=radio] + .box { border-radius: 50%; }
.choice .box::after { content: ""; width: 10px; height: 6px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px,-1px); opacity: 0; }
.choice input[type=radio] + .box::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: #fff; transform: none; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice input:checked + .box { background: var(--primary); border-color: var(--primary); }
.choice input:checked + .box::after { opacity: 1; }
.choice input:focus-visible + .box { box-shadow: var(--focus); }
.choices.inline { grid-template-columns: repeat(2, 1fr); }
.is-invalid .choice { border-color: #f3b6b8; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .05s, border-color .15s; text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-press); }
.btn-primary:disabled { background: #8fc0ff; cursor: default; }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { border-color: #cfd4dc; background: #fafafa; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(17,24,39,.05); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fbdcdc; }
.btn-block { width: 100%; height: 52px; font-size: 16px; }
.btn-sm { min-height: 36px; padding: 0 13px; font-size: 13.5px; border-radius: 10px; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; border-radius: 10px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.icon-btn { background: none; border: 0; padding: 6px; margin: -6px; border-radius: 8px; color: var(--text); cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: rgba(17,24,39,.06); }

/* ---------- Cards (review style) ---------- */
.card { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line-2); }
.card-head h2 { font-size: 16px; }
.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 9px 16px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.kv dd.empty { color: var(--faint); font-weight: 400; }
.note-box { background: var(--sunken); border-radius: 10px; padding: 12px 14px; margin-top: 14px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-box .label { font-size: 12.5px; margin-bottom: 4px; }
.tag-list { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* ---------- Stepper ---------- */
.steps { display: flex; gap: 6px; margin-bottom: 26px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: #dfe1e6; transition: background .3s; }
.steps span.on { background: var(--primary); }
.step-label { font-size: 12.5px; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.step { animation: fadeUp .25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.form-actions { margin-top: 24px; display: flex; gap: 10px; }
.form-actions .btn-primary { flex: 1; }
.alert { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alert-error { background: var(--danger-soft); color: #9b1c1f; }
.alert-success { background: var(--success-soft); color: #145c32; }
.alert-info { background: var(--primary-soft); color: #0a4a9c; }
.alert-warn { background: var(--warn-soft); color: #7a4d08; }

/* Success screen */
.success-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--success-soft); color: var(--success); display: grid; place-items: center; margin-bottom: 20px; }
.rma-number-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--sunken); border: 1px dashed #c9ced6; border-radius: 14px; padding: 16px 18px; margin: 4px 0 16px; }
.rma-number-box strong { font-size: 26px; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.ship-to { white-space: pre-line; font-weight: 600; font-size: 14.5px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Pills & chips ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-open { background: var(--primary-soft); color: #0a5bd1; }
.st-in-progress { background: var(--warn-soft); color: #95600a; }
.st-closed { background: var(--success-soft); color: #167a40; }
.st-disregard { background: #eef0f3; color: #6b7280; }
.cat { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.cat i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.chip-watch { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; color: #8a2e5c; background: #fbe9f2; padding: 2px 8px; border-radius: 6px; letter-spacing: .02em; }

/* ---------- Admin shell ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.88); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1320px; margin: 0 auto; height: 60px; padding: 0 20px; display: flex; align-items: center; gap: 22px; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); letter-spacing: -.01em; text-decoration: none; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 550; font-size: 14px; white-space: nowrap; text-decoration: none; }
.nav a:hover { color: var(--text); background: rgba(17,24,39,.05); }
.nav a.active { color: var(--text); background: rgba(17,24,39,.07); }
.usermenu { position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: #0a5bd1; font-weight: 700; font-size: 13px; display: grid; place-items: center; border: 0; cursor: pointer; }
.menu { position: absolute; right: 0; top: 44px; min-width: 220px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(17,24,39,.12); padding: 6px; }
.menu .who { padding: 10px 12px 8px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text); font-size: 14px; text-decoration: none; }
.menu a:hover { background: var(--sunken); }
.wrap { max-width: 1320px; margin: 0 auto; padding: 28px 20px 64px; }
.wrap-narrow { max-width: 860px; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head-row h1 { font-size: 28px; }
.head-row p { color: var(--muted); margin-top: 4px; }
.crumb { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; color: var(--muted); margin-bottom: 10px; font-weight: 550; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line-2); border-radius: 14px; padding: 14px 16px; text-decoration: none !important; color: inherit; transition: border-color .15s; display: block; }
.stat:hover { border-color: #cfd4dc; }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .t { font-size: 13px; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.stat.on { border-color: var(--primary); box-shadow: var(--focus); }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } .stat .n { font-size: 22px; } }

/* Search panel */
.search-card { padding: 16px; }
.search-main { display: flex; gap: 10px; }
.search-input { position: relative; flex: 1; }
.search-input .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search-input .input { padding-left: 42px; }
.filter-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-top: 12px; }
.filter-grid .field { margin: 0; }
.filter-grid .label { font-size: 12px; margin-bottom: 5px; color: var(--muted); }
.filter-grid .input { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.filter-grid select.input { padding-right: 34px; background-position: right 10px center; }
.filter-grid .span-2 { grid-column: span 2; }
@media (max-width: 1000px) { .filter-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .filter-grid { grid-template-columns: 1fr 1fr; } .filter-grid .span-2 { grid-column: span 2; } .search-main .btn span { display: none; } }
.seg { display: inline-flex; background: #e9eaef; border-radius: 10px; padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; }
.seg a { padding: 6px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; text-decoration: none; }
.seg a.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 18px 0 12px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.af { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; font-size: 12.5px; font-weight: 600; border-radius: 8px; background: var(--primary-soft); color: #0a5bd1; text-decoration: none !important; }
.af .ico { opacity: .7; }

/* Results table */
.table-card { padding: 0; overflow: hidden; }
.rtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.rtable th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 12px 14px; background: var(--sunken); border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.rtable th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.rtable th a.sorted { color: var(--text); }
.rtable td { padding: 13px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.rtable tr:last-child td { border-bottom: 0; }
.rtable tbody tr { cursor: pointer; transition: background .1s; }
.rtable tbody tr:hover { background: #fafbfc; }
.rtable td.bar { padding: 0; width: 4px; }
.rtable td.bar i { display: block; width: 4px; min-height: 100%; height: 100%; position: relative; }
.rtable tbody tr { position: relative; }
.rtable .rma { font-weight: 650; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rtable .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.rtable .clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rtable .nowrap { white-space: nowrap; }
.rowbar { box-shadow: inset 4px 0 0 var(--c, transparent); }
.empty-state { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty-state .ico { color: var(--faint); margin-bottom: 10px; }
@media (max-width: 860px) {
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { padding: 14px 16px 12px 18px; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
  .rtable td { padding: 0; border: 0; }
  .rtable td[data-m="hide"] { display: none; }
  .rtable td[data-m="right"] { text-align: right; grid-column: 2; grid-row: 1; }
  .rtable td[data-m="full"] { grid-column: 1 / -1; }
  .rtable .clip { max-width: none; }
}
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 4px 0; flex-wrap: wrap; }
.pager .btn-row .btn { flex: none; }

/* Detail page */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.quick { display: grid; gap: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: #c4c9d2; }
.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.k-created::before { background: var(--primary); }
.timeline li.k-status::before { background: var(--success); }
.timeline li.k-watchlist::before { background: #c2477f; }
.timeline .who { font-weight: 600; }
.timeline .when { color: var(--faint); font-size: 12.5px; }
.timeline .what { color: var(--text-2); white-space: pre-line; margin-top: 2px; overflow-wrap: anywhere; }
.watch-banner { display: flex; gap: 12px; align-items: flex-start; background: #fbe9f2; color: #6e1f47; border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; font-size: 14px; }
.watch-banner strong { display: block; }
.edit-section { scroll-margin-top: 80px; }
.sticky-save { position: sticky; bottom: 0; z-index: 10; background: linear-gradient(to top, var(--bg) 70%, rgba(242,242,247,0)); padding: 18px 0 16px; margin-top: 8px; display: flex; gap: 10px; }
.sticky-save .btn-primary { flex: 1; }

/* Generic data tables (users, watchlist) */
.dtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.dtable th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
.dtable td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.dtable tr:last-child td { border-bottom: 0; }
@media (max-width: 700px) {
  .dtable thead { display: none; }
  .dtable, .dtable tbody, .dtable tr, .dtable td { display: block; }
  .dtable tr { padding: 12px 0; border-bottom: 1px solid var(--line-2); }
  .dtable td { border: 0; padding: 3px 0; }
}
.legend { display: grid; gap: 8px; }
.legend div { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; flex: none; margin-top: 2px; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111827; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 550; box-shadow: 0 10px 30px rgba(0,0,0,.2); z-index: 100; animation: fadeUp .2s ease; }

/* Print */
@media print {
  body { background: #fff; font-size: 12px; }
  .topbar, .no-print, .sticky-save, .quick, .btn, .icon-btn { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .card { border: 1px solid #ddd; box-shadow: none; break-inside: avoid; }
}
@media (max-width: 560px) { .hide-sm { display: none; } .topbar-inner { gap: 10px; padding: 0 12px; } .nav a { padding: 8px 9px; } h1 { font-size: 26px; } .page { padding-top: 24px; } }
@media (max-width: 560px) { .logo { width: 120px; } .logo-top { width: 92px; } }
@media print { .logo-top { display: block !important; } }
.brand-tag { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line); line-height: 18px; }
@media (max-width: 560px) { .brand-tag { display: none; } }
