:root {
  --bg: #F6F4EE;
  --surface: #FFFFFF;
  --surface-muted: #FBFAF6;
  --border: #E4E0D4;
  --text: #1C2B2A;
  --muted: #8B8578;
  --muted-bg: #F6F4EE;
  --accent: #2B4C4F;
  --accent-on: #F3F1E8;
  --seal: #B5452F;
  --seal-bg: rgba(181, 69, 47, .1);
  --ready: #3F6B4F;
  --ready-bg: rgba(63, 107, 79, .1);
  --dim: #C9C4B4;
}

[data-theme="dark"] {
  --bg: #171F1D;
  --surface: #1F2A27;
  --surface-muted: #1A2422;
  --border: #32423E;
  --text: #F3F1E8;
  --muted: #9BA39C;
  --muted-bg: #26332F;
  --seal: #E0806A;
  --seal-bg: rgba(224, 128, 106, .16);
  --ready: #86C79A;
  --ready-bg: rgba(134, 199, 154, .16);
  --dim: #3C4C47;
}

* { 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 240px;
  max-width: 240px;
  box-sizing: border-box;
  padding: 28px 20px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.sidebar .brand { display: flex; align-items: center; gap: 12px; }
.sidebar .brand .mark {
  width: 36px; height: 36px; border-radius: 6px; 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: 18px; }
.sidebar .brand .name { font-family: 'Source Serif 4', serif; font-weight: 600; font-size: 18px; }

.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  display: block; padding: 9px 12px; border-radius: 7px; font-size: 14px; font-weight: 600;
  text-decoration: none; color: var(--muted);
}
.sidebar nav a.active { background: var(--accent); color: var(--accent-on); }

.sidebar .bottom {
  margin-top: auto; display: flex; flex-direction: column; gap: 12px;
  padding-top: 20px; 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: 7px;
  padding: 9px 12px; font-size: 13px; font-weight: 600; cursor: pointer; text-align: left;
}

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

.balance-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.balance-row .amount { font-family: 'Source Serif 4', serif; font-weight: 600; font-size: 14px; }
.balance-row a {
  background: var(--accent); color: var(--accent-on); border: none; border-radius: 6px;
  width: 24px; height: 24px; font-size: 14px; display: flex; align-items: center; justify-content: center;
  text-decoration: none; line-height: 1;
}

.main { flex: 999 1 560px; min-width: 0; box-sizing: border-box; padding: 40px 48px; display: flex; flex-direction: column; gap: 24px; }

.page-title { font-size: 30px; font-weight: 600; margin: 0 0 6px; }
.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: 8px; font-size: 14px; background: var(--surface); color: var(--text);
}
.search-input::placeholder { color: var(--muted); }

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

.category { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); overflow: hidden; }
.category summary {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  cursor: pointer; font-size: 14px; font-weight: 600; list-style: none;
}
.category summary::-webkit-details-marker { display: none; }
.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-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px; border-top: 1px solid var(--border);
}
.service-row:hover { background: var(--surface-muted); }
.service-row .left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.service-row .folio { font-family: 'Source Serif 4', serif; font-size: 13px; color: var(--muted); min-width: 46px; flex-shrink: 0; }
.service-row .title { font-size: 14px; font-weight: 600; display: block; }
.service-row .time { font-size: 12px; color: var(--muted); }
.service-row .right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.service-row .price { font-family: 'Source Serif 4', serif; font-weight: 600; font-size: 14px; }
.service-row .pedir {
  background: var(--accent); color: var(--accent-on); border: none; border-radius: 7px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
}

.dashed-box {
  border: 1px dashed var(--border); border-radius: 10px; padding: 32px 24px;
  text-align: center; color: var(--muted); font-size: 13px;
}

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 28px; max-width: 420px; }
.panel .eyebrow { font-size: 12px; font-weight: 600; color: var(--muted); }
.panel h2 { font-size: 22px; margin: 6px 0 4px; }
.panel .sub { 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: 8px; font-size: 14px; margin-bottom: 18px; background: var(--surface); color: var(--text);
}
.panel .terms { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-size: 13px; color: var(--muted); }
.panel .submit {
  width: 100%; padding: 14px; border: none; border-radius: 8px; background: var(--accent);
  color: var(--accent-on); font-size: 15px; font-weight: 600; cursor: pointer;
}

.stat-row { display: flex; flex-wrap: wrap; gap: 16px; }
.stat-card { flex: 1 1 140px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; }
.stat-card .label { font-size: 12px; margin-bottom: 6px; color: var(--muted); }
.stat-card .value { font-family: 'Source Serif 4', serif; font-size: 24px; font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.tab-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  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;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-on); }

.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: 10px; padding: 18px 22px;
}
.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 { 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: 7px; font-size: 13px; font-weight: 600; text-decoration: none;
}

.banner { padding: 14px 18px; border-radius: 8px; 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; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; 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: 8px; font-size: 14px; background: var(--bg); 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: 16px; }
  .sidebar .bottom { margin-top: 0; border-top: none; padding-top: 0; flex-direction: row; flex-wrap: wrap; }
  .main { padding: 24px 20px; }
}
