:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --sidebar: #14181f;
  --sidebar-text: #e8ecf2;
  --sidebar-muted: #8b93a3;
  --border: #e2e5eb;
  --text: #1a1d24;
  --muted: #6b7280;
  --accent: #9a7b3c;
  --accent-soft: rgba(154, 123, 60, 0.12);
  --accent-2: #2f6fed;
  --danger: #d14343;
  --success: #1f9d63;
  --radius: 10px;
  --sidebar-w: 248px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* ——— Login (logo as full-bleed background) ——— */
.login-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: #f5f7fb;
  overflow: hidden;
  background: #12151b;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    url("../assets/logo_bg.jpg") center / cover no-repeat;
  transform: scale(1.04);
  z-index: 0;
  pointer-events: none;
}

.login-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(
      105deg,
      rgba(10, 12, 16, 0.82) 0%,
      rgba(10, 12, 16, 0.55) 42%,
      rgba(10, 12, 16, 0.72) 100%
    );
}

.login-hero,
.login-footer {
  position: relative;
  z-index: 2;
}

.login-hero {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 24px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
  align-items: start;
  flex: 1;
}

.login-copy h1 {
  margin: 0 0 12px;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.2;
  font-weight: 700;
}

.login-copy p {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 1.02rem;
  max-width: 34ch;
}

.login-panel {
  background: rgba(18, 22, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 24px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.login-panel h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.login-panel > p {
  margin: 0 0 18px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.9rem;
}

.login-panel {
  max-height: min(78vh, 720px);
  overflow-y: auto;
}

.login-auth-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 0.86rem;
  color: rgba(255, 255, 255, 0.45);
}

.login-auth-links button {
  background: none;
  border: 0;
  padding: 0;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.login-auth-links button:hover {
  color: #fff;
}

.field-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.field-row input {
  flex: 1;
  min-width: 0;
}

.field-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.auth-check input {
  margin-top: 3px;
}

.auth-check a {
  color: rgba(255, 220, 160, 0.95);
}

.auth-back {
  width: 100%;
  margin-top: 10px;
}

.auth-status {
  margin-top: 6px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  min-height: 1.1em;
}

.auth-status.ok {
  color: #8ddea8;
}

.auth-status.bad {
  color: #f0a0a0;
}

.auth-result {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(141, 222, 168, 0.12);
  border: 1px solid rgba(141, 222, 168, 0.35);
  color: #c8f0d4;
  font-size: 0.92rem;
}

#error.auth-success,
.login-error.auth-success,
.error.auth-success {
  background: rgba(141, 222, 168, 0.14);
  border-color: rgba(141, 222, 168, 0.35);
  color: #c8f0d4;
}

.login-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.8rem;
}

.login-footer a {
  color: rgba(255, 255, 255, 0.65);
}

/* ——— App shell ——— */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

.sidebar-brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.95rem;
}

.sidebar-brand span {
  display: block;
  font-size: 0.72rem;
  color: var(--sidebar-muted);
}

.sidebar-user {
  padding: 0 8px 14px;
}

.sidebar-user strong {
  display: block;
  font-size: 0.95rem;
}

.sidebar-user span {
  font-size: 0.78rem;
  color: var(--sidebar-muted);
}

.side-label {
  padding: 10px 10px 6px;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.side-nav button,
.role-switch button {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--sidebar-muted);
  font: inherit;
  font-size: 0.92rem;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.side-nav button:hover,
.role-switch button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-text);
}

.side-nav button.active,
.role-switch button.active {
  background: rgba(201, 169, 98, 0.18);
  color: #e8d5a3;
  font-weight: 600;
}

.role-switch {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.shell-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.shell-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 22px 32px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.shell-top h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.shell-top .badge {
  margin-right: 8px;
  vertical-align: middle;
}

.shell-content {
  padding: 24px 32px 48px;
  width: min(1280px, 100%);
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.header-actions select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* ——— Forms / buttons ——— */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.82rem;
  color: var(--muted);
}

.login-shell .field label {
  color: rgba(255, 255, 255, 0.55);
}

.login-shell .field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font: inherit;
}

.field input,
.field select,
.inline-filters input,
.inline-filters select,
.inline-form input,
.inline-form select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #d4b978, #a8893f);
  color: #111;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.login-panel .btn-ghost {
  color: rgba(255, 255, 255, 0.65);
  border-color: rgba(255, 255, 255, 0.18);
}

.login-panel .btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #f5f7fb;
  border-color: rgba(255, 255, 255, 0.2);
}

.sidebar .btn-ghost {
  width: 100%;
  color: var(--sidebar-muted);
  border-color: rgba(255, 255, 255, 0.12);
}

.sidebar .btn-ghost:hover {
  color: var(--sidebar-text);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-sm {
  padding: 7px 11px;
  font-size: 0.85rem;
  width: auto;
}

.error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 107, 107, 0.15);
  color: #ffb4b4;
  font-size: 0.9rem;
}

/* ——— Content surfaces (light, flat) ——— */
.card,
.panel,
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}

.panel {
  padding: 18px 20px;
  margin-bottom: 16px;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 0.98rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stats-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat {
  padding: 16px;
}

.stat small {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.stat strong {
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-text {
  font-size: 0.95rem;
  line-height: 1.4;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(47, 111, 237, 0.1);
  color: var(--accent-2);
}

.badge-admin {
  background: rgba(47, 111, 237, 0.12);
  color: var(--accent-2);
}

.badge-owner {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-member {
  background: rgba(31, 157, 99, 0.12);
  color: var(--success);
}

.badge-pro {
  background: rgba(47, 111, 237, 0.1);
  color: var(--accent-2);
}

.subline,
.gateway-lead,
.panel-note {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.panel-toolbar h3 {
  margin: 0;
}

.inline-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-filters input,
.inline-filters select {
  width: auto;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.inline-form input,
.inline-form select {
  width: auto;
  min-width: 120px;
}

.inline-form .btn-primary {
  width: auto;
}

.product-form .field label {
  color: var(--muted);
}

.product-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.product-form-grid .field {
  margin-bottom: 0;
}

.product-form-grid .field-span {
  grid-column: 1 / -1;
}

.product-form-actions {
  margin-top: 14px;
}

.product-form-actions .btn-primary {
  width: auto;
  min-width: 120px;
}

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

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-grid label.full {
  grid-column: 1 / -1;
}

.form-grid input,
.form-grid select {
  width: 100%;
}

.form-actions {
  margin-top: 14px;
}

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.product-form textarea,
#owner-notice-content,
#owner-policy-refund {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.memo-input {
  width: 140px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}

.schedule-status-select {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  min-width: 96px;
}

.owner-panel.hidden,
.admin-panel.hidden,
.pro-panel.hidden,
.member-panel.hidden {
  display: none;
}

.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.store-card {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.store-card-body {
  padding: 14px 14px 8px;
  flex: 1;
}

.store-card-meta {
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.store-card h4 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.store-card-desc {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 3.6em;
}

.store-card-price {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.store-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border, #e5e7eb);
}

.store-qty {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.store-qty input,
.store-cart-qty {
  width: 64px;
}

.store-checkout-grid {
  margin-top: 8px;
}

.cart-badge-wrap {
  font-size: 0.85rem;
  color: var(--muted);
}

.cart-badge {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent, #111);
  color: #fff;
  text-align: center;
  font-size: 0.8rem;
}

.cart-badge.hidden {
  display: none;
}

.store-legal {
  margin: 14px 0 10px;
}

.store-legal-body {
  white-space: pre-wrap;
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 8px 0 0;
  line-height: 1.45;
}

.store-agree {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.88rem;
  margin: 8px 0 4px;
}

.panel-note.is-error {
  color: #b42318;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 14px;
  min-height: 480px;
}

.chat-inbox {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: #fff;
  overflow: auto;
  max-height: 70vh;
  padding: 6px;
}

.chat-room-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.chat-room-item:hover,
.chat-room-item.is-active {
  background: #f3f4f6;
}

.chat-room-item.is-unread .chat-room-title {
  font-weight: 700;
}

.chat-room-title {
  grid-column: 1;
  font-size: 0.95rem;
}

.chat-room-time {
  grid-column: 2;
  grid-row: 1;
  font-size: 0.75rem;
  color: var(--muted);
}

.chat-room-sub,
.chat-room-preview {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-main {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 480px;
  max-height: 70vh;
}

.chat-thread-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.chat-thread {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fafafa;
}

.chat-bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
}

.chat-bubble p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble time {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.chat-bubble.is-mine {
  align-self: flex-end;
  background: #111;
  color: #fff;
  border-color: #111;
}

.chat-bubble.is-mine time {
  color: rgba(255, 255, 255, 0.7);
}

.chat-bubble.is-other {
  align-self: flex-start;
}

.chat-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border, #e5e7eb);
}

.chat-composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 44px;
  grid-column: 1;
  grid-row: 1;
}

.chat-composer .btn {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
}

.chat-composer .panel-note {
  grid-column: 1 / -1;
  margin: 0;
}

.chat-composer.hidden {
  display: none;
}

@media (max-width: 860px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
  .chat-inbox {
    max-height: 220px;
  }
}

/* Legacy tab classes unused in shell; keep harmless */
.portal-tabs,
.owner-tabs {
  display: none;
}

.dashboard-header {
  display: none;
}

.gateway-lead {
  margin: 0 0 16px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.role-card {
  padding: 20px;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.role-card:hover {
  border-color: rgba(154, 123, 60, 0.45);
}

.role-card strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.role-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.test-page {
  padding: 28px 0 48px;
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
}

.test-page h1 {
  margin: 0 0 8px;
}

.test-page .lead {
  color: var(--muted);
  margin-bottom: 24px;
}

.checklist {
  padding: 20px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.checklist ol {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
}

.checklist code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}

.mobile-nav-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 40;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--sidebar);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 30;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.25);
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .shell-content {
    padding: 16px 16px 80px;
  }

  .shell-top {
    padding: 16px;
  }

  .login-hero,
  .grid-2,
  .stats,
  .stats-3,
  .role-grid {
    grid-template-columns: 1fr;
  }

  .login-hero {
    padding: 24px 0 16px;
  }

  .login-bg {
    background-position: center top;
  }
}
