/* ----------------------------------------------------------------------
   Base styles + shared components.
   Visual system aligned with the v17 reference (red + black, large radii,
   monospace numerals, soft red glow background, gradient bar on cards).
   ---------------------------------------------------------------------- */

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

html,
body {
  margin: 0;
  min-height: 100vh;
}

body {
  background: var(--page-wash);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
h4,
p,
pre {
  margin: 0;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.number {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 10000;
  padding: 10px 14px;
  background: var(--text);
  color: #ffffff;
  font-weight: 700;
  border-radius: var(--radius-sm);
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 12px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  color: #ffffff;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Eyebrow (the accented mono uppercase tag) ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: '';
  width: 28px;
  height: 2px;
  background: var(--accent);
}

.eyebrow.no-bar::before {
  display: none;
}

/* ---------- Buttons ---------- */
.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-on);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease),
              border-color var(--motion-fast) var(--ease),
              color var(--motion-fast) var(--ease),
              transform var(--motion-fast) var(--ease);
}

.btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn-secondary {
  background: var(--surface);
  border-color: color-mix(in oklab, var(--accent), var(--line) 40%);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  transform: none;
}

.btn-dark {
  background: var(--brand-black);
  border-color: var(--brand-black);
}

.btn-dark:hover {
  background: #1a1a1a;
  border-color: #1a1a1a;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #991b1b;
  border-color: #991b1b;
}

.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-lg {
  min-height: 50px;
  padding: 0 22px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

/* ---------- Form fields ---------- */
.field {
  display: grid;
  gap: 7px;
}

.field-label,
.field > label {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.005em;
}

.field input:not([type='checkbox']):not([type='radio']):not([type='range']),
.field select,
.field textarea {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 13px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  outline: none;
  transition: border-color var(--motion-fast) var(--ease),
              box-shadow var(--motion-fast) var(--ease);
}

.field textarea {
  height: auto;
  min-height: 88px;
  padding: 12px 13px;
  font-weight: 500;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.field-mono input {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 16px;
}

.field-hint {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.field-hint[data-state="ok"] {
  color: var(--success);
  font-weight: 700;
}

.field-hint[data-state="invalid"],
.field-hint[data-state="forbidden"],
.field-hint[data-state="long"],
.field-hint.error {
  color: var(--accent);
  font-weight: 700;
}

.field-hint[data-state="short"] {
  color: var(--warn);
  font-weight: 700;
}

/* ---------- Tags / pills ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag.is-success,
.tag.is-on {
  border-color: rgba(22, 101, 52, 0.18);
  background: var(--success-soft);
  color: var(--success);
}

.tag.is-warn {
  border-color: rgba(180, 83, 9, 0.22);
  background: var(--warn-soft);
  color: var(--warn);
}

.tag.is-danger,
.tag.is-off {
  border-color: rgba(185, 28, 28, 0.2);
  background: var(--danger-soft);
  color: var(--danger);
}

.tag-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- Card (the workhorse panel from v17) ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.card.card-bar::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--gradient-brand-bar);
  z-index: 1;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.card-head h2,
.card-head h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.card-head .subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.card-body {
  padding: 20px;
}

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--text);
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity var(--motion-base) var(--ease),
              transform var(--motion-base) var(--ease);
  pointer-events: auto;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--text); }

/* ---------- Dialog ---------- */
.dialog-mask {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 5, 0.45);
  opacity: 0;
  transition: opacity var(--motion-base) var(--ease);
}

.dialog-mask.show {
  opacity: 1;
}

.dialog {
  width: min(440px, calc(100vw - 32px));
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-hero);
  display: grid;
  gap: 14px;
}

.dialog h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.dialog p {
  color: var(--text-2);
  line-height: 1.55;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Quote progress bar ---------- */
.quote-progress {
  position: relative;
  min-height: 38px;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--accent-ring);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.quote-progress.hidden {
  display: none;
}

.quote-progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 38%;
  background: var(--accent);
  opacity: 0.16;
  animation: quote-progress 1.6s var(--ease) infinite;
}

.quote-progress-text {
  position: relative;
  z-index: 1;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

@keyframes quote-progress {
  0% { transform: translateX(-60%); }
  100% { transform: translateX(260%); }
}

@media (prefers-reduced-motion: reduce) {
  .quote-progress-bar {
    animation: none;
    opacity: 0.22;
    width: 100%;
  }
}

/* ---------- Floating contact card ---------- */
.app-contact {
  position: fixed;
  left: 18px;
  bottom: 16px;
  z-index: 80;
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.app-contact a {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.app-contact a:hover {
  color: var(--accent);
}

@media (max-width: 480px) {
  .app-contact {
    position: static;
    margin: 16px;
  }
}

/* ---------- Tabular content ---------- */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* ---------- Empty state ---------- */
.empty {
  padding: 32px 18px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

/* ---------- Background decoration container (kept inert; no animations) ---- */
.bg-decor {
  display: none;
}

/* ----------------------------------------------------------------------
   Login character stage (1:1 port of the original 4-color block animation
   from the production project: purple sedan, black coupe, orange round,
   yellow round-with-mouth). Eyes track the cursor; no other motion.
   ---------------------------------------------------------------------- */

.console-auth-stage .login-character {
  position: absolute;
  bottom: 0;
  transform-origin: bottom center;
  transition: transform 180ms var(--ease);
  --look-x: 0px;
  --look-y: 0px;
  --tilt: 0deg;
}

.console-auth-stage .character-purple {
  left: 27%;
  bottom: 14%;
  width: 30%;
  height: 62%;
  border-radius: 11px 11px 4px 4px;
  background: #6e3ff4;
  transform: skewX(var(--tilt));
  z-index: 1;
}

.console-auth-stage .character-black {
  left: 52%;
  bottom: 0;
  width: 21%;
  height: 56%;
  border-radius: 7px 7px 2px 2px;
  background: #242424;
  transform: skewX(var(--tilt));
  z-index: 2;
}

.console-auth-stage .character-orange {
  left: 6%;
  bottom: 0;
  width: 44%;
  height: 35%;
  border-radius: 999px 999px 0 0;
  background: #ff9b62;
  transform: skewX(var(--tilt));
  z-index: 4;
}

.console-auth-stage .character-yellow {
  right: 6%;
  bottom: 0;
  width: 28%;
  height: 40%;
  border-radius: 999px 999px 0 0;
  background: #eee052;
  transform: skewX(var(--tilt));
  z-index: 3;
}

.console-auth-stage .login-eye,
.console-auth-stage .login-dot-eye {
  position: absolute;
  transform: translate(var(--look-x), var(--look-y));
  transition: transform 70ms linear;
}

.console-auth-stage .login-eye {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
}

.console-auth-stage .login-eye span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #111111;
  transform: translate(calc(-50% + var(--look-x) * .34), calc(-50% + var(--look-y) * .34));
}

.console-auth-stage .character-purple .eye-left {
  left: 34%;
  top: 15%;
}

.console-auth-stage .character-purple .eye-right {
  left: 58%;
  top: 15%;
}

.console-auth-stage .character-black .eye-left {
  left: 34%;
  top: 17%;
}

.console-auth-stage .character-black .eye-right {
  left: 62%;
  top: 17%;
}

.console-auth-stage .login-dot-eye {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #141414;
}

.console-auth-stage .character-orange .eye-left {
  left: 45%;
  top: 43%;
}

.console-auth-stage .character-orange .eye-right {
  left: 64%;
  top: 43%;
}

.console-auth-stage .character-yellow .eye-left {
  left: 51%;
  top: 27%;
}

.console-auth-stage .character-yellow .eye-right {
  left: 73%;
  top: 27%;
}

.console-auth-stage .login-mouth {
  position: absolute;
  left: 38%;
  top: 58%;
  width: 50%;
  height: 3px;
  border-radius: 99px;
  background: #141414;
}

@media (prefers-reduced-motion: reduce) {
  .console-auth-stage .login-character,
  .console-auth-stage .login-eye,
  .console-auth-stage .login-dot-eye {
    transition: none;
  }
}
