:root {
  --bg: #f2f2f4;
  --ink: #2f1e25;
  --brand: #4b1f2d;
  --brand-2: #6f2134;
  --accent: #f2be45;
  --line: #e4d4b7;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.dashboard { max-width: 720px; margin: 0 auto; min-height: 100vh; }
.auth-card, .panel, .card { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.auth-card { max-width: 420px; margin: 4rem auto; padding: 1rem; }
.auth-card__heading {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
}
.panel {
  border-radius: 0;
  border: none;
  min-height: 100vh;
  background: #f1f1f3;
  position: relative;
  padding-bottom: 5rem;
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: linear-gradient(180deg, #c70000, #b10000);
  color: #fff;
  padding: 0.85rem 0.75rem;
}
.app-bar h1 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.icon-btn {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #dc2222;
}
.tab-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  padding: 0.78rem 0.4rem;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  font-size: 1rem;
}
.tab-btn.is-active {
  color: #fff;
  border-bottom-color: var(--accent);
}
.main-tab-btn {
  border-bottom-color: transparent !important;
}
.main-tab-btn.is-active {
  border-bottom-color: var(--accent) !important;
}
.main-tab-btn:not(.is-active) {
  border-bottom-color: transparent !important;
}
.tab-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 0.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #fff;
  color: #a00000;
  font-size: 0.7rem;
  line-height: 1.35rem;
}
.kpi {
  border: 1px solid #dedede;
  border-radius: 10px;
  background: #fff;
  padding: 0.55rem;
}
.kpi__label {
  margin: 0;
  color: #6c5c62;
  font-size: 0.8rem;
}
.kpi__value {
  margin: 0.2rem 0 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.tab-panel { display: none; padding: 0.85rem; }
.tab-panel.is-active { display: block; }
.search-wrap { margin-bottom: 0.7rem; }
.search-wrap--inline {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.search-wrap--inline input {
  flex: 1;
  min-width: 0;
}
.search-wrap__btn {
  flex-shrink: 0;
  align-self: stretch;
  white-space: nowrap;
}
.search-wrap input {
  width: 100%;
  border: 1px solid #d7d7d7;
  border-radius: 8px;
  padding: 0.62rem 0.7rem;
  font: inherit;
}

.card { padding: 0.85rem; background: #fff; }
.form-card { margin-bottom: 0.8rem; }
.form-card[hidden] { display: none !important; }

#dashboardFlatFeeWrap[hidden] {
  display: none !important;
}

.delivery-areas-toolbar {
  margin-bottom: 0.35rem;
}

.delivery-areas-card__search {
  margin-bottom: 0.65rem;
}

.section-title--sub {
  font-size: 0.95rem;
  margin: 0 0 0.35rem;
  letter-spacing: 0.04em;
}

.delivery-zone-bulk {
  margin-bottom: 1rem;
  padding: 0.65rem 0 0.85rem;
  border-top: 1px solid #e8e8e8;
  border-bottom: 1px solid #e8e8e8;
}

.delivery-zone-bulk__grid {
  display: grid;
  gap: 0.55rem;
  align-items: end;
}

@media (min-width: 560px) {
  .delivery-zone-bulk__grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  }
  .delivery-zone-bulk__apply {
    margin-bottom: 0.05rem;
  }
}

#deliveryAreaForm[hidden] {
  display: none !important;
}

.stack { display: grid; gap: 0.55rem; }
label { display: grid; gap: 0.3rem; font-weight: 600; font-size: 0.88rem; }
input, textarea, select {
  width: 100%;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  padding: 0.56rem 0.62rem;
  font: inherit;
  background: #fff;
}
button, .file-btn {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  padding: 0.52rem 0.7rem;
  font-weight: 700;
  cursor: pointer;
}
button:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}
button.is-loading::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 6px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.danger { border-color: #a02a2a; background: #a02a2a; }
.file-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.backup-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  border-radius: 8px;
}
.backup-btn__icon {
  width: 1rem;
  text-align: center;
  font-size: 0.92rem;
}
.backup-btn--export {
  background: #1f7a38;
  border-color: #1f7a38;
  color: #fff;
}
.backup-btn--import {
  background: #0a6ea8;
  border-color: #0a6ea8;
  color: #fff;
}

.row__actions--backup-full {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.5rem;
  width: 100%;
}
.row__actions--backup-full > .backup-btn--export,
.row__actions--backup-full > .file-btn.backup-btn--import {
  width: 100%;
  justify-content: center;
  box-sizing: border-box;
  padding: 0.58rem 0.85rem;
  font-size: 0.88rem;
}

label.file-btn.backup-btn--import.is-loading {
  pointer-events: none;
  opacity: 0.92;
  cursor: wait;
}
label.file-btn.backup-btn--import.is-loading::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 6px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}

.backup-progress {
  margin-top: 0.65rem;
  height: 5px;
  border-radius: 999px;
  background: #e4e4e4;
  overflow: hidden;
}
.backup-progress__bar {
  width: 38%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #1f7a38, #0a6ea8);
  animation: backupBarSlide 1.05s ease-in-out infinite;
}
@keyframes backupBarSlide {
  0% {
    transform: translateX(-30%);
    opacity: 0.75;
  }
  100% {
    transform: translateX(280%);
    opacity: 1;
  }
}
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  padding: 0.35rem;
  background: #ececec;
  border: 1px solid #d8d8d8;
  border-radius: 999px;
}
.mode-toggle__option {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  position: relative;
}
.mode-toggle__option input[type="radio"] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.mode-toggle__option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0.42rem 0.7rem;
  background: #8f8f8f;
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.mode-toggle__option input[type="radio"]:checked + span {
  background: #18a44b;
  color: #fff;
}

.list { display: grid; gap: 0.45rem; }
.row {
  border: 1px solid #e7e7e7;
  border-radius: 12px;
  background: #fff;
  padding: 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}
.row--draggable { cursor: grab; }
.row--draggable.is-dragging {
  opacity: 0.65;
  cursor: grabbing;
}
.row--draggable.is-drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(242, 190, 69, 0.25);
}
.row__meta { font-size: 0.79rem; color: #6c5c62; }
.row__actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.row__actions button { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
.row__actions .mini { padding: 0.24rem 0.42rem; min-width: 32px; text-align: center; }
.row__actions .ok {
  background: #1d9b2a;
  border-color: #1d9b2a;
}
.order-inline-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.55rem;
}
.order-inline-actions button {
  min-height: 38px;
  font-size: 0.88rem;
  font-weight: 700;
}
.order-inline-actions .ok {
  background: #179c21 !important;
  border-color: #179c21 !important;
  color: #fff !important;
}
.order-inline-actions .danger {
  background: #cb0e0e !important;
  border-color: #cb0e0e !important;
  color: #fff !important;
}
.order-view-btn {
  margin-top: 0.5rem;
  width: 100%;
  min-height: 38px;
  font-size: 0.88rem;
  font-weight: 700;
}
.order-card-main {
  width: 100%;
  flex: 1 1 auto;
}

.section-title { margin: 0 0 0.55rem; font-size: 1rem; }
.order-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.order-detail-head .section-title {
  margin: 0;
}
.order-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.9rem;
}
.order-detail-overlay.is-open {
  display: flex;
}
.order-detail-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.order-detail-overlay__dialog {
  position: relative;
  z-index: 1;
  width: min(96vw, 560px);
  max-height: 92vh;
  display: grid;
  grid-template-rows: auto 1fr;
  border-radius: 12px;
  overflow: hidden;
  background: #f1f1f3;
  border: 1px solid var(--line);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}
.order-detail-overlay[hidden] {
  display: none !important;
}
.entry-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.9rem;
}
.entry-modal[hidden] {
  display: none !important;
}
.entry-modal.is-open {
  display: flex;
}
.entry-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.entry-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(96vw, 560px);
  max-height: 92vh;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f1f1f3;
  display: grid;
  grid-template-rows: auto 1fr;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}
.entry-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: linear-gradient(180deg, #c70000, #b10000);
  color: #fff;
  padding: 0.72rem 0.7rem;
}
.entry-modal__head h2 {
  margin: 0;
  font-size: 1.05rem;
}
.entry-modal__body {
  overflow-y: auto;
  padding: 0.75rem;
}
.entry-modal__body .form-card {
  margin-bottom: 0;
}
.order-detail-overlay__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: linear-gradient(180deg, #c70000, #b10000);
  color: #fff;
  padding: 0.75rem 0.7rem;
}
.order-detail-overlay__head h2 {
  margin: 0;
  font-size: 1.2rem;
}
.order-detail-overlay__spacer {
  width: 1.2rem;
}
.order-detail-overlay__body {
  padding: 0.75rem;
  overflow-y: auto;
}
#orderDetail .stack {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
}
.order-detail-stack {
  gap: 0.75rem !important;
}
.order-head {
  text-align: center;
}
.order-head h3 {
  margin: 0;
  font-size: 1.8rem;
}
.order-head p {
  margin: 0.3rem 0 0;
  color: #6c5c62;
}
.order-primary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.order-primary-actions .ok {
  background: #1d9b2a;
  border-color: #1d9b2a;
}
.order-section {
  border: 1px solid #e7e7e7;
  border-radius: 12px;
  padding: 0.7rem;
  display: grid;
  gap: 0.45rem;
  background: #fff;
}
.order-customer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.order-contact-actions {
  display: flex;
  gap: 0.35rem;
}
.contact-btn {
  text-decoration: none;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.76rem;
  font-weight: 700;
}
.contact-btn.wa {
  background: #1ea952;
  border-color: #1ea952;
}
.order-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: #3f3f3f;
}
.order-line--total {
  font-weight: 700;
}
.hint { color: #6a5a61; font-size: 0.84rem; }
.error { color: #a02a2a; font-weight: 700; }
.image-preview-wrap { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.image-preview {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  border-radius: 999px;
  padding: 0.74rem 0.95rem;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 8px 22px rgba(75, 31, 45, 0.3);
}

.settings-drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
}
.settings-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.settings-drawer__panel {
  position: absolute;
  left: 0;
  top: 0;
  width: min(88vw, 380px);
  height: 100%;
  background: #fff;
  padding: 1rem 0.8rem;
  border-right: 1px solid #ddd;
  transform: translateX(-106%);
  transition: transform 0.24s ease;
}
.settings-drawer__panel h2 { margin: 0 0 0.9rem; color: #2e2e2e; }
.settings-drawer__panel .stack button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-start;
  background: #fff;
  color: #121212;
  border: 1px solid #d7d7d7;
}
.settings-drawer__panel .stack button:hover {
  background: #f7f7f7;
}
.drawer-btn__icon {
  width: 1.1rem;
  text-align: center;
  font-size: 0.95rem;
}
.settings-drawer.is-open .settings-drawer__backdrop {
  opacity: 1;
}
.settings-drawer.is-open .settings-drawer__panel {
  transform: translateX(0);
}

#tab-orders .form-card {
  background: transparent;
  border: 0;
  padding: 0;
  margin-bottom: 0.7rem;
}
#tab-orders .row__actions {
  gap: 0.45rem;
}
#ordersRefreshBtn,
#ordersSoundToggleBtn {
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
}

.toast {
  position: fixed;
  left: 50%;
  top: 4.2rem;
  transform: translate(-50%, 14px);
  opacity: 0;
  z-index: 9999;
  background: #1f7a38;
  color: #fff;
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast--error {
  background: #a02a2a;
}

.item-variations-editor {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
}
.item-variations-editor__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}
.item-variations-editor__add-group {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.item-variations-editor__groups {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.var-group-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  background: #fffaf2;
}
.var-group-card__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.var-group-card__head input[type="text"] {
  flex: 1;
  min-width: 140px;
}
.var-group-card__required {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.78rem;
  white-space: nowrap;
}
.var-group-card__required-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: lowercase;
  background: #fff3cd;
  color: #856404;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
}
.var-option-row {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.35rem;
}
.var-option-row input {
  width: 100%;
}
.row__meta .var-chip {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #efe2c8;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand);
}

.order-payment-proof {
  margin-top: 0.65rem;
}

.order-payment-proof img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  border-radius: 10px;
  border: 1px solid #e8e8e8;
  object-fit: contain;
  background: #fafafa;
}

.delivery-eta-compact {
  padding: 0.75rem 1rem;
}
.delivery-eta-compact__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
}
.delivery-eta-compact__title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 10rem;
  font-size: 1rem;
}
.delivery-eta-compact__minutes {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}
.delivery-eta-compact__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}
.delivery-eta-compact__minutes input {
  width: 4.5rem;
  max-width: 5rem;
  padding: 0.35rem 0.5rem;
}
.delivery-eta-compact__save {
  margin-left: auto;
  padding: 0.45rem 0.85rem;
  font-size: 0.88rem;
}

@media (min-width: 900px) {
  .panel {
    border-radius: 12px;
    margin: 1rem auto;
    min-height: calc(100vh - 2rem);
    max-width: 430px;
    border: 1px solid #d8d8d8;
    overflow: hidden;
  }

  .fab {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }

  .settings-drawer__panel {
    left: calc(50% - 215px);
    width: min(80vw, 250px);
  }
}
