:root {
  --bg: #F6F4EE;
  --surface: #FFFFFF;
  --surface-muted: #FBFAF6;
  --surface-hover: #F3EEDE;
  --surface-sunken: #ECE6D4;
  --border: #EAE6D9;
  --text: #1C2B2A;
  --muted: #8B8578;
  --muted-bg: #F6F4EE;
  --accent: #2B4C4F;
  --accent-deep: #17292B;
  --accent-soft: rgba(43, 76, 79, .08);
  --accent-on: #F3F1E8;
  --seal: #B5452F;
  --seal-bg: rgba(181, 69, 47, .1);
  --ready: #3F6B4F;
  --ready-bg: rgba(63, 107, 79, .1);
  --dim: #C9C4B4;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(23, 31, 29, .04), 0 6px 18px -6px rgba(23, 31, 29, .10);
  --shadow-card-hover: 0 2px 4px rgba(23, 31, 29, .06), 0 16px 32px -10px rgba(23, 31, 29, .16);
  --shadow-hero: 0 10px 30px -8px rgba(23, 41, 43, .35);
}

[data-theme="dark"] {
  --bg: #171F1D;
  --surface: #1F2A27;
  --surface-muted: #1A2422;
  --surface-hover: #283631;
  --surface-sunken: #111816;
  --border: #2C3A36;
  --text: #F3F1E8;
  --muted: #9BA39C;
  --muted-bg: #26332F;
  --accent: #4E8577;
  --accent-deep: #0F1C1C;
  --accent-soft: rgba(134, 199, 183, .10);
  --seal: #E0806A;
  --seal-bg: rgba(224, 128, 106, .16);
  --ready: #86C79A;
  --ready-bg: rgba(134, 199, 154, .16);
  --dim: #3C4C47;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 24px -8px rgba(0, 0, 0, .5);
  --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, .35), 0 18px 36px -10px rgba(0, 0, 0, .6);
  --shadow-hero: 0 14px 34px -10px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Libre Franklin', sans-serif;
  transition: background .15s ease, color .15s ease;
}

h1, h2, .serif { font-family: 'Source Serif 4', serif; }

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

input, button { font-family: inherit; outline: none; }

.app { display: flex; flex-wrap: wrap; min-height: 100vh; }

.sidebar {
  flex: 1 1 252px;
  max-width: 252px;
  box-sizing: border-box;
  padding: 24px 18px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.sidebar .brand .mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar .brand .mark span { font-family: 'Source Serif 4', serif; font-weight: 700; color: var(--accent-on); font-size: 17px; }
.sidebar .brand .name { font-family: 'Source Serif 4', serif; font-weight: 600; font-size: 17px; }

.sidebar nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  text-decoration: none; color: var(--muted); transition: background-color .15s ease, color .15s ease;
}
.sidebar nav a svg { flex-shrink: 0; }
.sidebar nav a:hover { background: var(--surface-hover); color: var(--text); }
.sidebar nav a.active { background: var(--accent); color: var(--accent-on); box-shadow: var(--shadow-card); }
.sidebar nav a.active:hover { background: var(--accent); }

.sidebar .bottom {
  margin-top: auto; display: flex; flex-direction: column; gap: 12px;
  padding-top: 18px; border-top: 1px solid var(--border);
}

.theme-toggle {
  display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; font-weight: 600; cursor: pointer; text-align: left;
  transition: background-color .15s ease;
}
.theme-toggle:hover { background: var(--surface-hover); }
.theme-toggle svg { flex-shrink: 0; }
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline-flex; }

.user-row { display: flex; align-items: center; gap: 10px; padding: 0 2px; }
.user-row .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: var(--accent-on); font-size: 12px; font-weight: 600;
}
.user-row .name { font-size: 13px; font-weight: 600; }

.balance-hero {
  position: relative; overflow: hidden; border-radius: var(--radius-lg);
  background: linear-gradient(155deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: var(--accent-on); padding: 18px 18px 16px; box-shadow: var(--shadow-hero);
}
.balance-hero::after {
  content: ''; position: absolute; top: -40px; right: -40px; width: 120px; height: 120px;
  border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.14), transparent 70%);
}
.balance-hero .label { display: flex; align-items: center; gap: 6px; font-size: 11px; opacity: .8; position: relative; }
.balance-hero .amount { font-family: 'Source Serif 4', serif; font-weight: 700; font-size: 26px; margin: 6px 0 14px; position: relative; }
.balance-hero .amount .currency { font-size: 12px; font-weight: 500; opacity: .75; margin-left: 4px; }
.balance-hero .add-btn {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, .14); color: var(--accent-on); border: 1px solid rgba(255, 255, 255, .22);
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; text-decoration: none;
  transition: background-color .15s ease;
}
.balance-hero .add-btn:hover { background: rgba(255, 255, 255, .24); }

.main { flex: 999 1 560px; min-width: 0; box-sizing: border-box; padding: 36px 44px; display: flex; flex-direction: column; gap: 22px; }

.page-title { font-size: 32px; font-weight: 600; margin: 0 0 6px; letter-spacing: -.01em; }
.page-sub { font-size: 14px; color: var(--muted); margin: 0; }

.search-input {
  width: 100%; box-sizing: border-box; padding: 13px 16px; border: 1px solid var(--border);
  border-radius: var(--radius-md); font-size: 14px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-card);
}
.search-input::placeholder { color: var(--muted); }

.search-wrap { position: relative; }
.search-wrap .search-input { padding-left: 42px; }
.search-wrap-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; pointer-events: none; }

.catalog { display: flex; flex-direction: column; gap: 10px; }

.category { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); overflow: hidden; }
.category summary {
  display: flex; align-items: center; justify-content: space-between; padding: 15px 18px;
  cursor: pointer; font-size: 14px; font-weight: 600; list-style: none;
}
.category summary::-webkit-details-marker { display: none; }
.category summary .label { display: flex; align-items: center; gap: 10px; }
.category summary .label svg { color: var(--accent); flex-shrink: 0; }
.category summary .meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.category summary .count { background: var(--muted-bg); border-radius: 999px; padding: 3px 10px; }
.category summary .chevron::after { content: '+'; font-size: 14px; }
.category[open] summary .chevron::after { content: '−'; }

.service-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px;
  padding: 4px 16px 16px;
}

.service-card {
  display: flex; flex-direction: column; gap: 10px; padding: 16px;
  background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-md);
  text-decoration: none; color: var(--text); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.service-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); border-color: var(--accent); }
.service-card-top { display: flex; align-items: center; justify-content: space-between; }
.service-card .icon-chip {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.service-card .folio { font-family: 'Source Serif 4', serif; font-size: 12px; color: var(--muted); }
.service-card .title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.service-card .time { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.service-card .footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 4px; }
.service-card .price { font-family: 'Source Serif 4', serif; font-weight: 600; font-size: 15px; }
.service-card .pedir {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: var(--accent-on); border: none; border-radius: var(--radius-sm);
  padding: 7px 13px; font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: none;
}

.dashed-box {
  border: 1px dashed var(--border); border-radius: var(--radius-lg); padding: 36px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center; color: var(--muted); font-size: 13px;
}

.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); text-decoration: none; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 28px; max-width: 420px; }
.panel .eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.panel h2 { font-size: 22px; margin: 6px 0 4px; }
.panel .sub { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 0 0 20px; }
.panel label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.panel input[type="text"] {
  width: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; background: var(--surface-muted); color: var(--text);
}
.panel .terms { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-size: 13px; color: var(--muted); }
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; border: none; border-radius: var(--radius-sm); background: var(--accent);
  color: var(--accent-on); font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-primary:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }

.live-indicator { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ready); animation: live-pulse 2s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.stat-row { display: flex; flex-wrap: wrap; gap: 14px; }
.stat-card { flex: 1 1 140px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 16px 18px; display: flex; align-items: center; gap: 13px; }
.stat-card .stat-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--muted-bg); color: var(--muted); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.stat-card .label { font-size: 12px; margin-bottom: 4px; color: var(--muted); }
.stat-card .value { font-family: 'Source Serif 4', serif; font-size: 23px; font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.tab-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.tab:hover { background: var(--surface-hover); }
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-on); }
.tab.active:hover { background: var(--accent); }

.order-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 18px 22px;
}
.order-row-has-note { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.order-note {
  background: var(--surface-sunken); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); padding: 12px 22px; font-size: 13px; color: var(--muted); line-height: 1.5;
  box-shadow: inset 0 2px 4px -2px rgba(0, 0, 0, .18);
}
.order-note-seal { color: var(--seal); background: var(--seal-bg); border-color: var(--seal-bg); box-shadow: none; }
.order-row .left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.order-row .folio { font-family: 'Source Serif 4', serif; font-size: 13px; color: var(--muted); min-width: 60px; }
.order-row .title { font-size: 14px; font-weight: 600; display: block; }
.order-row .meta { font-size: 12px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px; }
.badge.lista { color: var(--ready); background: var(--ready-bg); }
.badge.rechazada { color: var(--seal); background: var(--seal-bg); }
.badge.proceso { color: var(--muted); background: var(--muted-bg); }
.download-btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--accent-on);
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; text-decoration: none;
}

.order-wrap { transition: background-color .4s ease; border-radius: var(--radius-lg); }
.order-wrap.just-updated { animation: order-flash 1.8s ease; }
@keyframes order-flash {
  0% { box-shadow: 0 0 0 2px var(--ready); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.banner { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: var(--radius-md); font-size: 14px; margin-bottom: 4px; }
.banner.ok { background: var(--ready-bg); color: var(--ready); }
.banner.error { background: var(--seal-bg); color: var(--seal); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card-hover); padding: 36px; }
.login-card h1 { font-size: 24px; margin: 0 0 6px; }
.login-card p.sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; background: var(--surface-muted); color: var(--text);
}

@media (max-width: 760px) {
  .sidebar { max-width: none; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; flex-wrap: wrap; align-items: center; gap: 14px; }
  .sidebar .bottom { margin-top: 0; border-top: none; padding-top: 0; flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; }
  .balance-hero { flex: 1 1 200px; }
  .main { padding: 22px 18px; }
  .service-grid { grid-template-columns: 1fr; }
}
