:root {
  color-scheme: light dark;
  --bg: #F5F1E5;
  --surface: #FFFFFF;
  --surface-2: #FFFDF7;
  --shell: #EBE6D6;
  --ink: #16302A;
  --ink-soft: #5E6B62;
  --border: rgba(27,59,50,0.09);
  --gold: #C98A1F;
  --gold-bg: rgba(239,174,65,0.16);
  --green-bg: rgba(52,110,58,0.12);
  --green-fg: #2C6B39;
  --red-bg: rgba(196,60,52,0.12);
  --red-fg: #B23B2E;
  --shadow: 0 1px 2px rgba(22,48,42,0.04), 0 12px 28px -12px rgba(22,48,42,0.14);
  --shadow-sm: 0 1px 2px rgba(22,48,42,0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10201B; --surface: #16302A; --surface-2: #1B372F; --shell: #0D1916;
    --ink: #F1EFE4; --ink-soft: #A7B6AE; --border: rgba(241,239,228,0.08);
    --gold: #EFAE41; --gold-bg: rgba(239,174,65,0.16);
    --green-bg: rgba(126,201,140,0.14); --green-fg: #7EC98C;
    --red-bg: rgba(224,110,100,0.16); --red-fg: #E08066;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 16px 32px -14px rgba(0,0,0,0.55);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10201B; --surface: #16302A; --surface-2: #1B372F; --shell: #0D1916;
  --ink: #F1EFE4; --ink-soft: #A7B6AE; --border: rgba(241,239,228,0.08);
  --gold: #EFAE41; --gold-bg: rgba(239,174,65,0.16);
  --green-bg: rgba(126,201,140,0.14); --green-fg: #7EC98C;
  --red-bg: rgba(224,110,100,0.16); --red-fg: #E08066;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 16px 32px -14px rgba(0,0,0,0.55);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); height: 100%; }
body {
  margin: 0;
  padding-block: 28px 48px;
  color: var(--ink);
  background: var(--bg);
  font-family: 'Manrope', -apple-system, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1160px; margin: 0 auto; padding-inline: 22px; }

.pillnav {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 10px 10px 22px;
  margin-bottom: 30px;
  box-shadow: var(--shadow-sm);
}
.pillnav .brand { font-weight: 800; letter-spacing: -0.01em; font-size: 15px; color: var(--ink); text-decoration: none; }
.pillnav .brand .dot { color: var(--gold); }
.pillnav .links { display: flex; gap: 4px; }
.pillnav .links a {
  text-decoration: none; color: var(--ink-soft); font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: 999px; transition: transform 160ms cubic-bezier(0.23,1,0.32,1), background 160ms ease, color 160ms ease;
}
.pillnav .links a.active { background: var(--ink); color: var(--bg); }
.pillnav .links a:active { transform: scale(0.97); }
.pillnav .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--gold-bg); color: var(--gold);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}

h1, h2 { text-wrap: balance; margin: 0; color: var(--ink); }
.eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-soft);
  font-weight: 700; margin: 0 0 14px;
}

.intro { margin-bottom: 28px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.intro h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; }
.intro p { color: var(--ink-soft); margin: 6px 0 0; max-width: 60ch; }
.breadcrumb { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 10px; }
.breadcrumb a { color: var(--ink-soft); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 34px; }
@media (max-width: 780px) { .stat-row { grid-template-columns: 1fr 1fr; } }
.shell { background: var(--shell); border-radius: 22px; padding: 6px; box-shadow: var(--shadow); }
.shell .core {
  background: var(--surface); border-radius: 17px; padding: 18px 18px 16px;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.4); height: 100%;
}
:root:not([data-theme="light"]) .shell .core { box-shadow: inset 0 1px 1px rgba(255,255,255,0.06); }
:root[data-theme="dark"] .shell .core { box-shadow: inset 0 1px 1px rgba(255,255,255,0.06); }
.core .k { font-size: 12px; color: var(--ink-soft); margin-bottom: 10px; font-weight: 600; }
.core .v { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.core .d { margin-top: 8px; font-size: 12.5px; }
.core .d.up { color: var(--green-fg); font-weight: 700; }

.layout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
section + section { margin-top: 30px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 6px; box-shadow: var(--shadow-sm); }
.panel-inner { padding: 20px 18px; }
.panel table { width: 100%; border-collapse: collapse; }
.panel th {
  text-align: left; font-size: 11.5px; color: var(--ink-soft); font-weight: 700;
  padding: 0 10px 10px; text-transform: uppercase; letter-spacing: 0.04em;
}
.panel td { padding: 12px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.panel tr:hover td { background: var(--gold-bg); }
.panel td:first-child, .panel th:first-child { padding-left: 14px; border-radius: 10px 0 0 10px; }
.panel td:last-child, .panel th:last-child { padding-right: 14px; border-radius: 0 10px 10px 0; }

.name-link { color: var(--ink); text-decoration: none; font-weight: 700; }
.name-link:hover { text-decoration: underline; }
.mono { font-family: 'Manrope', monospace; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 4px 11px; border-radius: 999px; }
.pill.active { background: var(--green-bg); color: var(--green-fg); }
.pill.unassigned { background: var(--border); color: var(--ink-soft); }
.pill.cancelled { background: var(--red-bg); color: var(--red-fg); }
.pill.type { background: var(--gold-bg); color: var(--gold); }

select.mini, input.mini {
  font-family: inherit; font-size: 12.5px; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 9px; background: var(--surface-2); color: var(--ink);
}

.btn {
  font-family: inherit; font-size: 12.5px; font-weight: 700; border-radius: 999px; cursor: pointer;
  padding: 9px 18px; border: none; transition: transform 140ms cubic-bezier(0.23,1,0.32,1);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:active { transform: scale(0.96); }
.btn-gold { background: var(--gold); color: #16302A; }
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--red-fg); border: 1px solid var(--red-bg); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { margin-bottom: 0; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 7px; }
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), .field select, .field textarea {
  width: 100%; font-family: inherit; font-size: 13px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--ink);
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.field input:-webkit-autofill, .field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink); caret-color: var(--ink);
  box-shadow: 0 0 0 1000px var(--surface-2) inset; transition: background-color 9999s ease-out;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--gold); }
.field-row { display: flex; gap: 8px; }
.field-row input { flex: 1; }

.field input[type="file"] {
  width: 100%; font-family: inherit; font-size: 12.5px; padding: 8px 10px;
  border: 1px dashed var(--border); border-radius: 12px; background: var(--surface-2); color: var(--ink-soft);
}
.field input[type="file"]::file-selector-button {
  font-family: inherit; font-size: 12.5px; font-weight: 700; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; margin-right: 10px; cursor: pointer;
}
.field input[type="file"]:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.detail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.detail-head h2 { font-size: 1.5rem; font-weight: 800; }
.sub-divider { border-top: 1px solid var(--border); margin-top: 22px; padding-top: 18px; }
.sub-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.sub-row .status-line { font-size: 13px; color: var(--ink-soft); }
.sub-row .status-line b.on { color: var(--green-fg); }
.sub-row .status-line b.off { color: var(--red-fg); }

.type-switch { display: flex; gap: 8px; margin-bottom: 22px; }
.type-switch a {
  flex: 1; text-align: center; text-decoration: none; font-size: 12.5px; font-weight: 700;
  padding: 9px; border-radius: 12px; border: 1px solid var(--border); color: var(--ink-soft); background: var(--surface-2);
}
.type-switch a.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.avatar-photo {
  width: 56px; height: 56px; border-radius: 16px; background: var(--gold-bg); color: var(--gold);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; flex-shrink: 0;
}

footer.credits {
  margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); flex-wrap: wrap; gap: 8px;
}

/* alerts (errores de validación, flash messages) */
.alert {
  border-radius: 14px; padding: 14px 18px; margin-bottom: 22px; font-size: 13.5px;
}
.alert ul { margin: 0; padding-left: 18px; }
.alert-error { background: var(--red-bg); color: var(--red-fg); }
.alert-info { background: var(--gold-bg); color: var(--gold); }

/* login card, sin pillnav (no autenticado todavía) */
.auth-shell {
  min-height: calc(100% - 76px);
  display: flex; align-items: center; justify-content: center;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand-mark {
  text-align: center; font-weight: 800; font-size: 20px; color: var(--ink); margin-bottom: 22px;
}
.auth-card .brand-mark .dot { color: var(--gold); }
.auth-card .field { margin-bottom: 16px; }
.auth-card .check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); margin-bottom: 20px; }
.auth-card button[type="submit"] { width: 100%; justify-content: center; }

.empty-state { padding: 30px 10px; text-align: center; color: var(--ink-soft); font-size: 13.5px; }

.helper-text { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); }

.inline-form { display: flex; gap: 6px; align-items: center; }

.design-picker.has-preview { display: grid; grid-template-columns: 1fr 280px; gap: 22px; align-items: start; }
@media (max-width: 640px) { .design-picker.has-preview { grid-template-columns: 1fr; } }
.phone-frame {
  background: var(--shell); border-radius: 34px; padding: 8px; box-shadow: var(--shadow);
  width: 100%; max-width: 280px; margin-inline: auto;
}
.phone-frame iframe {
  display: block; width: 100%; height: 580px; border: 0; border-radius: 27px; background: var(--surface-2);
}

a:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; }
  .btn:active, .pillnav .links a:active { transform: none; }
}

.client-picker { position: relative; }
.client-picker input.mini { width: 210px; }
.client-picker-list {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: 320px;
  margin: 0; padding: 4px; list-style: none; max-height: 260px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.client-picker-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; display: flex; flex-direction: column; }
.client-picker-list li small { color: var(--ink-soft); font-size: 11.5px; }
.client-picker-list li:hover, .client-picker-list li.is-active { background: var(--gold-bg); }
.client-picker-list li.is-empty { cursor: default; color: var(--ink-soft); }
.client-picker-list li.is-empty:hover { background: transparent; }

/* Editor de vcard del área de cliente: galería de diseños + tarjeta editable en iframe */
.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 18px; justify-items: center; }
.design-card {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 8px 8px 12px; border-radius: 26px; border: 1px solid var(--border);
  transition: transform .16s cubic-bezier(.23,1,.32,1), border-color .16s, box-shadow .16s;
}
.design-card:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: var(--shadow); }
.design-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.design-card .thumb { position: relative; width: 215px; height: 418px; overflow: hidden; border-radius: 20px; background: var(--surface-2); }
.design-card .thumb iframe { position: absolute; top: 0; left: 0; width: 390px; height: 760px; border: 0; transform: scale(.5513); transform-origin: top left; pointer-events: none; }
.design-card .design-name { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.ve-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.ve-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.ve-seg button { all: unset; cursor: pointer; padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-soft); transition: background .15s, color .15s; }
.ve-seg button[aria-pressed="true"] { background: var(--gold); color: #1a1a14; }
.ve-seg button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.ve-frame { max-width: 410px; }
.ve-frame iframe { height: min(78vh, 760px); min-height: 520px; background: #fff; }
.ve-photo { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.ve-hint { text-align: center; margin: 12px 0 0; }
.ve-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 22px; }
#ve-errors { margin-bottom: 14px; }
