:root {
  --green:       #1D9E75;
  --green-light: #E1F5EE;
  --green-dark:  #085041;
  --amber:       #854F0B;
  --amber-light: #FAEEDA;
  --red:         #A32D2D;
  --red-light:   #FCEBEB;
  --blue:        #185FA5;
  --blue-light:  #E6F1FB;
  --gray-50:     #F8F7F4;
  --gray-100:    #EDECE8;
  --gray-200:    #D3D1C7;
  --gray-500:    #888780;
  --gray-700:    #444441;
  --gray-900:    #1A1A18;
  --white:       #FFFFFF;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --shadow:      0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 15px;
  line-height: 1.5;
}

/* ── NAV ── */
.nav {
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-logo {
  font-weight: 600;
  font-size: 16px;
  color: var(--green);
  margin-right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-btn {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-500);
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.nav-btn:hover { background: var(--gray-50); color: var(--gray-700); }
.nav-btn.active {
  background: var(--green-light);
  color: var(--green-dark);
  border-color: rgba(29,158,117,0.3);
  font-weight: 500;
}

/* ── VIEWS ── */
.view { display: none; padding: 20px 16px; max-width: 960px; margin: 0 auto; }
.view.active { display: block; }

/* ── CARDS ── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.card-title svg { opacity: 0.6; }

/* ── FORMS ── */
label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
  display: block;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input[type="text"],
input[type="number"],
input[type="password"],
select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--white);
  color: var(--gray-900);
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 12px;
}
input:focus, select:focus { border-color: var(--green); }
.row { display: flex; gap: 12px; align-items: flex-start; }
.row > * { flex: 1; }
.row > .col-fixed { flex: 0 0 120px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-200); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: #178a63; }
.btn-danger { color: var(--red); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--red-light); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-whatsapp { background: #25D366; border-color: #25D366; color: #fff; }
.btn-whatsapp:hover { background: #1ebe5a; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 999px;
}
.badge-green  { background: var(--green-light); color: var(--green-dark); }
.badge-amber  { background: var(--amber-light); color: var(--amber); }
.badge-red    { background: var(--red-light);   color: var(--red); }
.badge-blue   { background: var(--blue-light);  color: var(--blue); }
.badge-gray   { background: var(--gray-100);    color: var(--gray-700); }

/* ── MENU ITEM ── */
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  margin-bottom: 7px;
}
.menu-item-name { flex: 1; font-size: 14px; font-weight: 500; }
.menu-item-price { font-size: 13px; color: var(--green); font-weight: 600; min-width: 75px; text-align: right; }

/* ── ORDER CARD ── */
.order-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.order-line {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
  color: var(--gray-700);
}
.total-line {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  border-top: 1px solid var(--gray-100);
  padding-top: 8px;
  margin-top: 6px;
}

/* ── TV GRID ── */
body.tv-mode {
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
body.tv-mode .nav { flex-shrink: 0; }
#view-tv {
  max-width: 100%;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
body.tv-mode #view-tv {
  height: calc(100vh - 52px);
  padding: 8px 10px;
}
.tv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 2px;
  flex-shrink: 0;
}
.tv-title { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.tv-date  { font-size: 13px; color: var(--gray-500); }
.tv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 10px;
  flex: 1;
  min-height: 0;
}
body.tv-mode .tv-grid {
  height: 100%;
}
.tv-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tv-card-empty {
  background: var(--gray-50);
  border: 1px dashed var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tv-food-name {
  font-size: clamp(15px, 1.6vw, 22px);
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 8px;
  line-height: 1.2;
}
.tv-count-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 14px;
}
.tv-portions       { font-size: clamp(42px, 5vw, 72px); font-weight: 700; color: var(--green); line-height: 1; }
.tv-portions-label { font-size: clamp(12px, 1.1vw, 16px); color: var(--gray-500); }
.tv-client-row {
  display: flex;
  justify-content: space-between;
  font-size: clamp(12px, 1.2vw, 16px);
  color: var(--gray-500);
  padding: 4px 0;
  border-bottom: 1px solid var(--gray-100);
}
.tv-client-row:last-child { border-bottom: none; }
.tv-client-name { font-weight: 500; color: var(--gray-700); }

/* ── CLIENTE VIEW ── */
.food-select-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.food-select-card.selected { border-color: var(--green); background: var(--green-light); }
.food-select-info { flex: 1; }
.food-select-name { font-size: 14px; font-weight: 500; }
.food-select-price { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.qty-ctrl { display: flex; align-items: center; gap: 10px; }
.qty-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-700);
  transition: all 0.15s;
}
.qty-btn:hover { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }
.qty-num { font-size: 16px; font-weight: 600; min-width: 26px; text-align: center; }
.summary-bar {
  background: var(--green-light);
  border: 1px solid rgba(29,158,117,0.25);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 12px;
}

/* ── ACCOUNTS ── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 0;
}
.tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--green); border-bottom-color: var(--green); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.stat-label { font-size: 11px; font-weight: 500; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.stat-card.stat-pending .stat-label { color: var(--amber); }
.stat-card.stat-pending .stat-value { color: var(--amber); }

.month-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.month-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  padding: 6px 10px;
  border-bottom: 1px solid var(--gray-100);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.month-table td { padding: 9px 10px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.month-table tr:last-child td { border-bottom: none; }
.month-table tr.paid-row td { opacity: 0.4; }

/* ── ALERT ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin: 10px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: var(--green-light); color: var(--green-dark); }
.alert-info    { background: var(--blue-light);  color: var(--blue); }
.alert-error   { background: var(--red-light);   color: var(--red); }

/* ── LOADING / EMPTY ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
  font-size: 14px;
}
.empty-state .icon { font-size: 40px; margin-bottom: 10px; opacity: 0.4; }
.loading { text-align: center; padding: 30px; color: var(--gray-500); font-size: 13px; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--gray-200); border-top-color: var(--green); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -4px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── LOGIN ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
}
.login-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 24px; font-weight: 700; color: var(--green); margin-bottom: 6px; }
.login-sub  { font-size: 14px; color: var(--gray-500); margin-bottom: 24px; }

/* ── SECTION LABEL ── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  margin-bottom: 8px;
}

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--gray-100); margin: 14px 0; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .tv-grid { grid-template-columns: repeat(2, 1fr); }
  .row { flex-direction: column; }
  .row > .col-fixed { flex: 1; }
  .stat-grid { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .tv-grid { grid-template-columns: 1fr; }
}

/* ── TARJETAS DE CLIENTES ── */
.client-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.client-card:hover { border-color: var(--gray-200); }
.client-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 700;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.client-info { flex: 1; min-width: 0; }
.client-name { font-size: 14px; font-weight: 600; }
.client-meta { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.client-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── SEGUIMIENTO DIARIO ── */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  border: 1px solid transparent;
}
.status-pending {
  background: var(--amber-light);
  border-color: rgba(133,79,11,0.15);
}
.status-ok {
  background: var(--green-light);
  border-color: rgba(15,110,86,0.15);
}
.status-info { flex: 1; min-width: 0; }
.status-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
}
.status-phone {
  display: block;
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 1px;
}
.status-detail {
  display: block;
  font-size: 12px;
  color: var(--green-dark);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
.status-total {
  font-size: 13px;
  font-weight: 600;
  color: var(--green-dark);
  white-space: nowrap;
}
.status-actions { display: flex; gap: 6px; flex-shrink: 0; }

@media (max-width: 520px) {
  .status-row { flex-wrap: wrap; }
  .status-detail { max-width: 200px; }
  .client-actions { flex-wrap: wrap; }
}
