:root {
  --bg:    #111318;
  --card:  #181b22;
  --red:   #e03131;
  --rglow: rgba(224,49,49,0.35);
  --text:  #f1f3f5;
  --muted: #5c6370;
  --bord:  rgba(255,255,255,0.07);
  --green: #2f9e44;
  --yellow:#e67700;
  --blue:  #1971c2;
}
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}

/* ── HEADER ─────────────────────────────────── */
header {
  padding: 1.2rem 2rem;
  border-bottom: 1px solid var(--bord);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card);
  position: sticky; top: 0; z-index: 100;
}
.h-logo { font-size: 1rem; font-weight: 800; letter-spacing: .15em; }
.h-logo em { font-style: normal; color: var(--red); }
.h-sub  { font-size: .75rem; color: var(--muted); margin-top: .15rem; }

/* ── STATS BAR ──────────────────────────────── */
.stats {
  display: flex; gap: 1rem; padding: 1.5rem 2rem;
  flex-wrap: wrap;
}
.stat {
  flex: 1; min-width: 130px;
  background: var(--card); border: 1px solid var(--bord);
  border-radius: 12px; padding: 1rem 1.25rem;
}
.stat-num  { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-lbl  { font-size: .72rem; color: var(--muted); margin-top: .3rem; letter-spacing: .04em; text-transform: uppercase; }
.stat-num.pending   { color: var(--yellow); }
.stat-num.confirmed { color: var(--green); }
.stat-num.delivered { color: var(--blue); }
.stat-num.cancelled { color: var(--muted); }

/* ── PRODUCTS ───────────────────────────────── */
.products-section {
  margin: 0 2rem 1.25rem;
  background: var(--card); border: 1px solid var(--bord);
  border-radius: 12px; padding: 1rem 1.25rem;
}
.products-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .85rem;
}
.products-title {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.products-list { display: flex; flex-wrap: wrap; gap: .75rem; }
.product-card {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  background: rgba(255,255,255,.03); border: 1px solid var(--bord);
  border-radius: 10px; padding: .75rem 1rem;
  flex: 1; min-width: 220px;
}
.product-name  { font-size: .88rem; font-weight: 700; margin-bottom: .25rem; }
.product-prices { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.product-base  { font-size: .85rem; color: var(--text); font-weight: 600; }
.product-base-crossed { font-size: .82rem; color: var(--muted); text-decoration: line-through; }
.product-discount { font-size: .78rem; color: #ff8080; font-weight: 600; }
.product-final { font-size: .88rem; color: var(--green); font-weight: 700; }
.btn-edit-product {
  background: rgba(255,255,255,.05); border: 1px solid var(--bord);
  color: var(--muted); border-radius: 6px; font-size: .76rem; font-weight: 600;
  padding: .3rem .75rem; cursor: pointer; transition: all .2s; white-space: nowrap;
}
.btn-edit-product:hover { border-color: rgba(255,255,255,.2); color: var(--text); }

/* edit product modal extras */
.ep-final-wrap {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.03); border: 1px solid var(--bord);
  border-radius: 8px; padding: .65rem .85rem; margin-bottom: 1.2rem;
}
.ep-final { font-size: 1.1rem; font-weight: 800; color: var(--green); }

/* ── FILTERS ────────────────────────────────── */
.filters {
  padding: 0 2rem 1rem;
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
}
.filter-btn {
  background: var(--card); border: 1px solid var(--bord);
  color: var(--muted); border-radius: 999px;
  font-size: .8rem; font-weight: 600; padding: .4rem 1rem;
  cursor: pointer; transition: all .2s;
}
.filter-btn.active,
.filter-btn:hover { border-color: var(--red); color: var(--text); }
.filter-btn.active { background: rgba(224,49,49,.1); }

.refresh-btn {
  margin-left: auto; background: transparent; border: 1px solid var(--bord);
  color: var(--muted); border-radius: 8px; font-size: .8rem;
  padding: .4rem .9rem; cursor: pointer; transition: all .2s;
}
.refresh-btn:hover { border-color: rgba(255,255,255,.2); color: var(--text); }

/* ── TABLE WRAPPER ──────────────────────────── */
.table-wrap {
  padding: 0 2rem 4rem;
  overflow-x: auto;
}
table {
  width: 100%; border-collapse: collapse; min-width: 720px;
  background: var(--card); border: 1px solid var(--bord);
  border-radius: 12px; overflow: hidden;
}
thead { background: rgba(255,255,255,.03); }
th {
  text-align: left; padding: .9rem 1rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  color: var(--muted); text-transform: uppercase;
  border-bottom: 1px solid var(--bord);
}
td {
  padding: .85rem 1rem; font-size: .88rem;
  border-bottom: 1px solid var(--bord); vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

.td-product { font-size: .82rem; font-weight: 600; color: rgba(241,243,245,.75); white-space: nowrap; }
.td-name   { font-weight: 600; }
.td-phone  { color: var(--muted); font-family: monospace; font-size: .85rem; }
.td-addr   { font-size: .82rem; color: rgba(241,243,245,.6); max-width: 200px; }
.td-price  { font-weight: 700; color: var(--red); white-space: nowrap; }
.td-date   { font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* status badges */
.badge {
  display: inline-block; font-size: .7rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  padding: .22rem .65rem; border-radius: 999px;
}
.badge-pending   { background: rgba(230,119,0,.12);  color: var(--yellow); border: 1px solid rgba(230,119,0,.3); }
.badge-confirmed { background: rgba(47,158,68,.12);  color: var(--green);  border: 1px solid rgba(47,158,68,.3); }
.badge-delivered { background: rgba(25,113,194,.12); color: var(--blue);   border: 1px solid rgba(25,113,194,.3); }
.badge-cancelled { background: rgba(92,99,112,.12);  color: var(--muted);  border: 1px solid var(--bord); }

/* action buttons */
.btn-confirm, .btn-cancel, .btn-deliver {
  border: none; border-radius: 6px; cursor: pointer;
  font-size: .78rem; font-weight: 600; padding: .35rem .75rem;
  transition: opacity .2s; white-space: nowrap;
}
.btn-confirm { background: rgba(47,158,68,.15); color: var(--green); border: 1px solid rgba(47,158,68,.3); }
.btn-confirm:hover { background: rgba(47,158,68,.25); }
.btn-deliver { background: rgba(25,113,194,.15); color: var(--blue);  border: 1px solid rgba(25,113,194,.3); }
.btn-deliver:hover  { background: rgba(25,113,194,.25); }
.btn-cancel  { background: rgba(224,49,49,.1);  color: #ff8080;       border: 1px solid rgba(224,49,49,.25); margin-left: .4rem; }
.btn-cancel:hover  { background: rgba(224,49,49,.2); }
.btn-confirm:disabled, .btn-cancel:disabled, .btn-deliver:disabled { opacity: .35; cursor: not-allowed; }

.no-orders { text-align: center; padding: 3rem; color: var(--muted); font-size: .95rem; }

/* ── ADVANCE POPUP ──────────────────────────── */
.ap-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(8,10,14,.85); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .25s, visibility .25s;
}
.ap-overlay.open { opacity: 1; visibility: visible; pointer-events: all; }
.ap-box {
  background: #181b22; border: 1px solid var(--bord);
  border-radius: 14px; padding: 2rem;
  width: 100%; max-width: 360px;
  transform: translateY(14px); transition: transform .25s;
}
.ap-overlay.open .ap-box { transform: translateY(0); }
.ap-title { font-size: 1.1rem; font-weight: 800; margin-bottom: .4rem; }
.ap-desc  { font-size: .85rem; color: var(--muted); margin-bottom: 1.25rem; line-height: 1.6; }
.ap-label { font-size: .78rem; font-weight: 600; color: rgba(241,243,245,.7); margin-bottom: .4rem; display: block; }
.ap-input {
  width: 100%; background: #111318; border: 1px solid var(--bord);
  border-radius: 8px; color: var(--text); font-size: 1rem;
  font-family: inherit; padding: .65rem .85rem; outline: none;
  transition: border-color .2s; margin-bottom: 1.2rem;
}
.ap-input:focus { border-color: rgba(47,158,68,.5); }
.ap-actions { display: flex; gap: .6rem; justify-content: flex-end; }
.ap-cancel-btn {
  background: transparent; border: 1px solid var(--bord);
  color: var(--muted); border-radius: 8px; font-size: .88rem;
  padding: .55rem 1.1rem; cursor: pointer; transition: all .2s;
}
.ap-cancel-btn:hover { border-color: rgba(255,255,255,.2); color: var(--text); }
.ap-confirm-btn {
  background: var(--green); color: #fff; border: none;
  border-radius: 8px; font-size: .88rem; font-weight: 700;
  padding: .55rem 1.3rem; cursor: pointer; transition: opacity .2s;
}
.ap-confirm-btn:hover { opacity: .85; }
.ap-confirm-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── TOAST ──────────────────────────────────── */
#toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999;
  background: var(--card); border: 1px solid var(--bord);
  border-radius: 10px; padding: .8rem 1.2rem;
  font-size: .88rem; max-width: 300px;
  transform: translateY(20px); opacity: 0;
  transition: transform .3s, opacity .3s; pointer-events: none;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { border-color: rgba(47,158,68,.4); color: var(--green); }
#toast.error   { border-color: rgba(224,49,49,.4);  color: #ff8080; }

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 640px) {
  header { padding: 1rem; flex-direction: column; align-items: flex-start; gap: .25rem; }
  .stats { padding: 1rem; }
  .filters, .table-wrap { padding-left: 1rem; padding-right: 1rem; }
}
