:root {
  --primary: #c05621;
  --primary-dark: #9c4319;
  --primary-light: #f0d4bc;
  --bg: #fdf6f0;
  --bg-card: #ffffff;
  --text: #3b2313;
  --text-light: #8b6f5e;
  --text-white: #ffffff;
  --border: #e8d5c4;
  --success: #2d8a4e;
  --success-light: #e6f4ea;
  --danger: #c53030;
  --danger-light: #fee2e2;
  --warning: #d69e2e;
  --warning-light: #fefce8;
  --shadow: 0 2px 8px rgba(59,35,19,0.1);
  --shadow-lg: 0 4px 16px rgba(59,35,19,0.15);
  --radius: 12px;
  --radius-sm: 8px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  padding-top: 52px;
  padding-bottom: 64px;
  min-height: 100vh;
}
#app-header {
  position: fixed; top: 0; left: 0; right: 0; height: 52px;
  background: linear-gradient(135deg, #d4652a, #bf5620);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-title { color: var(--text-white); font-size: 18px; font-weight: 700; }
.header-clock { color: rgba(255,255,255,0.85); font-size: 14px; font-weight: 500; }
#app-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: 64px;
  background: var(--bg-card); display: flex;
  border-top: 1px solid var(--border); z-index: 100;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border: none; background: none; color: var(--text-light);
  font-size: 11px; cursor: pointer; position: relative;
}
.nav-btn.active { color: var(--primary); }
.nav-icon { font-size: 22px; }
.nav-label { font-weight: 600; }
.nav-badge {
  position: absolute; top: 6px; right: calc(50% - 22px);
  background: var(--danger); color: white; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.page { display: none; padding: 16px; animation: fadeIn 0.2s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.page-top-bar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.page-title { font-size: 18px; font-weight: 700; flex: 1; }

.order-tabs {
  display: flex; gap: 0; margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
}
.order-tab {
  flex: 1; padding: 10px; text-align: center; font-size: 15px; font-weight: 700;
  background: none; border: none; color: var(--text-light); cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.2s;
}
.order-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.table-badge {
  font-size: 14px; font-weight: 700; color: var(--primary);
  background: var(--primary-light); padding: 4px 12px; border-radius: 20px;
}
.fab {
  position: fixed; bottom: 80px; right: 20px;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--primary); color: white; border: none;
  font-size: 28px; font-weight: 700;
  box-shadow: var(--shadow-lg); cursor: pointer; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.9); }
.fab.hidden { display: none; }
.orders-date-picker {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-bottom: 16px;
}
.orders-date-picker input[type="date"] {
  font-size: 15px; font-weight: 600; padding: 6px 10px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); background: white;
}
.btn-today {
  background: var(--primary); color: white; border: 2px solid var(--primary);
  font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: var(--radius-sm);
}
.table-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.table-card {
  background: var(--bg-card); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 20px 16px; text-align: center;
  cursor: pointer; box-shadow: var(--shadow); transition: all 0.2s;
}
.table-card:active { transform: scale(0.97); }
.table-card.occupied { border-color: var(--primary); background: linear-gradient(135deg, #fef3ec, #fde8d8); }
.table-card-name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.table-card-status { font-size: 12px; color: var(--text-light); }
.table-card.occupied .table-card-status { color: var(--primary); font-weight: 600; }
.table-card-capacity { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.order-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow); cursor: pointer; transition: all 0.15s;
}
.order-card:active { transform: scale(0.99); background: #fef8f4; }
.order-card.paid { opacity: 0.5; }
.order-card-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.order-card-table { font-size: 16px; font-weight: 700; color: var(--primary); }
.order-card-time { font-size: 12px; color: var(--text-light); margin-left: 8px; }
.order-card-status { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 10px; }
.status-active { background: var(--danger-light); color: var(--danger); }
.status-ready { background: var(--warning-light); color: var(--warning); }
.status-paid { background: var(--success-light); color: var(--success); }
.order-card-summary {
  font-size: 13px; color: var(--text-light); margin-bottom: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.order-card-footer {
  display: flex; align-items: center; justify-content: space-between;
}
.order-card-total { font-size: 18px; font-weight: 700; color: var(--primary); }
.order-card-served {
  font-size: 12px; color: var(--text-light);
}
.order-card-served .served-count { color: var(--success); font-weight: 600; }
.detail-status {
  font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 10px; margin-left: auto;
}
.order-item-row {
  display: flex; align-items: center; padding: 10px 0;
  border-bottom: 1px solid #f5ede6; gap: 8px;
}
.order-item-row:last-child { border-bottom: none; }
.serve-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--border); background: white;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; transition: all 0.15s;
}
.serve-btn.served { background: var(--success); border-color: var(--success); color: white; }
.order-item-name { flex: 1; font-size: 14px; }
.order-item-name.served { text-decoration: line-through; color: var(--text-light); }
.order-item-info { flex: 1; display: flex; flex-direction: column; }
.order-item-time { font-size: 11px; color: var(--text-light); }
.order-card-paid-time { font-size: 12px; color: var(--success); font-weight: 600; }
.order-item-qty-price { font-size: 13px; color: var(--text-light); white-space: nowrap; }
.item-delete-btn {
  width: 26px; height: 26px; border-radius: 50%; border: none;
  background: var(--danger-light); color: var(--danger);
  font-size: 13px; font-weight: 700; cursor: pointer; flex-shrink: 0;
  margin-left: 4px; display: flex; align-items: center; justify-content: center;
}
.item-delete-btn:active { background: var(--danger); color: white; }
.detail-footer {
  position: sticky; bottom: 64px;
  background: var(--bg); padding: 16px 0;
  border-top: 2px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.detail-total { font-size: 20px; font-weight: 700; color: var(--primary); }
.detail-actions { display: flex; gap: 8px; }
.menu-category { margin-bottom: 20px; }
.menu-category-title {
  font-size: 14px; font-weight: 700; color: var(--primary);
  padding: 8px 0; border-bottom: 2px solid var(--primary-light); margin-bottom: 8px;
}
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; margin-bottom: 6px;
  cursor: pointer; transition: all 0.15s;
}
.menu-item:active { background: var(--primary-light); }
.menu-item.in-cart { border-color: var(--primary); background: #fef8f4; }
.menu-item-info { flex: 1; }
.menu-item-name { font-size: 15px; font-weight: 600; }
.menu-item-name .recommended { color: var(--danger); font-size: 12px; margin-left: 4px; }
.menu-item-desc { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.menu-item-price { font-size: 16px; font-weight: 700; color: var(--primary); white-space: nowrap; margin-left: 12px; }
.menu-item-qty { display: flex; align-items: center; gap: 8px; margin-left: 12px; }
.qty-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--primary); background: white; color: var(--primary);
  font-size: 18px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.qty-btn:active { background: var(--primary); color: white; }
.qty-value { font-size: 18px; font-weight: 700; min-width: 24px; text-align: center; }
.cart-bar {
  position: fixed; bottom: 72px; left: 12px; right: 12px;
  background: var(--primary); color: white; border-radius: var(--radius);
  padding: 14px 20px; display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 16px;
  box-shadow: var(--shadow-lg); cursor: pointer; z-index: 50;
}
.cart-bar:active { transform: scale(0.98); }
.cart-bar-action { font-size: 14px; opacity: 0.9; }
.cart-bar-modal { position: relative; bottom: auto; left: auto; right: auto; margin-top: 12px; }
.cart-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; margin-bottom: 6px;
}
.cart-item-name { font-weight: 600; flex: 1; }
.cart-item-qty { color: var(--text-light); margin: 0 12px; }
.cart-item-price { font-weight: 700; color: var(--primary); }
.cart-item-remove { margin-left: 12px; color: var(--danger); cursor: pointer; font-size: 18px; padding: 4px; }
.cart-summary {
  background: var(--primary-light); border-radius: var(--radius-sm);
  padding: 16px; margin: 16px 0; font-size: 14px;
}
.cart-summary-total {
  display: flex; justify-content: space-between;
  font-size: 20px; font-weight: 700; color: var(--primary);
  border-top: 2px solid var(--primary); padding-top: 8px; margin-top: 8px;
}
.bill-section { margin-bottom: 16px; }
.bill-section-title { font-size: 13px; font-weight: 700; color: var(--text-light); margin-bottom: 6px; }
.bill-item { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.bill-set {
  background: var(--success-light); border: 1px solid #c6f0c6;
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 6px;
}
.bill-set-name { font-weight: 700; color: var(--success); margin-bottom: 4px; }
.bill-set-items { font-size: 13px; color: var(--text-light); }
.bill-set-saving { font-size: 12px; color: var(--success); font-weight: 600; margin-top: 4px; }
.bill-total-section { background: var(--primary-light); border-radius: var(--radius-sm); padding: 16px; margin-top: 16px; }
.bill-total-row { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 14px; }
.bill-discount-row { color: var(--success); font-weight: 600; }
.bill-grand-total {
  display: flex; justify-content: space-between;
  font-size: 24px; font-weight: 700; color: var(--primary);
  margin-top: 8px; padding-top: 8px; border-top: 2px solid var(--primary);
}
.sales-date-picker { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 20px; }
.sales-date-picker input[type="date"] {
  font-size: 16px; font-weight: 600; padding: 8px 12px;
  border: 2px solid var(--border); border-radius: var(--radius-sm); color: var(--text); background: white;
}
.sales-summary {
  background: linear-gradient(135deg, #d4652a, #bf5620); color: white;
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow-lg);
}
.sales-summary-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; opacity: 0.9; }
.sales-summary-total {
  display: flex; justify-content: space-between; font-size: 24px; font-weight: 700;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.3);
}
.sales-section-title { font-size: 15px; font-weight: 700; margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--primary-light); }
.sales-menu-item {
  display: grid; grid-template-columns: 1fr 60px 80px;
  align-items: center;
  padding: 10px 12px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 4px;
}
.sales-menu-name { font-weight: 600; }
.sales-menu-qty { color: var(--text-light); font-size: 13px; text-align: right; }
.sales-menu-amount { font-weight: 700; color: var(--primary); text-align: right; }
.modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-content {
  background: var(--bg); border-radius: 20px 20px 0 0;
  width: 100%; max-height: 85vh; overflow-y: auto;
  padding: 20px 16px; animation: modalSlideUp 0.3s ease;
}
.modal-large { max-height: 90vh; }
@keyframes modalSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--border); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-footer { display: flex; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.btn-primary {
  background: var(--primary); color: white; border: none; border-radius: var(--radius-sm);
  padding: 12px 24px; font-size: 15px; font-weight: 700; cursor: pointer; flex: 1;
}
.btn-primary:active { background: var(--primary-dark); transform: scale(0.98); }
.btn-primary:disabled, .btn-primary.btn-disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary {
  background: white; color: var(--text); border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 24px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-small {
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: white; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-success {
  background: var(--success); color: white; border: none; border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-success.btn-disabled { background: #ccc; color: #888; cursor: not-allowed; }
.btn-back { background: none; border: none; color: var(--primary); font-size: 15px; font-weight: 600; cursor: pointer; }
.btn-large { width: 100%; padding: 16px; font-size: 17px; border-radius: var(--radius); }
.btn-reload {
  padding: 6px 14px; border-radius: 20px; border: 2px solid var(--primary);
  background: white; font-size: 13px; font-weight: 700; color: var(--primary); cursor: pointer;
}
.btn-reload:active { background: var(--primary); color: white; }
.btn-add-order {
  background: var(--primary-light); color: var(--primary); border: 2px solid var(--primary);
  border-radius: var(--radius-sm); padding: 10px 16px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-danger-outline {
  background: white; color: var(--danger); border: 2px solid var(--danger);
  border-radius: var(--radius-sm); padding: 10px 16px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-danger-outline:active { background: var(--danger); color: white; }
.toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white; padding: 12px 24px;
  border-radius: var(--radius); font-size: 14px; font-weight: 600;
  z-index: 300; box-shadow: var(--shadow-lg);
}
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-light); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 15px; }

.kitchen-card {
  background: var(--bg-card); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.kitchen-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--primary-light);
}
.kitchen-table { font-size: 18px; font-weight: 700; color: var(--primary); }
.kitchen-time { font-size: 13px; color: var(--text-light); }
.kitchen-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid #f5ede6;
}
.kitchen-item:last-child { border-bottom: none; }
.kitchen-item-urgent { background: var(--danger-light); margin: 0 -16px; padding: 10px 16px; border-radius: 6px; }
.kitchen-item-name { flex: 1; font-size: 16px; font-weight: 600; }
.kitchen-item-elapsed { font-size: 14px; font-weight: 700; color: var(--text-light); min-width: 40px; text-align: right; }
.kitchen-item-urgent .kitchen-item-elapsed { color: var(--danger); }
.text-muted { color: var(--text-light); }
.text-sm { font-size: 13px; }
.mt-8 { margin-top: 8px; }

.loading-state {
  text-align: center; padding: 60px 20px; color: var(--text-light);
  font-size: 15px; display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.loading-spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.timing-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 300;
  display: flex; align-items: center; justify-content: center;
}
.timing-popup {
  background: white; border-radius: 16px; padding: 24px; width: 280px;
  text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.timing-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.timing-subtitle { font-size: 13px; color: var(--text-light); margin-bottom: 20px; }
.timing-buttons { display: flex; gap: 12px; margin-bottom: 16px; }
.timing-btn {
  flex: 1; padding: 14px; border-radius: 10px; font-size: 16px; font-weight: 700;
  cursor: pointer; border: 2px solid; transition: all 0.15s;
}
.timing-before { background: #e8f4fd; color: #2563eb; border-color: #93c5fd; }
.timing-before:active { background: #2563eb; color: white; }
.timing-anytime { background: #e6f4ea; color: #2d8a4e; border-color: #86efac; }
.timing-anytime:active { background: #2d8a4e; color: white; }
.timing-after { background: #fef3ec; color: #c05621; border-color: #f0d4bc; }
.timing-after:active { background: #c05621; color: white; }
.timing-cancel {
  background: none; border: none; color: var(--text-light); font-size: 14px; cursor: pointer;
}
.timing-tag {
  font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 4px;
  display: inline-block; vertical-align: middle; margin-left: 4px;
}
.timing-tag-before { background: #2563eb; color: white; }
.timing-tag-anytime { background: #2d8a4e; color: white; }
.timing-tag-after { background: #c05621; color: white; }

.menu-item-cart-entries { display: flex; flex-direction: column; gap: 4px; margin-left: 8px; }

.kitchen-item-waiting { }
.kitchen-item-waiting .kitchen-item-elapsed { color: var(--text-light); }
.kitchen-item-served { opacity: 0.45; }
.kitchen-item-served .kitchen-item-name { text-decoration: line-through; }
.kitchen-item-served .kitchen-item-elapsed { color: var(--success); }

.kitchen-card-complete {
  background: var(--success-light); border-color: var(--success);
}
.kitchen-card-complete .kitchen-item-served { opacity: 0.6; }
.kitchen-item-check {
  width: 24px; height: 24px; color: var(--success); font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.kitchen-complete-icon { font-size: 22px; }
.kitchen-complete-msg {
  font-size: 16px; font-weight: 700; color: var(--success);
  padding: 12px 0;
}
.kitchen-complete-actions {
  display: flex; gap: 12px; justify-content: center; padding-top: 8px;
}
.kitchen-btn-done {
  background: var(--success); color: white; border: none;
  border-radius: 8px; padding: 10px 32px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.kitchen-btn-done:active { opacity: 0.8; }
.kitchen-btn-undo {
  background: white; color: var(--text-light); border: 2px solid var(--border);
  border-radius: 8px; padding: 10px 24px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.kitchen-btn-undo:active { background: #f5f5f5; }
