:root {
  --ink: #1a1a1a;
  --ink-deep: #0d0d0d;
  --ink-mid: #333333;
  --ink-soft: #f0f0f0;
  --orange: #e67a22;
  --orange-deep: #c45a0f;
  --orange-mid: #f08a2e;
  --orange-soft: #fff0e4;
  --accent: #ffffff;
  --accent-soft: #eaeaea;
  --pend-soft: #fff3e6;
  --blue-soft: #eceff2;
  --ok-soft: #e9ecea;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --line: #d8d8d8;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  color: var(--text);
  background: #f3f3f3;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.sidebar {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 210, 140, 0.28), transparent 55%),
    radial-gradient(ellipse at 90% 80%, rgba(160, 60, 0, 0.35), transparent 50%),
    linear-gradient(165deg, var(--orange-mid) 0%, var(--orange) 42%, var(--orange-deep) 100%);
  color: #fff8f0;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  align-items: flex-start;
}
.brand-logo {
  width: 100%;
  max-width: 180px;
  height: auto;
  display: block;
  background: #fff;
  border-radius: 8px;
  padding: .55rem .65rem;
  object-fit: contain;
}
.brand strong { display: block; font-size: 1.05rem; letter-spacing: .02em; }
.brand span { display: block; opacity: .7; font-size: .8rem; }

.nav-label {
  margin: .5rem 0 0;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .72rem;
  opacity: .55;
}

.nav { display: flex; flex-direction: column; gap: .4rem; }
.nav a {
  padding: .75rem .9rem;
  border-radius: 12px;
  color: #fff8f0;
  transition: .15s ease;
}
.nav a:hover { background: rgba(255,255,255,.16); }
.nav a.active {
  background: #fff;
  color: #b34d0a;
  font-weight: 700;
}

.sidebar-foot {
  margin-top: auto;
  font-size: .78rem;
  opacity: .7;
  display: grid;
  gap: .2rem;
}

.main { padding: 1.4rem 1.6rem 2rem; min-width: 0; }

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 1.55rem; }
.page-head p { margin: .25rem 0 0; color: var(--muted); }

.head-actions {
  display: flex; gap: .7rem; align-items: center; flex-wrap: wrap;
}

.seg {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.seg a { padding: .45rem .9rem; color: var(--muted); }
.seg a.on {
  background: var(--orange);
  color: #fff;
  font-weight: 600;
}

.weekdays {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin: 0 0 1.1rem;
}
.weekdays a {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .5rem 1rem .7rem;
  min-width: 3.4rem;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  position: relative;
}
.weekdays a.has:not(.on)::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--orange);
  transform: translateX(-50%);
}
.weekdays a.on {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}
.weekdays a.on.has::after {
  background: #fff;
}
.weekdays a:hover {
  border-color: var(--orange);
  color: var(--orange-deep);
}
.weekdays a.on:hover {
  color: #fff;
}

.flow {
  display: inline-flex; align-items: center; gap: .45rem;
  background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: .35rem .7rem;
  font-size: .85rem; color: var(--muted);
}
.flow i {
  width: 14px; height: 1px; background: var(--line); display: inline-block;
}
.flow-on {
  background: var(--orange);
  color: #fff;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-weight: 700;
}

.btn-link {
  background: none; border: none; color: var(--orange-deep);
  cursor: pointer; text-decoration: underline; padding: .4rem .2rem;
}
.btn-primary {
  background: var(--orange);
  border: none;
  border-radius: 12px;
  padding: .7rem 1rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  width: 100%;
}
.btn-primary:hover { background: var(--orange-deep); }
.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  width: 38px; height: 38px;
  cursor: pointer;
}
.btn-ghost:disabled { opacity: .35; cursor: default; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .85rem;
  margin-bottom: 1.1rem;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.kpi strong { display: block; font-size: 1.35rem; }
.kpi span { color: var(--muted); font-size: .85rem; }

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}
.column {
  background: #ebebeb;
  border-radius: 18px;
  padding: .75rem;
  min-height: 280px;
}
.col-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: .55rem .75rem; border-radius: 12px; margin-bottom: .75rem;
  font-weight: 700;
}
.col-head em {
  background: rgba(0,0,0,.08);
  border-radius: 999px;
  padding: .1rem .55rem;
  font-style: normal;
  font-size: .85rem;
}
.col-pend .col-head { background: var(--pend-soft); }
.col-prep .col-head { background: var(--blue-soft); }
.col-exp .col-head { background: var(--ok-soft); }

.card {
  background: var(--card);
  border-radius: 14px;
  padding: .9rem;
  margin-bottom: .75rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,.06);
}
.card-top {
  display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .65rem;
}
.card-meta {
  display: grid; gap: .15rem; text-align: right;
  color: var(--muted); font-size: .82rem;
}
.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .75rem; }
.tags span {
  background: #f0f0f0;
  border-radius: 999px;
  padding: .2rem .55rem;
  font-size: .78rem;
}
.tag-marca { background: var(--orange) !important; color: #fff; font-weight: 700; }

.card-actions { display: flex; gap: .5rem; align-items: center; }
.card-actions .grow { flex: 1; }

.done-box {
  margin-top: .7rem;
  background: var(--ok-soft);
  color: #2a2a2a;
  border-radius: 10px;
  padding: .55rem .7rem;
  font-size: .85rem;
  font-weight: 600;
}

.empty { color: var(--muted); text-align: center; padding: 1.4rem .5rem; }

.flash-wrap { display: grid; gap: .45rem; margin-bottom: .9rem; }
.flash {
  padding: .7rem .9rem;
  border-radius: 10px;
  font-size: .92rem;
}
.flash-ok { background: var(--ok-soft); color: #222; }
.flash-error { background: #fde8e8; color: #8a1f1f; }

.comercial-grid, .hist-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 1rem;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 .8rem; font-size: 1.05rem; }
.mt { margin-top: 1rem; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: .55rem .85rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--orange); background: var(--orange-soft); }
.chip.soft { background: var(--orange-soft); }
.chip:active { transform: scale(.98); }

.chat-panel { display: flex; flex-direction: column; gap: .85rem; min-height: 560px; }
.chat-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
}
.btn-inline { width: auto !important; padding: .55rem .95rem !important; }
.muted { color: var(--muted); font-size: .88rem; }

.chat-log {
  flex: 1;
  min-height: 220px;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: .4rem .15rem .8rem;
  border-bottom: 1px solid var(--line);
}
.bubble {
  max-width: 85%;
  padding: .7rem .9rem;
  border-radius: 14px;
  line-height: 1.35;
  font-size: .95rem;
}
.bubble.bot {
  align-self: flex-start;
  background: var(--orange-soft);
  color: #8a3d08;
  border-bottom-left-radius: 4px;
}
.bubble.user {
  align-self: flex-end;
  background: var(--orange);
  color: #fff;
  font-weight: 600;
  border-bottom-right-radius: 4px;
}

.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}
.opt-title {
  width: 100%;
  margin: .35rem 0 .1rem;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 700;
}

.chat-compose {
  display: flex;
  gap: .55rem;
  align-items: center;
}
.chat-compose input[type="text"] {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .7rem .85rem;
  background: #fff;
}
.chat-compose input[type="text"]:disabled {
  background: #f0f0f0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.form-grid label {
  display: grid; gap: .3rem; font-size: .85rem; color: var(--muted);
}
.form-grid input, .form-grid select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .65rem .75rem;
  color: var(--text);
  background: #fff;
}
.form-actions { grid-column: 1 / -1; }

.list { display: grid; gap: .55rem; }
.list-item {
  display: flex; justify-content: space-between; gap: .7rem;
  padding: .7rem .75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  align-items: center;
}
.list-item span, .list-item em { display: block; }
.list-item span { color: var(--muted); font-size: .82rem; margin-top: .15rem; }
.list-item em { font-style: normal; font-size: .8rem; font-weight: 700; }

.estado-pendiente { color: #8a6d1d; }
.estado-preparacion { color: #3a4f66; }
.estado-expedido { color: #2a2a2a; }

.pill {
  background: var(--orange-soft);
  color: var(--orange-deep);
  border-radius: 999px;
  padding: .4rem .8rem;
  font-weight: 600;
  font-size: .88rem;
}

.hint {
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: .8rem 1rem;
  color: var(--muted);
  margin: 0 0 1rem;
}
.hint code { color: var(--ink); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
th, td {
  text-align: left;
  padding: .55rem .4rem;
  border-bottom: 1px solid var(--line);
}
th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table-wrap { overflow-x: auto; }

.btn-logout {
  color: #fff8f0;
  opacity: .9;
  padding: 0;
  margin: .2rem 0 .35rem;
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.2rem;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 210, 140, 0.45), transparent 55%),
    linear-gradient(165deg, #f7f3ee 0%, #f3f3f3 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.4rem 1.3rem 1.5rem;
}
.login-brand {
  display: grid;
  gap: .25rem;
  margin-bottom: 1rem;
}
.login-brand .brand-logo { max-width: 160px; }
.login-brand strong { font-size: 1.15rem; }
.login-brand span { color: var(--muted); font-size: .9rem; }
.login-form { display: grid; gap: .85rem; }
.login-form label {
  display: grid;
  gap: .35rem;
  font-size: .88rem;
  color: var(--muted);
}
.login-form input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .75rem .8rem;
  color: var(--text);
  background: #fff;
  width: 100%;
}
.captcha-row {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.captcha-row img {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff8f0;
  height: 72px;
  width: auto;
  max-width: calc(100% - 50px);
}

@media (max-width: 1100px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; min-height: auto; }
  .kpi-row, .board, .comercial-grid, .hist-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .brand-logo { max-width: 140px; }
  .head-actions { width: 100%; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
}
