/* ==========================================================================
   kanripress-insights — Frontend styles
   Stripe-inspired Environmental Green Theme (kanripress-cdn-v2 design.md)
   Loaded after Lism CSS so layout primitives (l--stack/l--grid/l--flex)
   stay available and these rules override Lism's typography defaults.
   ========================================================================== */

/* --- 1. Design Tokens --------------------------------------------------- */
:root {
  /* Green palette */
  --kp-green-50:  #f0fdf4;
  --kp-green-100: #dcfce7;
  --kp-green-200: #bbf7d0;
  --kp-green-300: #86efac;
  --kp-green-400: #4ade80;
  --kp-green-500: #22c55e;
  --kp-green-600: #16a34a;
  --kp-green-700: #15803d;
  --kp-green-800: #166534;
  --kp-green-900: #14532d;
  --kp-green-950: #052e16;

  /* Semantic: primary */
  --color-primary:       var(--kp-green-700);
  --color-primary-hover: var(--kp-green-800);
  --color-primary-light: var(--kp-green-100);
  --color-primary-bg:    var(--kp-green-50);

  /* Semantic: text — WCAG AA on white */
  --color-heading: var(--kp-green-950);
  --color-label:   var(--kp-green-900);
  --color-body:    #475569;
  --color-muted:   #64748b;

  /* Semantic: surface / border */
  --color-bg:           #ffffff;
  --color-surface:      #f8faf9;
  --color-border:       #e2e8f0;
  --color-border-green: #d1e7d8;
  --color-border-focus: var(--kp-green-400);

  /* Status */
  --color-success:        #22c55e;
  --color-success-text:   #15803d;
  --color-success-bg:     rgba(34,197,94,0.12);
  --color-success-border: rgba(34,197,94,0.3);

  --color-warning:        #f59e0b;
  --color-warning-text:   #92400e;
  --color-warning-bg:     rgba(245,158,11,0.12);
  --color-warning-border: rgba(245,158,11,0.3);

  --color-danger:        #ef4444;
  --color-danger-hover:  #dc2626;
  --color-danger-text:   #b91c1c;
  --color-danger-bg:     rgba(239,68,68,0.08);

  /* Shadows (green-tinted) */
  --shadow-xs: 0 1px 2px rgba(5,46,22,0.05);
  --shadow-sm: 0 1px 3px rgba(5,46,22,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(5,46,22,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 40px -20px rgba(5,46,22,0.18), 0 12px 24px -12px rgba(0,0,0,0.05);
  --shadow-xl: 0 30px 45px -30px rgba(5,46,22,0.25), 0 18px 36px -18px rgba(0,0,0,0.08);

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Layout */
  --sidebar-w: 248px;
  --topbar-h:  56px;

  /* Motion */
  --ease-fast: 150ms ease;
  --ease-base: 200ms ease;

  /* Typography */
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", sans-serif;
  --font-mono: "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

/* --- 2. Base over Lism's defaults --------------------------------------- */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-body);
  background: var(--color-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); text-decoration: underline; }

/* --- 3. Accessibility --------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 500;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
}
.skip-link:focus {
  left: 50%;
  transform: translateX(-50%);
}

:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 2px;
}
.form-input:focus-visible,
.form-textarea:focus-visible,
.form-select:focus-visible {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(21,128,61,0.25);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* --- 4. App Layout ------------------------------------------------------ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- 5. Sidebar --------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform var(--ease-base);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  min-height: var(--topbar-h);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-heading);
  font-weight: 500;
  font-size: 0.9375rem;
  letter-spacing: -0.02em;
}
.logo svg { flex-shrink: 0; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.nav-section-label {
  padding: 18px 20px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-body);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  margin: 1px 8px;
  border-radius: var(--radius-md);
  color: var(--color-body);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 400;
  min-height: 40px;
  transition: background var(--ease-fast), color var(--ease-fast);
}
.sidebar-nav a:hover {
  background: var(--color-primary-bg);
  color: var(--color-heading);
  text-decoration: none;
}
.sidebar-nav a.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 500;
}
.sidebar-nav a .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
}
.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  font-size: 0.8125rem;
  color: var(--color-body);
}
.sidebar-footer a { color: var(--color-muted); text-decoration: none; }
.sidebar-footer a:hover { color: var(--color-primary); }

/* Mobile toggle */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--color-heading);
  border-radius: var(--radius-sm);
}
.sidebar-toggle:hover { background: var(--color-primary-bg); }

.hamburger,
.hamburger::before,
.hamburger::after {
  display: block;
  width: 18px; height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.hamburger { position: relative; }
.hamburger::before, .hamburger::after { content: ''; position: absolute; left: 0; }
.hamburger::before { top: -6px; }
.hamburger::after  { top:  6px; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(5,46,22,0.3);
  z-index: 35;
}

/* --- 6. Main Wrapper / Topbar ------------------------------------------ */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(248,250,249,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  padding: 0 32px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
}
.topbar h1 {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--color-heading);
  letter-spacing: -0.01em;
}

.main-content {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 48px;
}

/* --- 7. Typography ------------------------------------------------------ */
h1, h2, h3, h4 {
  color: var(--color-heading);
  letter-spacing: -0.01em;
}
h2, .heading-section {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
h3, .heading-sub {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
}

.text-muted { color: var(--color-muted); }
.text-body  { color: var(--color-body); }
.text-sm    { font-size: 0.875rem; }
.text-xs    { font-size: 0.8125rem; }

.lead {
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--color-body);
  max-width: 60ch;
}
.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary);
}
.page-hero h1 {
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin-top: 8px;
}

/* --- 8. Cards ---------------------------------------------------------- */
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card-header { padding: 20px 24px 0; }
.card-title {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--color-heading);
  margin: 0;
}
.card-description {
  display: block;
  font-size: 0.9375rem;
  color: var(--color-body);
  margin-top: 4px;
  line-height: 1.55;
}
.card-body { padding: 16px 24px 24px; }
.card-body:first-child { padding-top: 24px; }
.card-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-size: 0.875rem;
  color: var(--color-body);
}

/* --- 9. Metric Cards (Hero numbers) ------------------------------------ */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.metric-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-xs);
}
.metric-label {
  font-size: 0.9375rem;
  color: var(--color-body);
}
.metric-value {
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--color-heading);
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-feature-settings: "tnum";
  margin-top: 6px;
}
.metric-detail {
  font-size: 0.875rem;
  color: var(--color-body);
  margin-top: 4px;
}

/* --- 10. Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--ease-fast), box-shadow var(--ease-fast);
}
.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-sm);
  color: #fff;
  text-decoration: none;
}
.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-border-green);
}
.btn-ghost:hover {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
  text-decoration: none;
}
.btn-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.875rem;
}

/* --- 11. Forms ---------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-label);
  margin-bottom: 6px;
}
.form-hint {
  display: block;
  font-size: 0.875rem;
  color: var(--color-body);
  margin-top: 6px;
  line-height: 1.55;
}
.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.4;
  color: var(--color-heading);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
}
.form-input,
.form-select { height: 40px; }
.form-textarea { padding: 8px 12px; line-height: 1.5; min-height: 80px; resize: vertical; }
.form-input::placeholder,
.form-textarea::placeholder { color: var(--color-muted); }
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(21,128,61,0.12);
}
.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.form-row .form-input { flex: 1; }

/* --- 12. Tables --------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-body);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  white-space: nowrap;
}
.data-table td {
  padding: 18px 14px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-heading);
  font-feature-settings: "tnum";
  vertical-align: top;
  line-height: 1.55;
}
.data-table.data-table-middle td { vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--color-primary-bg); }
.data-table tfoot td {
  border-top: 1px solid var(--color-border);
  border-bottom: none;
}
/* Sub-headers (`<br><span>`) inside <th>: allow wrap even though th defaults to nowrap. */
.data-table th br + span {
  white-space: normal;
  display: block;
  margin-top: 2px;
}
/* Aligns first-row content (icons / buttons / text) at a shared baseline,
   while allowing cells to expand below — see design.md §5.4. */
.data-table .row-cell {
  display: flex;
  align-items: center;
  min-height: 36px;
}
.data-table .row-cell-center { justify-content: center; }

/* --- 13. Badges --------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border: 1px solid var(--color-success-border);
}
.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border: 1px solid var(--color-warning-border);
}
.badge-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  border: 1px solid rgba(239,68,68,0.2);
}
.badge-neutral {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* --- 14. Code ----------------------------------------------------------- */
pre {
  background: var(--kp-green-950);
  color: #e2e8f0;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  box-shadow: var(--shadow-md);
  margin: 0;
}
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}
:not(pre) > code {
  background: var(--color-primary-bg);
  color: var(--color-primary-hover);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.85em;
}

/* --- 15. Quadrant Matrix (Priority × Effort) --------------------------- */
.quadrant-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.quadrant-cell {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  background: var(--color-bg);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 140px;
}
.quadrant-cell.is-quick-wins {
  background: #f0fdf4;
  border-color: #86efac;
}
.quadrant-cell-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.quadrant-cell-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-heading);
}
.quadrant-cell-meta {
  font-size: 0.8125rem;
  color: var(--color-body);
}
.quadrant-cell-empty {
  font-size: 0.875rem;
  color: var(--color-muted);
}
.task-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-card h3 {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-heading);
}
.task-card .task-desc {
  font-size: 0.875rem;
  color: var(--color-body);
  line-height: 1.55;
}
.task-card .task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* --- 15.5. Feature section (homepage) ---------------------------------- */
.features-section {
  margin-top: 80px;
  padding: 0 16px;
}
.features-header {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 40px;
}
.features-header h2 {
  font-size: 1.875rem;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin-top: 8px;
}
.features-header .lead {
  margin: 12px auto 0;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 36px 28px;
  max-width: 1100px;
  margin: 0 auto;
}
.feature-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--color-primary-bg);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.feature-icon svg {
  width: 22px;
  height: 22px;
}
.feature-item h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--color-heading);
  letter-spacing: -0.01em;
  line-height: 1.4;
  margin: 0;
}
.feature-item p {
  font-size: 0.9375rem;
  color: var(--color-body);
  line-height: 1.65;
  margin: 0;
}
.features-footer {
  text-align: center;
  margin: 40px auto 0;
  max-width: 720px;
  font-size: 0.9375rem;
  color: var(--color-body);
}

@media (max-width: 768px) {
  .features-section { margin-top: 56px; }
  .features-header h2 { font-size: 1.5rem; }
  .features-grid { gap: 28px 20px; }
}

/* --- 15.7. Report / Dashboard polish ----------------------------------- */

/* Page header — used on /jobs/:id, /dashboard etc to introduce the screen
 * with eyebrow + h1 + supporting meta. */
.page-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--color-heading);
  letter-spacing: -0.015em;
  line-height: 1.3;
  margin: 0;
  word-break: break-word;
}
.page-header .meta {
  font-size: 0.875rem;
  color: var(--color-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
}
.page-header .meta code {
  font-size: 0.8125rem;
}

/* Verdict block — the LLM's plain-text summary, displayed prominently. */
.verdict-block {
  background: var(--color-primary-bg);
  border-left: 3px solid var(--color-primary);
  border-radius: 4px;
  padding: 16px 20px;
  font-size: 1rem;
  color: var(--color-heading);
  line-height: 1.65;
  margin-bottom: 24px;
}

/* Score dot — 8px coloured circle paired with vital labels. */
.score-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
}
.score-dot.good { background: var(--color-success); }
.score-dot.needs { background: var(--color-warning); }
.score-dot.poor { background: var(--color-danger); }

/* Trend arrow appended to metric values. */
.metric-trend {
  font-weight: 500;
  margin-right: 4px;
}
.metric-trend.up { color: var(--color-success-text); }
.metric-trend.down { color: var(--color-success-text); } /* down is good for latency */

/* Progress bar — used for monthly quota visualisation on /dashboard. */
.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--color-border);
  overflow: hidden;
  margin: 12px 0 6px;
}
.progress > .progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
  transition: width var(--ease-base);
}
.progress > .progress-fill.warn { background: var(--color-warning); }
.progress > .progress-fill.danger { background: var(--color-danger); }

/* Section-level header used inside dashboards (h2 + small subtitle pair). */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.section-head h2 {
  margin: 0;
}

/* Toolbar for action buttons in card headers. */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- 15.8. Plan cards (/billing プラン変更カード) ---------------------- */

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
}
@media (max-width: 960px) {
  .plan-grid { grid-template-columns: 1fr; }
}

.plan-card {
  position: relative;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform var(--ease-base), box-shadow var(--ease-base),
              border-color var(--ease-base);
}
.plan-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.plan-card.is-current {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.plan-ribbon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  z-index: 1;
}
.plan-ribbon-current {
  background: var(--color-bg);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.plan-card-inner {
  padding: 28px 24px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.plan-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.plan-tier-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.plan-card-title-block { flex: 1; min-width: 0; }
.plan-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-heading);
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.plan-card-tagline {
  font-size: 0.8125rem;
  color: var(--color-body);
  margin: 4px 0 0;
  line-height: 1.4;
}

.plan-price-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.plan-price {
  font-size: 2rem;
  font-weight: 500;
  color: var(--color-heading);
  letter-spacing: -0.025em;
  line-height: 1.1;
  font-feature-settings: "tnum";
}
.plan-price-period {
  font-size: 0.9375rem;
  color: var(--color-body);
}
.plan-price-pending {
  font-size: 0.9375rem;
  color: var(--color-muted);
  font-style: italic;
}

.plan-quota {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.plan-quota-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.plan-quota-label {
  font-size: 0.8125rem;
  color: var(--color-body);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.plan-quota-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-heading);
  font-feature-settings: "tnum";
  letter-spacing: -0.01em;
}
.plan-quota-unit {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-body);
}
.plan-quota-overage {
  font-size: 0.8125rem;
  color: var(--color-muted);
}

.plan-features-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.plan-inherit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--color-primary-bg);
  border: 1px solid var(--color-border-green);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--color-primary-hover);
  line-height: 1.4;
}
.plan-inherit strong { color: var(--color-heading); font-weight: 600; }
.plan-inherit-icon { flex-shrink: 0; }
.plan-scale-note {
  font-size: 0.875rem;
  color: var(--color-body);
  line-height: 1.55;
  margin: 0;
  padding: 0 4px;
}
.plan-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.plan-feature {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9375rem;
  color: var(--color-heading);
  line-height: 1.5;
}
.plan-feature-icon { flex-shrink: 0; margin-top: 1px; }

.plan-cta {
  margin-top: auto;
  padding-top: 8px;
}

/* --- 16. Bare layout (share view, errors) ------------------------------ */
.bare-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
  background: var(--color-surface);
}
.bare-layout main {
  width: 100%;
  max-width: 720px;
}
.bare-header {
  width: 100%;
  max-width: 720px;
  margin-bottom: 24px;
}
.bare-header .logo { font-size: 1rem; }

/* --- 17. Responsive ---------------------------------------------------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-backdrop { display: block; }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .main-wrapper { margin-left: 0; }
  .topbar { padding: 0 16px; gap: 12px; }
  .topbar h1 { font-size: 0.9375rem; }
  .main-content { padding: 20px 16px 40px; }
  .quadrant-grid { grid-template-columns: 1fr; }
}

/* --- 18. Reduced motion / Print ---------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
@media print {
  .sidebar, .topbar, .sidebar-backdrop, .skip-link, .btn { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
