:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --border: #dfe4ea;
  --primary: #f06423;
  --primary-dark: #d94f13;
  --success: #16865c;
  --danger: #c43d4b;
  --sidebar: #18212f;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans KR", "Malgun Gothic", Arial, sans-serif;
  font-size: 15px;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #121a26;
}
.auth-card {
  width: min(420px, 100%);
  padding: 38px;
  border-radius: 16px;
  background: var(--surface);
}
.brand { font-size: 28px; font-weight: 800; color: var(--primary); }
.brand-sub { margin-top: 5px; color: var(--muted); font-size: 14px; }

.field { display: grid; gap: 7px; margin-top: 18px; }
.field label { color: var(--muted); font-size: 13px; font-weight: 700; }
.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(240, 100, 35, .12);
}
.textarea { min-height: 90px; resize: vertical; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--primary-dark); }
.button:disabled { cursor: wait; opacity: .65; }
.button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.button.secondary:hover { background: var(--surface-muted); }
.button.danger { background: var(--danger); }
.button.block { width: 100%; margin-top: 22px; }

.alert {
  margin-top: 16px;
  padding: 11px 13px;
  border-radius: 8px;
  background: #fff0f1;
  color: var(--danger);
  font-size: 13px;
}
.alert.success { background: #eaf8f2; color: var(--success); }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: var(--sidebar);
  color: #e8edf4;
}
.sidebar .brand { font-size: 21px; }
.role-chip { display: inline-flex; margin-top: 12px; padding: 5px 9px; border-radius: 999px; background: rgba(240,100,35,.16); color: #ffb38c; font-size: 11px; font-weight: 800; }
.sidebar-nav { display: grid; gap: 6px; margin-top: 34px; }
.sidebar-nav a {
  padding: 11px 12px;
  border-radius: 8px;
  color: #aeb9c8;
  text-decoration: none;
}
.sidebar-nav a.active, .sidebar-nav a:hover { color: white; background: #273346; }
.sidebar-footer { position: absolute; left: 18px; right: 18px; bottom: 20px; }
.sidebar-user { margin-bottom: 10px; color: #aeb9c8; font-size: 13px; }

.main { min-width: 0; padding: 26px 30px 60px; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-title { margin: 0; font-size: 25px; }
.page-description { margin: 6px 0 0; color: var(--muted); }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.toolbar .input { min-height: 40px; max-width: 260px; }
.table-wrap { overflow-x: auto; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 16px; border-top: 1px solid var(--border); }
.excel-choice-list { display: grid; gap: 8px; max-height: 48vh; margin: 14px 0; overflow: auto; }
.excel-choice { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 9px; padding: 11px; cursor: pointer; }
.excel-choice:hover { background: var(--surface-muted); }
.data-table { width: 100%; border-collapse: collapse; min-width: 780px; }
.data-table th, .data-table td {
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.data-table th { background: var(--surface-muted); color: var(--muted); font-size: 13px; }
.data-table tbody tr:hover { background: #fffaf7; }
.empty { padding: 48px 20px; color: var(--muted); text-align: center; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf1f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.badge.live { background: #e7f8f0; color: var(--success); }
.badge.ended { background: #eef0f3; color: #4b5565; }
.badge.blocked { background: #fff0f1; color: var(--danger); }
.badge.warning { background: #fff7e6; color: #a15c00; }
.table-actions { display: flex; gap: 6px; white-space: nowrap; }
.cell-sub { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.multiline-cell { white-space: pre-line; line-height: 1.55; }
.unmatched-row { background: #fffaf0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 26, 38, .58);
  z-index: 50;
}
.modal {
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 14px;
  background: var(--surface);
  padding: 24px;
}
.modal-header { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.modal-title { margin: 0; font-size: 20px; }
.modal-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.modal-wide { width: min(980px, 100%); }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.settings-card { padding: 20px; }
.settings-card h2 { margin: 0; font-size: 19px; }
.settings-card > p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.check-row { display: flex; align-items: center; gap: 9px; margin-top: 18px; color: var(--muted); font-size: 13px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.customer-table { min-width: 1120px; }
.customer-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .85fr); gap: 22px; margin-top: 16px; }
.detail-panel { border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.detail-panel + .detail-panel { margin-top: 12px; }
.detail-panel h3 { margin: 0 0 10px; font-size: 15px; }
.detail-list { color: var(--muted); font-size: 13px; }
.detail-row { padding: 9px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: 0; }
.detail-row strong, .detail-row span { display: block; }
.detail-row span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.inline-form { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 7px; margin-top: 12px; }
.inline-form .input, .inline-form .select { min-height: 40px; }
.profile-detail-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.profile-detail-row span { margin: 0; color: var(--text); }
.profile-detail-row .button { min-height: 32px; padding: 5px 9px; font-size: 12px; }

.settlement-page { background: #eef1f5; }
.settlement-shell { width: min(560px, 100%); margin: 0 auto; padding: 22px 14px 60px; }
.settlement-header { padding: 12px 4px 18px; }
.settlement-header h1 { margin: 10px 0 5px; font-size: 25px; }
.settlement-header p { margin: 0; color: var(--muted); }
.settlement-card { margin-bottom: 12px; padding: 20px; }
.settlement-card h2 { margin: 0 0 15px; font-size: 18px; }
.settlement-item { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.settlement-item img { width: 58px; height: 58px; border-radius: 9px; object-fit: cover; background: var(--surface-muted); }
.settlement-item p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.settlement-item b { white-space: nowrap; }
.amount-summary { display: grid; gap: 10px; padding-top: 16px; }
.amount-summary > div { display: flex; justify-content: space-between; gap: 14px; }
.amount-summary .total { padding-top: 12px; border-top: 1px solid var(--border); color: var(--primary-dark); font-size: 18px; }
.bank-card > strong { display: block; font-size: 20px; }
.bank-card > p { color: var(--muted); }
.notice-box { margin-top: 12px; padding: 13px; border-radius: 9px; background: var(--surface-muted); color: var(--muted); font-size: 13px; line-height: 1.65; }
.section-help { margin: -8px 0 8px; color: var(--muted); font-size: 13px; }

.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.summary-card { padding: 16px; }
.summary-card span { display: block; color: var(--muted); font-size: 12px; }
.summary-card b { display: block; margin-top: 7px; font-size: 20px; }
.order-management-toolbar { display: flex; justify-content: space-between; margin-bottom: 12px; }
.tab-buttons { display: flex; gap: 7px; }
.tab-button.active { background: var(--sidebar); }
.managed-order-list { display: grid; gap: 14px; }
.managed-order-card { padding: 18px; }
.managed-order-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.managed-order-head h2 { margin: 0; font-size: 19px; }
.managed-order-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.member-state { padding: 6px 9px; border-radius: 999px; background: var(--surface-muted); color: var(--muted); font-size: 12px; font-weight: 700; }
.managed-items { display: grid; gap: 7px; padding: 13px 0; }
.managed-item { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(120px, .7fr) 80px 100px auto auto; gap: 7px; align-items: center; }
.managed-item .input { min-height: 38px; }
.managed-order-form { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 9px; padding-top: 13px; border-top: 1px solid var(--border); }
.managed-order-form label { color: var(--muted); font-size: 12px; }
.managed-order-form .input, .managed-order-form .select { margin-top: 5px; min-height: 40px; }
.managed-order-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; margin-top: 15px; }
.managed-order-actions > strong { margin-right: auto; font-size: 19px; }
.search-results { display: grid; gap: 7px; margin-top: 14px; max-height: 400px; overflow: auto; }
.search-result-row { width: 100%; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 12px; text-align: left; cursor: pointer; }
.search-result-row:hover { border-color: var(--primary); background: #fffaf7; }

.live-board-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.product-entry, .product-list-panel { padding: 20px; }
.product-entry h2, .product-list-panel h2 { margin: 0; font-size: 19px; }
.image-drop-zone { display: grid; place-items: center; gap: 7px; min-height: 170px; margin-top: 16px; border: 2px dashed var(--border); border-radius: 12px; background: var(--surface-muted); padding: 14px; text-align: center; }
.image-drop-zone.uploading { opacity: .6; }
.image-drop-zone.ready { border-color: var(--success); }
.image-drop-zone > span { color: var(--muted); font-size: 12px; }
.image-drop-zone img { width: 100%; max-height: 190px; border-radius: 9px; object-fit: contain; }
.product-search-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 0 0; }
.product-search-row .input { max-width: 320px; }
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.product-list { display: grid; gap: 10px; padding-top: 14px; }
.product-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 120px 110px 100px auto;
  gap: 9px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}
.product-row.closed { opacity: .68; }
.product-thumb { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 9px; overflow: hidden; background: #e8edf3; color: var(--muted); font-size: 9px; }
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-row .input { min-height: 40px; }
.product-actions { display: flex; gap: 6px; }
.impact-note { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.order-summary-heading {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.order-summary-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.order-list { display: grid; gap: 9px; margin-top: 14px; }
.order-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 120px auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
}
.order-customer { font-weight: 800; }
.order-items { color: var(--muted); font-size: 13px; line-height: 1.55; }
.board-order-item { display: grid; grid-template-columns: minmax(150px, 1fr) 34px 28px 34px auto auto; gap: 5px; align-items: center; padding: 4px 0; }
.board-order-item .button { min-height: 30px; padding: 4px 7px; font-size: 11px; }
.board-order-item b { text-align: center; color: var(--text); }
.order-total { text-align: right; font-weight: 800; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 16px; }
  .sidebar-nav { grid-template-columns: repeat(2, 1fr); margin-top: 16px; }
  .sidebar-footer { position: static; margin-top: 18px; }
  .main { padding: 20px 16px 50px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar .input { max-width: none; }
  .live-board-grid { grid-template-columns: 1fr; }
  .product-row { grid-template-columns: 1fr; }
  .impact-note { grid-column: auto; }
  .order-row { grid-template-columns: 1fr; }
  .order-total { text-align: left; }
  .settings-grid, .form-row, .customer-detail-grid, .inline-form { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .managed-item, .managed-order-form { grid-template-columns: 1fr; }
  .managed-order-actions { align-items: stretch; flex-direction: column; }
  .managed-order-actions > strong { margin: 0 0 5px; }
}
