/*
 * Peepseed Admin semantic design system
 *
 * The application is server-rendered Express/EJS, so this stylesheet provides
 * shadcn/ui-compatible tokens and presentation primitives without replacing
 * existing DOM events, form behavior, routing, or API integration.
 */

:root {
  color-scheme: light;

  --background: oklch(0.985 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.52 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.55 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);

  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.205 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.955 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);

  --success: oklch(0.962 0.027 151.328);
  --success-foreground: oklch(0.448 0.119 151.328);
  --warning: oklch(0.966 0.044 84.429);
  --warning-foreground: oklch(0.53 0.135 70.08);
  --info: oklch(0.962 0.024 266.74);
  --info-foreground: oklch(0.488 0.188 264.376);
  --destructive-soft: oklch(0.971 0.018 17.38);
  --destructive-soft-foreground: var(--destructive);
  --overlay: oklch(0 0 0 / 0.5);
  --shadow-color: oklch(0 0 0 / 0.08);
  --shadow-xs: 0 1px 2px oklch(0 0 0 / 0.035);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.05);
  --shadow-md: 0 8px 24px oklch(0 0 0 / 0.08);
  --shadow-lg: 0 24px 64px oklch(0 0 0 / 0.18);
  --shadow-ring: 0 0 0 3px var(--focus-ring);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;

  /* Compatibility aliases for the existing presentation layer. */
  --bg: var(--background);
  --surface: var(--card);
  --surface-soft: var(--muted);
  --ink: var(--foreground);
  --line: var(--border);
  --dark: var(--primary);
  --dark-soft: var(--secondary-foreground);
  --blue: var(--info-foreground);
  --green: var(--success-foreground);
  --amber: var(--warning-foreground);
  --red: var(--destructive);
  --success-soft: var(--success);
  --warning-soft: var(--warning);
  --info-soft: var(--info);
  --focus-ring: color-mix(in oklab, var(--ring) 28%, transparent);

  --radius: 0.625rem;
  --content-max: 1560px;
  --page-gutter: clamp(16px, 2.2vw, 32px);
  --space-section: 24px;
  --control-height: 36px;
  --control-height-touch: 44px;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-bold: 600;
}

html {
  background: var(--background);
}

body,
body[data-mode="dashboard"],
body[data-mode="product-create"],
body[data-mode="order-dashboard"],
body[data-mode="order-management"],
body[data-mode="order-detail"],
body[data-mode="review-detail"] {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

::selection {
  background: #FDFFC8;
  color: #111827;
}

::-moz-selection {
  background: #FDFFC8;
  color: #111827;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Sidebar */

.sidebar {
  width: 248px;
  border-right: 1px solid var(--sidebar-border);
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  box-shadow: none;
}

.sidebar-head {
  min-height: 64px;
  border-color: var(--sidebar-border);
  padding-inline: 16px;
}

.logo-link {
  gap: 10px;
}

.sidebar .brand-mark,
.sidebar .brand-mark.small {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  border: 0;
  border-radius: var(--radius);
  background: var(--sidebar-primary);
  color: var(--sidebar-primary-foreground);
  box-shadow: none;
  font-size: 11px;
}

.logo-link strong {
  color: var(--sidebar-foreground);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.logo-link .sidebar-brand-title {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.logo-link small {
  margin-top: 1px;
  color: var(--muted-foreground);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.nav-list {
  background: transparent;
  padding: 12px 10px 20px;
  scrollbar-color: color-mix(in oklab, var(--muted-foreground) 32%, transparent) transparent;
  scrollbar-width: thin;
}

.nav-list::-webkit-scrollbar {
  width: 7px;
}

.nav-list::-webkit-scrollbar-track,
.nav-list::-webkit-scrollbar-corner {
  background: transparent;
}

.nav-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in oklab, var(--muted-foreground) 36%, transparent);
  background-clip: padding-box;
}

.nav-group {
  margin-top: 18px;
}

.nav-group p {
  margin-bottom: 6px;
  padding-inline: 10px;
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-tree {
  gap: 2px;
}

.nav-item,
.nav-item-level-2,
.nav-item-level-3 {
  min-height: 36px;
  gap: 9px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: color-mix(in oklab, var(--sidebar-foreground) 72%, transparent);
  padding-inline: 10px;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 120ms ease, color 120ms ease;
}

.nav-item:hover:not(.active),
.nav-tree-entry.active-branch > .nav-parent:hover {
  border: 0;
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
  transform: none;
}

.nav-item.active,
.nav-item-level-2.active,
.nav-item-level-3.active,
.nav-tree-entry.active-branch > .nav-parent,
.nav-tree-level-1 > .nav-tree-entry.active-branch > .nav-parent {
  border: 0;
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
  box-shadow: none;
  font-weight: 600;
}

.nav-icon,
.nav-item-level-2 .nav-icon,
.nav-item-level-3 .nav-icon,
.nav-icon-dot {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: currentColor;
}

.nav-icon svg,
.icon-button > svg,
.admin-breadcrumb svg,
.admin-main-metric-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-icon-dot > span {
  width: 4px;
  height: 4px;
  background: currentColor;
  opacity: 0.55;
}

.nav-item-level-2,
.nav-item-level-3 {
  min-height: 32px;
  font-size: 12px;
}

.nav-submenu {
  margin: 3px 0 7px 25px;
}

.nav-tree-level-2 .nav-submenu {
  margin-left: 16px;
}

.nav-caret {
  width: 5px;
  height: 5px;
  border-width: 1px;
  opacity: 0.55;
}

.sidebar-footer {
  margin-top: 18px;
  border-color: var(--sidebar-border);
  padding-top: 12px;
}

.sidebar-logout-button {
  min-height: 36px;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius);
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  padding-inline: 10px;
  font-weight: 500;
}

.sidebar-logout-button:hover,
.sidebar-logout-button:focus-visible {
  border-color: var(--sidebar-border);
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
  filter: none;
}

/* Header and app layout */

.admin-layout,
.workspace {
  min-width: 0;
  background: var(--background);
}

.workspace {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  padding-left: 248px;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  padding: 0 var(--page-gutter);
}

.admin-topbar-leading,
.admin-breadcrumb {
  display: flex;
  min-width: 0;
  align-items: center;
}

.admin-topbar-leading {
  gap: 10px;
}

.admin-topbar-separator {
  width: 1px;
  height: 18px;
  background: var(--border);
}

.admin-breadcrumb {
  gap: 7px;
  color: var(--muted-foreground);
  font-size: 13px;
  white-space: nowrap;
}

.admin-breadcrumb a:hover {
  color: var(--foreground);
}

.admin-breadcrumb svg {
  width: 14px;
  height: 14px;
}

.admin-breadcrumb [aria-current="page"] {
  max-width: min(48vw, 520px);
  overflow: hidden;
  color: var(--foreground);
  font-weight: 500;
  text-overflow: ellipsis;
}

.admin-topbar-context {
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.admin-sidebar-toggle,
.admin-mobile-menu-button,
.icon-button {
  display: inline-flex;
  width: 34px;
  height: 34px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--foreground);
  box-shadow: none;
}

.admin-sidebar-toggle:hover,
.admin-mobile-menu-button:hover,
.icon-button:hover {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-foreground);
  filter: none;
}

.admin-sidebar-toggle > span {
  font-size: 21px;
  line-height: 1;
}

.mobile-only {
  display: none;
}

.content,
body[data-mode="dashboard"] .content,
body[data-mode="order-dashboard"] .content,
body[data-mode="order-management"] .content {
  width: 100%;
  max-width: calc(var(--content-max) + (var(--page-gutter) * 2));
  flex: 1;
  margin-inline: auto;
  background: transparent;
  padding: var(--space-section) var(--page-gutter) 48px;
}

.page-head {
  align-items: flex-end;
  margin-bottom: 20px;
}

.page-head h2,
.login-card h2 {
  color: var(--foreground);
  font-size: clamp(20px, 2vw, 24px);
  font-weight: 650;
  letter-spacing: -0.025em;
}

.page-head p:last-child {
  max-width: 760px;
  margin-top: 6px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.content > .page-head .eyebrow,
.dashboard-page-head .eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--muted-foreground);
  font-size: 10px;
  letter-spacing: 0.1em;
}

/* Inputs and controls */

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea,
.delivery-settings-editor input,
.delivery-settings-editor textarea,
.order-filter-row input,
.order-filter-row select,
.order-upload-card input,
.order-upload-card select,
.order-action-dialog-panel textarea,
.order-action-dialog-panel select,
.order-recipient-fields input,
.order-recipient-fields textarea {
  min-height: var(--control-height);
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background-color: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

select {
  appearance: auto;
  background-image: none;
  padding-right: 12px;
}

input:not([type="checkbox"]):not([type="radio"]):hover,
select:hover:not(:disabled),
textarea:hover {
  border-color: color-mix(in oklab, var(--foreground) 28%, var(--border));
  background-color: var(--background);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-foreground);
  opacity: 1;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus,
.delivery-settings-editor textarea:focus,
.delivery-settings-editor input:focus {
  border-color: var(--ring);
  outline: 0;
  box-shadow: var(--shadow-ring);
}

input:disabled,
select:disabled,
textarea:disabled {
  background-color: var(--muted);
  color: var(--muted-foreground);
  cursor: not-allowed;
  opacity: 1;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--primary);
}

.member-coupon-picker-item:has(input:checked) {
  border-color: var(--primary);
  background: var(--accent);
  box-shadow: none;
}

.member-coupon-picker-item input {
  accent-color: var(--primary);
}

textarea {
  min-height: 88px;
}

.button {
  min-height: var(--control-height);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-sm);
  padding-inline: 13px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button:hover:not(:disabled) {
  background: color-mix(in oklab, var(--primary) 88%, var(--primary-foreground));
  box-shadow: var(--shadow-sm);
  filter: none;
  transform: none;
}

.button.primary,
.order-results-head .button.primary,
.order-detail-actions .button.primary,
.order-action-dialog .button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-sm);
}

.button.secondary,
.order-range-buttons button,
.button.bundle-action {
  border-color: var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
  box-shadow: var(--shadow-xs);
}

.button.secondary:hover:not(:disabled),
.order-range-buttons button:hover:not(:disabled),
.button.bundle-action:hover:not(:disabled) {
  border-color: var(--border);
  background: var(--accent);
  color: var(--accent-foreground);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--foreground);
  box-shadow: none;
}

.button.ghost:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-foreground);
}

.button.danger,
.product-bulk-delete {
  border-color: color-mix(in oklab, var(--destructive) 24%, transparent);
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.button.danger:hover:not(:disabled),
.product-bulk-delete:hover:not(:disabled) {
  border-color: var(--destructive);
  background: color-mix(in oklab, var(--destructive) 88%, var(--foreground));
  color: var(--destructive-foreground);
}

.button:disabled,
.button.bundle-action:disabled {
  border-color: var(--border);
  background: var(--muted);
  color: var(--muted-foreground);
  box-shadow: none;
  opacity: 1;
  transform: none;
}

.button.compact {
  min-height: 30px;
  padding-inline: 9px;
  font-size: 12px;
}

.inline-action-spaced {
  margin-left: 10px;
}

/* Cards, tables, badges, tabs, and dialogs */

.panel,
.metric-card,
.save-action-bar,
.product-action-bar,
.order-detail-popup-shell .order-detail-page > .page-head {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-xs);
}

body[data-mode="product-create"] .product-action-bar {
  top: 68px;
  background: var(--card);
  box-shadow: var(--shadow-xs);
}

.panel-head {
  min-height: 56px;
  border-color: var(--border);
  padding-inline: 18px;
}

.panel-head h3 {
  color: var(--card-foreground);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.panel-head p {
  margin: 3px 0 0;
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 400;
}

.panel-head a,
.text-button,
.member-benefit-table a,
.inquiry-member-link:hover,
.order-detail-history strong,
.order-number-link,
.order-upload-card a,
.coupon-valid-days-preview {
  color: var(--foreground);
}

/* Main content editor: page header with independent shadcn cards. */

.main-content-panel {
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.main-content-panel > .panel-head {
  min-height: 0;
  align-items: baseline;
  border-bottom: 0;
  padding: 0 0 18px;
}

.main-content-panel > .panel-head h3 {
  font-size: 18px;
}

.main-content-panel .main-content-manager {
  gap: 36px;
  padding: 0;
}

.main-content-panel .main-manager-section {
  min-width: 0;
  container-type: inline-size;
}

.main-content-panel .main-manager-section:not(:first-child) {
  border-top: 1px solid var(--border);
  padding-top: 28px;
}

.main-content-panel .main-manager-section > h3,
.main-content-panel .main-manager-section > p {
  padding-inline: 0;
}

.main-content-panel .main-visual-card,
.main-content-panel .main-popup-admin-card,
.main-content-panel .main-visual-fields,
.main-content-panel .main-position-fields,
.main-content-panel .main-position-fields > label,
.main-content-panel .main-cutout-link-setting {
  min-width: 0;
}

.main-content-panel .main-visual-card {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

@container (max-width: 1000px) {
  .main-content-panel .main-visual-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@container (max-width: 640px) {
  .main-content-panel .main-visual-card,
  .main-content-panel .main-popup-admin-card {
    grid-template-columns: minmax(0, 1fr);
  }
}

@container (max-width: 460px) {
  .main-content-panel .main-position-fields,
  .main-content-panel .main-visual-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

.inquiry-reply-field textarea:focus,
.inquiry-admin-settings textarea:focus {
  border-color: var(--ring);
  outline: 0;
  box-shadow: var(--shadow-ring);
}

.table-wrap {
  scrollbar-color: color-mix(in oklab, var(--muted-foreground) 32%, transparent) transparent;
}

table {
  border-collapse: collapse;
  font-size: 13px;
}

th,
.order-unified-table th,
.admin-main-orders thead th {
  border-color: var(--border);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
}

td,
.order-unified-table td,
.admin-main-orders td {
  border-color: var(--border);
  background: var(--card);
  color: var(--card-foreground);
}

th,
td {
  padding: 11px 14px;
}

tr.clickable-row:hover td,
.order-unified-table tr:hover td,
.admin-main-orders tbody tr:hover td {
  background: color-mix(in oklab, var(--muted) 70%, var(--background));
}

.order-unified-table th:nth-child(1) {
  background: var(--muted);
  box-shadow: 1px 0 0 var(--border);
}

.order-unified-table td:nth-child(1) {
  background: var(--card);
  box-shadow: 1px 0 0 var(--border);
}

.order-unified-table tr:hover td:nth-child(1) {
  background: color-mix(in oklab, var(--muted) 70%, var(--background));
}

.badge,
.api-status,
.cj-status,
.bundle-refund-note {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
}

.badge.status-visible,
.badge.status-available,
.order-status-tone--received,
.order-status-tone--confirmed,
.cj-status-success,
.badge[data-status-code*="COMPLETE"],
.badge[data-status-code*="PAID"] {
  border-color: color-mix(in oklab, var(--success-foreground) 18%, transparent);
  background: var(--success);
  color: var(--success-foreground);
}

.badge.status-pending,
.cj-status-pending,
.badge[data-status-code*="WAIT"] {
  border-color: color-mix(in oklab, var(--warning-foreground) 18%, transparent);
  background: var(--warning);
  color: var(--warning-foreground);
}

.order-status-tone--shipping {
  border-color: color-mix(in oklab, var(--info-foreground) 18%, transparent);
  background: var(--info);
  color: var(--info-foreground);
}

.badge.status-withdrawn,
.badge.status-sold-out,
.order-status-tone--cancel-requested,
.cj-status-error,
.badge[data-status-code*="FAILED"],
.badge[data-status-code*="CANCEL"] {
  border-color: color-mix(in oklab, var(--destructive) 18%, transparent);
  background: var(--destructive-soft);
  color: var(--destructive-soft-foreground);
}

.badge[data-status-code*="PARTIAL"] {
  border-color: color-mix(in oklab, var(--warning-foreground) 18%, transparent);
  background: var(--warning);
  color: var(--warning-foreground);
}

.badge.status-hidden,
.badge.status-coming-soon,
.order-status-tone--canceled,
.cj-status-held,
.cj-status-neutral {
  border-color: var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.api-status {
  color: var(--secondary-foreground);
}

.api-status.error {
  border-color: color-mix(in oklab, var(--destructive) 18%, transparent);
  background: var(--destructive-soft);
  color: var(--destructive-soft-foreground);
}

.api-status.is-error,
.form-error,
.danger-text-button,
.text-button.danger,
.product-preview-toolbar-title span.is-error,
.order-cj-stage.is-error,
.order-cj-stage.is-error strong,
.order-bundle-validation.is-error {
  color: var(--destructive);
}

.member-benefit-status.status-scheduled,
.inquiry-status-badge,
.order-return-stage-track li.is-current {
  border-color: color-mix(in oklab, var(--warning-foreground) 18%, transparent);
  background: var(--warning);
  color: var(--warning-foreground);
}

.inquiry-status-badge.is-answered,
.order-return-stage-track li.is-complete,
.order-return-cj-stage.is-success,
.order-bundle-validation.is-success,
.account-security-status {
  border-color: color-mix(in oklab, var(--success-foreground) 18%, transparent);
  background: var(--success);
  color: var(--success-foreground);
}

.member-benefit-status.status-expired {
  border-color: var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.member-benefit-status.status-voided,
.product-stock-status-badge.is-sold-out {
  border-color: color-mix(in oklab, var(--destructive) 18%, transparent);
  background: var(--destructive-soft);
  color: var(--destructive-soft-foreground);
}

.list-filter,
.reward-adjustment-form,
.delivery-settings-actions,
.order-filter-row,
.order-status-filter,
.order-upload-grid,
.order-upload-card,
.product-settings-card-head,
.product-settings-section-head,
.product-option-inline-head,
.product-category-group > h4 {
  border-color: var(--border);
  background: color-mix(in oklab, var(--muted) 55%, var(--background));
}

.order-result-tabs {
  border-color: var(--border);
  border-radius: var(--radius);
  background: var(--muted);
}

.order-cj-package-dialog-panel {
  border-top-color: var(--border);
}

.order-result-tabs button {
  border-color: transparent;
  color: var(--muted-foreground);
}

.order-result-tabs button.is-active,
.order-range-buttons button.is-active {
  border-color: var(--border);
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}

dialog,
.order-action-dialog,
.cj-shipment-dialog,
.product-unsaved-dialog,
.order-detail-dialog,
.member-benefit-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop,
.order-action-dialog::backdrop,
.cj-shipment-dialog::backdrop,
.product-unsaved-dialog::backdrop,
.order-detail-dialog::backdrop,
.member-benefit-dialog::backdrop {
  background: var(--overlay);
}

.order-action-dialog-panel,
.cj-shipment-dialog-panel {
  background: var(--popover);
}

.order-dialog-choices label,
.order-dialog-list,
.order-bundle-help,
.order-bundle-validation,
.order-admin-return-summary,
.order-party-information dt,
.order-qna-answer,
.product-settings-card,
.product-settings-section,
.product-option-inline-section,
.product-operation-card,
.product-check-panel,
.file-drop,
.inquiry-answer-history,
.member-detail-grid > div,
.member-benefit-summary > div,
.review-detail-grid > div {
  border-color: var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: none;
}

.main-popup-admin-preview {
  background: var(--muted);
  box-shadow: var(--shadow-xs);
}

.main-popup-admin-preview::before,
.main-popup-admin-preview::after {
  display: none;
}

/* CKEditor injects branded placeholder gradients at runtime. Keep them neutral. */
body .ck .ck-widget.ck-widget_selected > .ck-widget__type-around > .ck-widget__type-around__button::after,
body .ck .ck-widget > .ck-widget__type-around > .ck-widget__type-around__button:hover::after,
body .ck-media__wrapper[data-oembed-url*="instagram.com"] .ck-media__placeholder,
body .ck-media__wrapper[data-oembed-url*="twitter.com"] .ck.ck-media__placeholder {
  background: var(--muted);
}

/* Dashboard */

.dashboard-page-head {
  margin-bottom: 18px;
}

.admin-main-metrics {
  gap: 12px;
  margin-bottom: 16px;
}

body[data-mode="dashboard"] .admin-main-metric,
.admin-main-metric {
  min-height: 128px;
  align-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-width: 1px;
  background: var(--card);
  color: var(--card-foreground);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.admin-main-metric::after {
  display: none;
}

.admin-main-metric.blue,
.admin-main-metric.green,
.admin-main-metric.amber,
.admin-main-metric.red {
  border-color: var(--border);
}

.admin-main-metric:hover {
  border-color: color-mix(in oklab, var(--foreground) 22%, var(--border));
  box-shadow: var(--shadow-md);
  transform: none;
}

.admin-main-metric-head,
.admin-main-metric-copy {
  display: flex;
  align-items: center;
}

.admin-main-metric-head {
  justify-content: space-between;
}

.admin-main-metric-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
  color: var(--muted-foreground);
}

.admin-main-metric em {
  color: var(--muted-foreground);
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
}

.admin-main-metric-copy {
  justify-content: space-between;
  gap: 12px;
}

.admin-main-metric-copy > span {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 500;
}

body[data-mode="dashboard"] .admin-main-metric strong,
.admin-main-metric strong {
  color: var(--card-foreground);
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1;
}

body[data-mode="dashboard"] .admin-main-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.admin-main-panel {
  border-color: var(--border);
  background: var(--card);
  box-shadow: var(--shadow-xs);
}

.admin-main-panel .panel-head {
  min-height: 62px;
  background: var(--card);
}

.admin-main-orders .table-wrap {
  overflow-x: auto;
}

.admin-main-orders .dashboard-recent-orders-table {
  min-width: 760px;
}

.dashboard-recent-orders-table th,
.dashboard-recent-orders-table td {
  padding-inline: 14px;
}

body[data-mode="dashboard"] .admin-main-tasks .task-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

body[data-mode="dashboard"] .admin-main-tasks .task-list a,
.admin-main-tasks .task-list a {
  min-height: 58px;
  border-right: 1px solid var(--border);
  border-bottom: 0;
  padding: 0 18px;
}

.admin-main-tasks .task-list a:last-child {
  border-right: 0;
}

.admin-main-tasks .task-list a:hover,
.admin-main-panel .task-list a:hover,
.order-status-queue a:hover {
  background: var(--accent);
}

.admin-main-tasks .task-list span {
  color: var(--card-foreground);
  font-size: 12px;
  font-weight: 500;
}

.admin-main-tasks .task-list strong {
  min-width: 30px;
  min-height: 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
}

.admin-main-tasks .task-list a:hover span,
.admin-main-panel .task-list a:hover span,
.order-status-queue a:hover {
  color: var(--accent-foreground);
}

/* Login */

.login-screen {
  background: var(--background);
}

.login-brand {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: none;
}

.login-card {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

/* Feedback */

.toast,
.notification-toast {
  border: 1px solid color-mix(in oklab, var(--primary-foreground) 18%, transparent);
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-lg);
}

.admin-notice {
  border-radius: var(--radius);
}

.admin-notice.is-success {
  background: var(--success);
  color: var(--success-foreground);
}

.admin-notice.is-error {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

@media (min-width: 1025px) {
  .sidebar {
    width: 248px;
  }

  .workspace {
    padding-left: 248px;
  }

  body.sidebar-collapsed .workspace {
    padding-left: 0;
  }
}

@media (max-width: 1024px) {
  .sidebar {
    width: min(86vw, 288px);
    box-shadow: var(--shadow-lg);
  }

  .workspace {
    padding-left: 0;
  }

  .admin-sidebar-toggle {
    display: none;
  }

  .mobile-only {
    display: inline-flex;
  }

  .admin-mobile-menu-button {
    position: static;
  }

  .workspace > .content,
  .content,
  body[data-mode="dashboard"] .content,
  body[data-mode="order-dashboard"] .content,
  body[data-mode="order-management"] .content {
    padding-top: var(--space-section);
  }

  body[data-mode="product-create"] .product-action-bar {
    top: 60px;
  }

  .backdrop,
  body.menu-open .backdrop {
    background: color-mix(in oklab, var(--overlay) 76%, transparent);
  }
}

@media (max-width: 900px) {
  body[data-mode="dashboard"] .admin-main-tasks .task-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-mode="dashboard"] .admin-main-tasks .task-list a:nth-child(2n) {
    border-right: 0;
  }

  body[data-mode="dashboard"] .admin-main-tasks .task-list a:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 760px) {
  :root {
    --page-gutter: 12px;
    --space-section: 16px;
  }

  .admin-topbar {
    min-height: 52px;
  }

  .admin-topbar-context,
  .admin-breadcrumb a,
  .admin-breadcrumb svg {
    display: none;
  }

  .admin-breadcrumb [aria-current="page"] {
    max-width: 60vw;
  }

  .page-head:not(.save-action-bar):not(.product-action-bar) {
    align-items: stretch;
    flex-direction: column;
  }

  .page-head h2,
  .login-card h2 {
    font-size: 21px;
  }

  .order-filter-row .order-keyword-field {
    width: 100%;
    flex: 0 0 auto;
  }

  .order-basic-search-submit {
    width: 100%;
  }

  .panel,
  .metric-card,
  .save-action-bar,
  .product-action-bar,
  .order-detail-popup-shell .order-detail-page > .page-head {
  }

  .admin-main-orders .dashboard-recent-orders-table {
    min-width: 0;
  }

  .dashboard-recent-orders-table tbody {
    gap: 8px;
    padding: 10px;
  }

  .dashboard-recent-orders-table tr {
    border-color: var(--border);
    border-radius: var(--radius);
    background: var(--card);
  }

  .dashboard-recent-orders-table td {
    background: transparent;
  }

  .order-action-dialog,
  .cj-shipment-dialog,
  .product-unsaved-dialog,
  .order-detail-dialog {
    border-radius: var(--radius);
  }
}

@media (max-width: 560px) {
  .metric-grid,
  .admin-main-metrics {
    grid-template-columns: 1fr;
  }

  body[data-mode="dashboard"] .admin-main-tasks .task-list {
    grid-template-columns: 1fr;
  }

  body[data-mode="dashboard"] .admin-main-tasks .task-list a,
  body[data-mode="dashboard"] .admin-main-tasks .task-list a:nth-child(2n),
  body[data-mode="dashboard"] .admin-main-tasks .task-list a:nth-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  body[data-mode="dashboard"] .admin-main-tasks .task-list a:last-child {
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
