:root {
  --color-primary: #E8743B;
  --color-primary-dark: #C85820;
  --color-primary-light: #FFF0E5;
  --color-secondary: #2D8B8B;
  --color-bg: #FFF8F0;
  --color-surface: #FFFFFF;
  --color-text: #1A1A1A;
  --color-text-light: #6B6B6B;
  --color-border: #E5DDD5;
  --color-danger: #D93636;
  --color-success: #2DA84F;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(70px + var(--safe-bottom));
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

/* HEADER */
.header {
  background: var(--color-primary);
  color: #fff;
  padding: calc(16px + var(--safe-top)) 20px 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.header h1 .emoji {
  font-size: 1.2rem;
}

/* TAB BAR (bottom nav) */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + var(--safe-bottom));
  z-index: 200;
}

.tabbar button {
  flex: 1;
  background: none;
  border: none;
  color: var(--color-text-light);
  font-size: 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  cursor: pointer;
}

.tabbar button.active {
  color: var(--color-primary);
}

.tabbar button .icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* VIEWS */
.view {
  display: none;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* SECTION */
.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title:first-child {
  margin-top: 8px;
}

.section-title .badge {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 20px;
}

/* CARDS */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

/* ORDER CARD (dashboard) */
.order-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.order-card .time {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-primary);
}

.order-card .name {
  font-size: 1.05rem;
  font-weight: 600;
}

.order-card .meta {
  font-size: 0.85rem;
  color: var(--color-text-light);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.order-card .num {
  font-size: 0.75rem;
  color: var(--color-text-light);
  background: var(--color-bg);
  padding: 2px 8px;
  border-radius: 6px;
  align-self: flex-start;
}

/* HOME (2 rubriques) */
.home-hero {
  text-align: center;
  padding: 40px 20px 30px;
}

.home-hero h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.home-hero p {
  color: var(--color-text-light);
  font-size: 0.9rem;
}

.home-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 20px;
}

.home-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.1s;
}

.home-card:active {
  transform: scale(0.98);
}

.home-card .emoji {
  font-size: 2.5rem;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--color-primary-light);
}

.home-card .info h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.home-card .info p {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.home-card .chevron {
  margin-left: auto;
  color: var(--color-border);
  font-size: 1.2rem;
}

/* FORMS */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%236B6B6B' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > * {
  flex: 1;
}

.segmented {
  display: flex;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
}

.segmented button {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-light);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.segmented button.active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* STEPPER */
.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stepper button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper .minus {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.stepper .plus {
  background: var(--color-primary);
  color: #fff;
}

.stepper .count {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 30px;
  text-align: center;
}

/* ITEMS (repas) */
.item-list {
  margin-bottom: 12px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-bg);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.item-row .item-name {
  flex: 1;
  font-weight: 600;
}

.item-row .item-price {
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.item-row .item-qty {
  font-weight: 700;
  color: var(--color-primary);
}

.item-row .item-total {
  font-weight: 600;
  min-width: 60px;
  text-align: right;
}

.item-row button.delete-item {
  background: none;
  border: none;
  color: var(--color-danger);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}

.item-add {
  background: var(--color-primary-light);
  border: 1px dashed var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 16px;
}

.item-add input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 8px;
}

.item-add .item-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.item-add .item-add-row input {
  flex: 1;
  margin-bottom: 0;
}

.item-add .item-add-row .stepper {
  margin: 0;
}

.item-add button.add-btn {
  width: 100%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 8px;
  cursor: pointer;
}

/* TOTAL */
.total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius);
  margin: 16px 0;
}

.total-bar .label {
  font-weight: 600;
}

.total-bar .amount {
  font-size: 1.3rem;
  font-weight: 800;
}

/* BUTTONS */
.btn-primary {
  width: 100%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:active {
  opacity: 0.85;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  width: 100%;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger {
  width: 100%;
  background: transparent;
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

/* SEARCH */
.search-bar {
  padding: 12px 16px;
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--color-border);
}

.search-bar input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 0.95rem;
  background: var(--color-bg) url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='7' cy='7' r='5' stroke='%236B6B6B' stroke-width='2'/%3E%3Cpath d='M11 11L15 15' stroke='%236B6B6B' stroke-width='2'/%3E%3C/svg%3E") no-repeat 12px center;
}

/* EMPTY STATE */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-light);
}

.empty .emoji {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty p {
  font-size: 0.9rem;
}

/* LOADING */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--color-text-light);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* DETAIL */
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.detail-header .icon {
  font-size: 2rem;
}

.detail-header .title {
  font-size: 1.3rem;
  font-weight: 800;
}

.detail-header .num {
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-info .row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.detail-info .row .label {
  color: var(--color-text-light);
}

.detail-info .row .value {
  font-weight: 600;
  text-align: right;
}

.detail-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 20px 0 10px;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: #fff;
  padding: 12px 24px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 999;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(-50%) translateY(10px); }
}

/* BACK */
.back-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--color-border);
}

.back-bar button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-primary);
  padding: 4px 8px;
}

.back-bar .title {
  font-size: 1rem;
  font-weight: 700;
}

/* FILTER CHIP */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

/* STATUS BADGE */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-btn:active {
  opacity: 0.85;
}

/* RESPONSIVE */
@media (min-width: 481px) {
  body {
    background: #f0f0f0;
  }
  #app {
    background: var(--color-bg);
    box-shadow: 0 0 20px rgba(0,0,0,0.08);
  }
}