:root {
  --bg: #fff7fb;
  --card: #ffffff;
  --card-soft: #fff0f7;
  --text: #2a2430;
  --muted: #746b7a;
  --primary: #d63384;
  --primary-dark: #aa2265;
  --line: #f0d9e7;
  --warning: #ffb703;
  --success: #2a9d8f;
  --danger: #d62828;
  --accent-light: #ffe2f0;
  --accent-strong: rgba(214, 51, 132, 0.12);
  --sidebar-grad-1: #ffffff;
  --sidebar-grad-2: #fff2f7;
  --shadow: 0 14px 35px rgba(214, 51, 132, 0.10);
}

body.theme-lila {
  --bg: #faf7ff;
  --primary: #8b5cf6;
  --primary-dark: #6d3fe2;
  --line: #e8defd;
  --accent-light: #efe7ff;
  --accent-strong: rgba(139, 92, 246, 0.12);
  --sidebar-grad-1: #ffffff;
  --sidebar-grad-2: #f3eeff;
  --shadow: 0 14px 35px rgba(139, 92, 246, 0.10);
}

body.theme-menta {
  --bg: #f4fffb;
  --primary: #17a589;
  --primary-dark: #0f7f69;
  --line: #d4f2ea;
  --accent-light: #ddfbf3;
  --accent-strong: rgba(23, 165, 137, 0.12);
  --sidebar-grad-1: #ffffff;
  --sidebar-grad-2: #ecfffa;
  --shadow: 0 14px 35px rgba(23, 165, 137, 0.10);
}

body.theme-durazno {
  --bg: #fff9f3;
  --primary: #f08a5d;
  --primary-dark: #d66b3f;
  --line: #f7dccf;
  --accent-light: #ffe8dc;
  --accent-strong: rgba(240, 138, 93, 0.15);
  --sidebar-grad-1: #ffffff;
  --sidebar-grad-2: #fff3ea;
  --shadow: 0 14px 35px rgba(240, 138, 93, 0.12);
}

body.theme-cielo {
  --bg: #f5fbff;
  --primary: #3182ce;
  --primary-dark: #2365a3;
  --line: #d6e8f7;
  --accent-light: #e6f2fd;
  --accent-strong: rgba(49, 130, 206, 0.12);
  --sidebar-grad-1: #ffffff;
  --sidebar-grad-2: #eff7ff;
  --shadow: 0 14px 35px rgba(49, 130, 206, 0.10);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, var(--bg), #ffffff 55%);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 270px;
  background: linear-gradient(180deg, var(--sidebar-grad-1), var(--sidebar-grad-2));
  border-right: 1px solid var(--line);
  padding: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.logo {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--accent-light), #fff);
  border: 1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 24px;
  box-shadow: var(--shadow);
}
.brand strong { font-size: 17px; }
.brand small { display:block; color: var(--muted); margin-top:4px; }
nav { display: grid; gap: 8px; }
nav a {
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--text);
  transition: .2s ease;
}
nav a.active, nav a:hover {
  background: var(--accent-light);
  color: var(--primary-dark);
  font-weight: 700;
  transform: translateX(2px);
}
.content { flex: 1; padding: 28px; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}
h1 { margin: 0 0 6px; font-size: 30px; }
h2 { margin-top: 0; }
p { line-height: 1.55; margin-top: 0; }
.muted { color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 .card {
  position: relative;
  overflow: hidden;
}
.grid-4 .card::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--accent-strong);
}
.stat { font-size: 30px; font-weight: 800; margin-top: 6px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  display:inline-block;
  border: none;
  cursor: pointer;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--primary);
  color:#fff;
  font-weight:700;
  box-shadow: 0 8px 18px var(--accent-strong);
}
.btn:hover { background: var(--primary-dark); color:#fff; }
.btn.secondary {
  background: var(--accent-light);
  color: var(--primary-dark);
  box-shadow: none;
}
.btn.danger { background: var(--danger); }
.table-wrap { overflow-x: auto; }
table { width:100%; border-collapse: collapse; }
th, td { text-align:left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.badge {
  display:inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight:700;
  background:#f4edf2;
  color:#59314a;
}
.badge-soft { background: var(--accent-light); color: var(--primary-dark); }
.badge.alta { background:#ffe0e0; color:#9d0208; }
.badge.normal { background:#e8f4ff; color:#075985; }
.badge.baja { background:#e8f7ed; color:#146c43; }
form .row { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.row-tight { align-items: end; }
label { display:block; font-weight:700; margin-bottom: 6px; }
input, select, textarea {
  width:100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:#fff;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--accent-strong);
}
textarea { min-height: 110px; resize: vertical; }
.form-actions { margin-top: 16px; display:flex; gap:10px; flex-wrap: wrap; }
.alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  background: #e8f7ed;
  color: #146c43;
  border:1px solid #ccebd8;
}
.alert.error { background:#ffe0e0; color:#9d0208; border-color:#ffb4b4; }
.alert.soft { background: var(--card-soft); color: var(--text); border-color: var(--line); }
.section-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--primary-dark);
}
.helper-text { display:block; margin-top: 6px; }
.quick-create {
  border: 1px dashed var(--line);
  background: linear-gradient(180deg, var(--card-soft), #fff);
  border-radius: 18px;
  padding: 18px;
  margin: 16px 0 20px;
}
.inline-actions { display:flex; flex-direction:column; justify-content:flex-end; }
.login-page { max-width: 430px; margin: 8vh auto; }
.check { width: 20px; height:20px; }
.full-mobile { width: auto; }

@media (max-width: 850px) {
  .layout { display:block; }
  .sidebar { width:100%; height:auto; position:relative; }
  nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 18px; }
  .grid-4, .grid-2, form .row { grid-template-columns: 1fr; }
  .topbar { display:block; }
  .full-mobile { width: 100%; }
}

/* V4: selección de cliente más limpia, acciones rápidas y mejor uso en celular */
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.section-head h2,
.section-head h3 { margin-bottom: 4px; }
.small-head { align-items: center; }
.hidden { display: none !important; }
.search-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
}
.search-results {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.customer-result {
  width: 100%;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, var(--card-soft));
  border-radius: 15px;
  padding: 13px 14px;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.customer-result strong { display: block; font-size: 15px; color: var(--text); }
.customer-result span { color: var(--muted); font-size: 13px; }
.customer-result:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--accent-strong);
}
.empty-result {
  padding: 13px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: #fff;
}
.empty-result .btn { margin-top: 10px; }
.selected-customer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--accent-light), #fff);
  border-radius: 18px;
  padding: 16px;
  margin: 12px 0 18px;
}
.selected-customer h3 {
  margin: 8px 0 2px;
  font-size: 20px;
}
.status-form {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 180px;
}
.status-form select {
  min-width: 170px;
  padding: 9px 10px;
}
.quick-status-box {
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 16px;
}
.detail-status-form {
  display: block;
}
.nowrap-actions { flex-wrap: nowrap; }
.btn.whatsapp {
  background: #25D366;
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 211, 102, .18);
}
.btn.whatsapp:hover { background: #1faa52; }
.action-alert {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: rgba(255,255,255,.92);
  border-top: 1px solid var(--line);
  padding: 12px 0 4px;
  backdrop-filter: blur(10px);
  z-index: 5;
}

@media (max-width: 850px) {
  body { font-size: 16px; }
  .sidebar { padding: 14px; }
  .brand { margin-bottom: 14px; }
  nav {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }
  nav a {
    white-space: nowrap;
    min-width: max-content;
    padding: 10px 12px;
  }
  .card { padding: 16px; border-radius: 18px; }
  h1 { font-size: 25px; }
  .section-head,
  .selected-customer,
  .action-alert { display: block; }
  .section-head .btn,
  .selected-customer .btn,
  .action-alert .btn { width: 100%; margin-top: 10px; text-align: center; }
  .actions .btn,
  .actions button,
  .search-actions input,
  .search-actions .btn,
  .filter-actions .btn,
  .task-form input,
  .task-form button { width: 100%; max-width: none !important; }
  .status-form { width: 100%; min-width: 0; }
  .status-form select { width: 100%; min-width: 0; }
  .nowrap-actions { flex-wrap: wrap; }
  input, select, textarea, .btn { font-size: 16px; }
  .customer-result { padding: 15px; }
}
