:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.badge-neutral {
  background: #f1f5f9;
  color: var(--text-muted);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Order Number Bar */
.order-number-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
}

.order-number-current {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.order-number-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e40af;
}

.order-number-stepper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface);
  padding: 0.15rem 0.35rem;
  border-radius: 8px;
  border: 1px solid #93c5fd;
}

.order-number-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  min-width: 2.5rem;
  text-align: center;
}

.order-number-Input-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.order-number-Input-group input {
  width: 95px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

/* Main Layout */
.main-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 960px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* Menu Section */
.menu-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.1rem;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.category-tab {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.category-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 0.85rem;
}

.menu-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  transition: border-color 0.15s, background-color 0.15s, transform 0.08s;
  user-select: none;
  cursor: pointer;
  position: relative;
}

.menu-card:hover {
  border-color: #93c5fd;
}

.menu-card.selected {
  border-color: var(--primary);
  background: #f8fbff;
}

.menu-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.menu-category-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 0.25rem;
}

.menu-name {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.menu-price {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
}

.menu-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border-radius: 8px;
  padding: 0.25rem;
  border: 1px solid var(--border);
}

.qty-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: none;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn-minus {
  background: #e2e8f0;
  color: var(--text);
}

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

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

.qty-display {
  font-size: 1.05rem;
  font-weight: 700;
  min-width: 2rem;
  text-align: center;
}

/* Cart & Right Panel */
.cart-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 4.75rem;
}

.cart-card,
.history-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.15rem;
  box-shadow: var(--shadow);
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}

.cart-header h2 {
  font-size: 1.05rem;
}

.cart-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sheet-preview-wrapper {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
  max-height: 280px;
  overflow-y: auto;
}

.sheet-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.sheet-preview-table th {
  background: #f8fafc;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sheet-preview-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.sheet-preview-table .col-qty {
  text-align: center;
  width: 96px;
}

.sheet-preview-table .col-price {
  text-align: right;
  width: 95px;
  font-weight: 700;
}

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem 0.5rem;
}

.cart-inline-qty {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.cart-inline-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
}

/* Summary */
.cart-summary {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.summary-total {
  border-top: 1px solid var(--border);
  padding-top: 0.65rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.grand-total {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--primary);
}

.change-calculator {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
}

.change-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.change-input-row input {
  width: 120px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.change-display strong {
  font-size: 1rem;
  color: var(--success);
}

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s;
}

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

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}

.btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #1e40af;
  color: #fff;
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-text-danger {
  background: transparent;
  color: var(--danger);
}

.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: #f1f5f9;
  cursor: pointer;
  font-weight: 700;
}

.btn-submit {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  margin-top: 0.25rem;
}

/* History */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.history-header h3 {
  font-size: 0.92rem;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
}

.history-item {
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  background: #f8fafc;
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.history-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.75rem 0;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 540px;
  width: 100%;
  padding: 1.25rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.form-input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.spec-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.95rem;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

.spec-box h4 {
  margin-bottom: 0.35rem;
}

.spec-box ul {
  padding-left: 1.1rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 60;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

