:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --surface-muted: #eef2f6;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fee2e2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.18);
  --font-sans: -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

/* 공통 레이아웃 */
.page-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}

.nav-link:hover {
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

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

/* 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

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

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

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-alt);
}

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

.btn-success:hover:not(:disabled) {
  filter: brightness(0.95);
}

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

.btn-warning:hover:not(:disabled) {
  filter: brightness(0.95);
}

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

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

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
}

.btn-lg {
  padding: 13px 20px;
  font-size: 16px;
  border-radius: var(--radius-md);
}

/* 폼 요소 */
.form-group {
  margin-bottom: 14px;
}

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

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.text-muted {
  color: var(--text-muted);
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

/* 카드 & 패널 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

/* 배지 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

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

.badge-accepted {
  background: var(--warning-soft);
  color: var(--warning);
}

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

.badge-canceled {
  background: var(--surface-muted);
  color: var(--text-muted);
}

.badge-paid {
  background: var(--primary-soft);
  color: var(--primary);
}

/* 테이블 */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data-table th,
table.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

table.data-table th {
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-weight: 700;
  white-space: nowrap;
}

table.data-table tbody tr:hover {
  background: var(--surface-alt);
}

/* 홈 화면 (index.html) */
.home-container {
  max-width: 820px;
  margin: 40px auto;
  padding: 0 20px;
}

.home-header {
  text-align: center;
  margin-bottom: 28px;
}

.home-header h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 800;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.home-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 148px;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.home-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.home-tile-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
}

.home-tile-desc {
  font-size: 14px;
  color: var(--text-secondary);
}

.home-notice {
  margin-top: 22px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: 14px;
}

@media (max-width: 600px) {
  .home-grid {
    grid-template-columns: 1fr;
  }
}

/* 손님 테이블오더 (order.html - 모바일 세로 우선) */
.order-page {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 92px;
}

.order-topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.order-table-badge {
  font-size: 18px;
  font-weight: 800;
}

.category-tabs {
  position: sticky;
  top: 57px;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.cat-tab {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

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

.order-section {
  padding: 16px 16px 6px;
}

.order-section-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 800;
}

.menu-card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.menu-card.soldout {
  background: #f1f5f9;
  opacity: 0.72;
}

.menu-thumb {
  width: 84px;
  height: 84px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-muted);
}

.menu-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.menu-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-name {
  font-weight: 700;
  font-size: 16px;
}

.menu-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.menu-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.menu-price {
  font-weight: 800;
  font-size: 15px;
}

.cart-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 28;
  background: var(--primary);
  color: #fff;
  padding: 14px 18px;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.16);
}

.cart-bar-btn {
  width: 100%;
  max-width: 608px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}

/* 바텀 시트 / 드로어 */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  z-index: 45;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-panel {
  width: 100%;
  max-width: 640px;
  max-height: 86vh;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.sheet-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.sheet-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.sheet-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

.qty-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}

/* POS 메인 (pos.html - 1280px 가로 우선) */
.pos-stats-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 14px;
}

.pos-stat-pill {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-weight: 700;
}

.pos-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 20px;
}

.pos-layout.with-drawer {
  grid-template-columns: minmax(0, 1fr) 430px;
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

@media (min-width: 1280px) {
  .table-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .table-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pos-layout.with-drawer {
    grid-template-columns: 1fr;
  }
}

.pos-table-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  min-height: 152px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.pos-table-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.pos-table-card.empty {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--text-muted);
}

.pos-table-card.occupied {
  background: var(--surface);
  border-color: #93c5fd;
}

.pos-table-card.has-new {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}

.pos-table-card.selected {
  outline: 3px solid var(--primary);
}

.pos-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.pos-table-name {
  font-size: 17px;
  font-weight: 800;
}

.pos-elapsed {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.pos-summary-lines {
  margin: 8px 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.pos-card-total {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

@keyframes blinkBadge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.badge-blink {
  animation: blinkBadge 1.1s infinite;
}

.pos-detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 102px);
  position: sticky;
  top: 82px;
  overflow: hidden;
}

.pos-detail-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pos-detail-body {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1;
}

.pos-order-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  background: var(--surface-alt);
}

.pos-detail-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.method-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

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

/* 통계 (stats.html) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  margin-top: 6px;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.chart-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
}

.chart-box {
  position: relative;
  height: 270px;
}

/* 관리 탭 (admin.html) */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.admin-tab-btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}

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

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* 모달 & 토스트 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.pin-backdrop {
  z-index: 90;
  background: rgba(15, 23, 42, 0.72);
}

.modal-dialog {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #0f172a;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast-item.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: #15803d;
}

.toast-error {
  background: #b91c1c;
}

.toast-warning {
  background: #b45309;
}

.full-error-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}