:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-soft: #eef2ff;
  --teal: #0f766e;
  --amber: #b45309;
  --red: #dc2626;
  --blue: #2563eb;
  --shadow: 0 18px 48px -32px rgba(15, 23, 42, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  letter-spacing: 0;
}

.is-hidden {
  display: none !important;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #f7f8fb;
}

.auth-shell {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) 420px;
  gap: 28px;
  align-items: center;
}

.auth-copy {
  display: grid;
  gap: 20px;
  padding: 10px;
}

.auth-brand {
  min-height: 48px;
}

.auth-copy h1 {
  max-width: 680px;
  font-size: 36px;
  line-height: 1.22;
}

.auth-copy p {
  max-width: 640px;
  color: var(--muted);
  line-height: 1.9;
}

.auth-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-points span,
.chip,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.auth-points span,
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
}

.chip.warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.chip.success {
  border-color: #99f6e4;
  background: #f0fdfa;
  color: #115e59;
}

.program-connection {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.program-media-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.program-media-links span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.auth-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-card-head {
  display: grid;
  gap: 6px;
}

.auth-card-head p {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.auth-card-head h2 {
  font-size: 22px;
}

.auth-card-head span,
.auth-panel-head span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.auth-entry-actions {
  display: grid;
  gap: 10px;
}

.auth-choice-button {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.auth-choice-button:hover {
  border-color: #c7d2fe;
  background: #fbfcff;
}

.auth-choice-button.primary {
  border-color: #c7d2fe;
  background: var(--primary-soft);
}

.auth-choice-button strong {
  font-size: 15px;
}

.auth-choice-button span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.auth-panel {
  display: grid;
  gap: 14px;
}

.auth-panel-head {
  display: grid;
  gap: 6px;
}

.auth-panel-head p {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.text-button {
  justify-self: start;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.verify-form {
  padding-top: 4px;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.auth-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
  height: 100vh;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: #fff;
  box-shadow: 8px 0 28px -30px rgba(15, 23, 42, 0.55);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 44px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.workspace-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface-soft);
}

.workspace-card span {
  color: var(--muted);
  font-size: 12px;
}

.workspace-card strong {
  font-size: 14px;
}

.nav {
  display: grid;
  align-content: start;
  gap: 6px;
}

.nav a {
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #475569;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.nav a:hover {
  border-color: var(--line);
  background: #f8fafc;
  color: var(--ink);
}

.nav a.active {
  border-color: #c7d2fe;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.sidebar-logout {
  width: 100%;
}

.main {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 28px 32px 40px;
}

.toolbar,
.section-head,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head p,
.toolbar p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.toolbar-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.page-actions,
.item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.token-field {
  min-width: 220px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.24;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.metrics,
.grid.two {
  display: grid;
  gap: 14px;
}

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

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

.metric,
.panel,
.surface {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.metric {
  min-height: 98px;
  padding: 18px;
  box-shadow: 0 10px 32px -30px rgba(15, 23, 42, 0.55);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
}

.surface {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.route-page {
  display: none;
}

.route-page.active {
  display: grid;
  gap: 18px;
}

.surface.inset {
  background: var(--surface-soft);
}

.panel {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  padding: 16px;
}

.panel-title-row,
.compact-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-title-row .button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
}

.help-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.label-with-help,
h2 .help-tip,
h3 .help-tip,
th .help-tip,
strong .help-tip {
  vertical-align: middle;
}

.label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: inherit;
}

.code-with-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.help-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--primary-dark);
  cursor: help;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.help-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  z-index: 80;
  width: min(300px, calc(100vw - 48px));
  transform: translateX(-50%) translateY(4px);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  background: #0f172a;
  box-shadow: 0 14px 32px -20px rgba(15, 23, 42, 0.7);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.65;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  white-space: normal;
  word-break: normal;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.help-tip::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 3px);
  z-index: 81;
  width: 10px;
  height: 10px;
  transform: translateX(-50%) rotate(45deg);
  background: #0f172a;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.help-tip:hover::after,
.help-tip:focus-visible::after,
.help-tip.active::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.help-tip:hover::before,
.help-tip:focus-visible::before,
.help-tip.active::before {
  opacity: 1;
}

.help-tip.align-left::after {
  left: 0;
  transform: translateX(0) translateY(4px);
}

.help-tip.align-left:hover::after,
.help-tip.align-left:focus-visible::after,
.help-tip.align-left.active::after {
  transform: translateX(0) translateY(0);
}

.help-tip.align-left::before {
  left: 8px;
  transform: rotate(45deg);
}

.help-tip.align-right::after {
  right: 0;
  left: auto;
  transform: translateX(0) translateY(4px);
}

.help-tip.align-right:hover::after,
.help-tip.align-right:focus-visible::after,
.help-tip.align-right.active::after {
  transform: translateX(0) translateY(0);
}

.help-tip.align-right::before {
  right: 8px;
  left: auto;
  transform: rotate(45deg);
}

.help-tip.align-below::after {
  top: calc(100% + 9px);
  bottom: auto;
  transform: translateX(-50%) translateY(-4px);
}

.help-tip.align-below:hover::after,
.help-tip.align-below:focus-visible::after,
.help-tip.align-below.active::after {
  transform: translateX(-50%) translateY(0);
}

.help-tip.align-below::before {
  top: calc(100% + 3px);
  bottom: auto;
}

.help-tip.align-below.align-left::after,
.help-tip.align-below.align-right::after {
  transform: translateX(0) translateY(-4px);
}

.help-tip.align-below.align-left:hover::after,
.help-tip.align-below.align-left:focus-visible::after,
.help-tip.align-below.align-left.active::after,
.help-tip.align-below.align-right:hover::after,
.help-tip.align-below.align-right:focus-visible::after,
.help-tip.align-below.align-right.active::after {
  transform: translateX(0) translateY(0);
}

.flow-card .help-tip {
  display: inline-grid;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin-left: 4px;
  background: #eef2ff;
  color: var(--primary-dark);
  font-size: 11px;
}

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

.flow-card {
  display: grid;
  gap: 8px;
  min-height: 148px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: #fff;
  color: inherit;
  text-decoration: none;
}

.flow-card:hover {
  border-color: #c7d2fe;
  background: #fbfcff;
}

.flow-card span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.flow-card small {
  color: var(--muted);
  line-height: 1.7;
}

.project-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.mode-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.mode-option:has(input:checked) {
  border-color: #c7d2fe;
  background: var(--primary-soft);
}

.mode-option input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.mode-option strong,
.mode-option small {
  display: block;
}

.mode-option small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.6;
}

.mode-panel {
  display: grid;
  gap: 14px;
}

.copy-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.copy-field code {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.notification-panel {
  grid-column: 1 / -1;
}

.compact-table table {
  min-width: 420px;
}

.compact-list {
  gap: 8px;
}

.step-list {
  margin: 0;
  padding-left: 22px;
  color: #334155;
  line-height: 1.9;
  font-size: 13px;
}

.compact-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox input {
  width: 18px;
  min-height: 18px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(79, 70, 229, 0.18);
  border-color: var(--primary);
}

textarea {
  min-height: 148px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

.button.wide {
  width: 100%;
}

.button.secondary {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.button.google {
  border-color: var(--line-strong);
  background: #fff;
  color: #1f2937;
}

.button:hover {
  background: var(--primary-dark);
}

.button.secondary:hover,
.button.google:hover {
  background: #f8fafc;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  background: #f8fafc;
}

.program-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status {
  color: #fff;
  background: var(--muted);
}

.status.pending,
.status.processing,
.status.past_due {
  background: var(--amber);
}

.status.accepted,
.status.approved,
.status.active,
.status.trialing,
.status.completed,
.status.free,
.status.occurred {
  background: var(--teal);
}

.status.skipped,
.status.not_started,
.status.pro {
  background: var(--blue);
}

.status.failed,
.status.rejected,
.status.canceled,
.status.cancelled {
  background: var(--red);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  display: grid;
  gap: 6px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.item-actions .button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
}

.item code,
td code {
  word-break: break-all;
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.setting-item {
  min-height: 64px;
}

.setting-item strong {
  word-break: break-word;
}

.result {
  display: none;
  max-height: 280px;
  overflow: auto;
  margin: 0;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px;
  background: #0f172a;
  color: #dbeafe;
  font-size: 12px;
}

.auth-result {
  max-height: 180px;
}

.snippet {
  min-height: 96px;
  max-height: 340px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.code-panel .snippet {
  max-height: 260px;
}

.grid.two.site-code-grid {
  align-items: start;
}

.diagnostic-tool {
  display: grid;
  grid-template-columns: minmax(220px, 360px) max-content;
  gap: 10px;
  align-items: end;
}

.diagnostic-tool .button {
  justify-self: start;
}

.notice-list {
  display: grid;
  gap: 8px;
  color: #475569;
  font-size: 13px;
  line-height: 1.7;
}

.notice-list span {
  position: relative;
  padding-left: 16px;
}

.notice-list span::before {
  content: "";
  position: absolute;
  top: 0.72em;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--primary);
}

.result.active {
  display: block;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  width: min(520px, 100%);
  max-height: min(780px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-panel.wide {
  width: min(820px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.modal-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.modal-actions {
  justify-content: flex-end;
}

.inline-test-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

@media (max-width: 1024px) {
  .auth-shell,
  .shell {
    grid-template-columns: 1fr;
  }

  .auth-copy h1 {
    font-size: 30px;
  }

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  }

  .metrics,
  .grid.two,
  .mode-switch,
  .setup-flow,
  .diagnostic-tool,
  .inline-test-form {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-actions {
    justify-content: flex-start;
  }

  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .auth-view,
  .main {
    padding: 16px;
  }

  .auth-card {
    padding: 18px;
  }

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

  h1 {
    font-size: 23px;
  }

  .auth-copy h1 {
    font-size: 25px;
  }

  .actions {
    align-items: stretch;
    flex-direction: column;
  }
}