:root {
  color-scheme: light;

  /* Neutral surfaces */
  --bg: #ffffff;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-soft: #ffffff;
  --panel-soft-subtle: #ffffff;
  --line: #e7e9ee;
  --line-strong: #cfd3dc;
  --text: #16181d;
  --muted: #666b76;
  --muted-soft: rgba(102, 107, 118, 0.10);

  /* Shared accent. Keep these current values until a new accent is approved. */
  --accent: #183153;
  --accent-strong: #102641;
  --accent-soft: rgba(24, 49, 83, 0.08);
  --accent-line: rgba(24, 49, 83, 0.16);
  --accent-rule: rgba(24, 49, 83, 0.20);
  --accent-border: rgba(24, 49, 83, 0.28);
  --accent-outline: rgba(24, 49, 83, 0.18);
  --control-accent: #2563eb;
  --control-accent-soft: rgba(37, 99, 235, 0.22);
  --control-accent-outline: rgba(37, 99, 235, 0.38);

  /* Semantic states. These are independent of the shared accent. */
  --ok: #2d6a4f;
  --ok-soft: rgba(45, 106, 79, 0.10);
  --warn: #9a6700;
  --warn-soft: rgba(154, 103, 0, 0.12);
  --warn-soft-quiet: rgba(154, 103, 0, 0.10);
  --warn-border: rgba(154, 103, 0, 0.22);
  --warn-surface: #fff7e6;
  --warn-text: #382508;
  --danger: #a63d40;
  --danger-soft: rgba(166, 61, 64, 0.10);
  --danger-soft-strong: rgba(166, 61, 64, 0.12);
  --danger-border: rgba(166, 61, 64, 0.18);
  --danger-surface: #fff4f4;

  /* Decoration and elevation */
  --decorative-neutral: rgba(207, 211, 220, 0.22);
  --shadow: 0 12px 32px rgba(22, 24, 29, 0.06);
  --shadow-compact: 0 12px 32px rgba(22, 24, 29, 0.06);
  --shadow-modal: 0 24px 72px rgba(22, 24, 29, 0.18);
  --radius-control: 10px;
  --radius-card: 14px;
  --radius-panel: 18px;
  --focus-ring: 0 0 0 3px rgba(24, 49, 83, 0.18);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-sans-strong: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", "Yu Gothic Medium", sans-serif;
  --font-serif: "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/*
 * Shared component layer
 *
 * The page-local styles predate the design system. Selectors here include the
 * body element deliberately so this shared layer can refine their presentation
 * without changing page structure or JavaScript behavior.
 */
html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

html body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.8;
  letter-spacing: 0.01em;
  overflow-wrap: break-word;
  padding: 48px 32px 80px;
}

body :is(h1, h2, h3) {
  color: var(--text);
  font-family: var(--font-sans-strong);
  line-height: 1.3;
  letter-spacing: -0.02em;
}

body h1 {
  line-height: 1.18;
}

body :is(.wrap, .grid, .content, .section) {
  min-width: 0;
}

body .wrap {
  gap: 24px;
}

body .panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 28px;
}

body :is(.card, .metric, .summary-item, .alert-item, .check-card, .list-box, .notice, .result-box) {
  border-color: var(--line);
  border-radius: var(--radius-card);
  background: var(--panel-soft);
}

body > main.card {
  border-radius: var(--radius-panel);
  background: var(--panel);
  box-shadow: var(--shadow);
}

body :is(button, a.button, input, select, textarea, input[type="file"], .readonly-chip, .hour-pill) {
  border-radius: var(--radius-control);
}

body :is(input, select, textarea, input[type="file"]) {
  border-color: var(--line-strong);
  background: #fff;
}

body :is(input, select, textarea, button, a.button):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

body :is(button.secondary, a.button.secondary, button.ghost) {
  border-color: var(--line-strong);
  background: #fff;
}

body :is(button.secondary, a.button.secondary, button.ghost):hover {
  border-color: var(--accent);
  color: var(--accent);
}

body :is(.table-wrap, pre, .scan-summary) {
  border-color: var(--line);
  border-radius: var(--radius-card);
  background: #fff;
}

body :is(.badge, .chip, .eyebrow, .nav-badge) {
  border-radius: 999px;
}

body .sidebar {
  border-color: var(--line);
  border-radius: var(--radius-panel);
  background: #fff;
  box-shadow: var(--shadow);
}

body .nav-button {
  border-radius: var(--radius-control);
}

body :is(.modal, .edit-modal) {
  border-color: var(--line);
  border-radius: var(--radius-panel);
  background: #fff;
  box-shadow: var(--shadow-modal);
}

body .edit-modal-body,
body .edit-modal-frame {
  background: var(--bg);
}

body :is(.modal-shell, .modal-backdrop, .edit-modal-shell) {
  background: rgba(22, 24, 29, 0.28);
  backdrop-filter: blur(4px);
}

html::-webkit-scrollbar {
  width: 14px;
}

html::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(22, 24, 29, 0.28);
  background-clip: padding-box;
}

html::-webkit-scrollbar-thumb:hover {
  background: rgba(22, 24, 29, 0.42);
  background-clip: padding-box;
}

@media (max-width: 760px) {
  html {
    scrollbar-gutter: auto;
  }

  html body {
    padding: 24px 14px 48px;
    font-size: 15px;
  }

  body .wrap {
    gap: 16px;
  }

  body .panel {
    border-radius: 16px;
    padding: 20px;
  }

  body :is(.card, .metric, .summary-item, .alert-item, .check-card, .list-box, .notice, .result-box) {
    border-radius: 12px;
    padding: 16px;
  }

  body > main.card {
    border-radius: 16px;
    padding: 32px 22px;
  }

  body .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-items: start;
  }

  body .toolbar > .actions {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scrollbar-width: none;
    overscroll-behavior-inline: contain;
  }

  body .toolbar > .actions::-webkit-scrollbar {
    display: none;
  }

  body .toolbar > .actions > :is(button, .button, .inline) {
    flex: 0 0 auto;
  }

  body .filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  body :is(.filter-search, .filter-select) {
    width: 100%;
  }

  body :is(.two-col, .three-col, .threshold-inline) {
    grid-template-columns: minmax(0, 1fr);
  }

  body .table-wrap {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
  }

  body .modal-shell {
    align-items: flex-end;
    padding: 48px 0 0;
  }

  body .modal-shell .modal {
    width: 100%;
    max-height: 82dvh;
    padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 20px 20px 0 0;
    gap: 16px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  body .modal-shell .modal::before,
  body .modal-backdrop .modal::before {
    content: "";
    position: sticky;
    top: 0;
    z-index: 4;
    width: 40px;
    height: 4px;
    margin: 0 auto 2px;
    border-radius: 999px;
    background: var(--line-strong);
  }

  body .modal .sticky-actions,
  body #createProductModalShell .modal > .toolbar {
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 0 -16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.97);
  }

  body .modal-backdrop {
    place-items: end center;
    padding: 64px 0 0;
  }

  body .modal-backdrop .modal {
    width: 100%;
    max-height: 72dvh;
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 20px 20px 0 0;
    gap: 14px;
    overscroll-behavior: contain;
  }

  body .modal-title {
    font-size: 22px;
  }

  body .modal-actions,
  body .modal-actions.two {
    position: sticky;
    bottom: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-top: 10px;
    padding-bottom: env(safe-area-inset-bottom);
    background: #fff;
  }

  body .modal-actions.one {
    grid-template-columns: minmax(0, 1fr);
  }

  body .modal-actions button {
    min-height: 48px;
  }

  body .modal-actions button:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  body .edit-modal-shell {
    align-items: flex-end;
    padding: 48px 0 0;
  }

  body .edit-modal {
    width: 100%;
    height: 92dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 20px 20px 0 0;
  }

  body .edit-modal-head {
    flex-wrap: nowrap;
    padding: 12px 14px;
  }

  body .sidebar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px;
    border-radius: 14px;
    scrollbar-width: none;
    scroll-snap-type: inline proximity;
    overscroll-behavior-inline: contain;
  }

  body .sidebar::-webkit-scrollbar {
    display: none;
  }

  body .sidebar-block {
    display: flex;
    gap: 8px;
    min-width: max-content;
    overflow: visible;
  }

  body .sidebar-title {
    display: none;
  }

  body .nav-button {
    width: auto;
    min-width: 160px;
    min-height: 48px;
    flex: 0 0 auto;
    scroll-snap-align: start;
  }
}

@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;
  }
}
