:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --sidebar-bg: #0f172a;
  --sidebar-bg-2: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #94a3b8;
  --sidebar-width: 272px;
  --header-height: 64px;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .06);
  --transition: .18s ease;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: Sora, "Noto Sans JP", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────── */

.layout {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #111827 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 200;
  border-right: 1px solid rgba(255, 255, 255, .06);
  overflow: hidden;
}

.sidebar-header {
  flex-shrink: 0;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
  flex-shrink: 0;
}

.brand-mark svg {
  width: 20px;
  height: 20px;
  color: #fff;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-weight: 700;
  font-size: .92rem;
  letter-spacing: -.02em;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: .72rem;
  color: var(--sidebar-muted);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .75rem .75rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .15) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .15);
  border-radius: 4px;
}

.nav-group {
  margin-bottom: 1.1rem;
}

.nav-group:last-child { margin-bottom: 0; }

.nav-group--muted {
  margin-top: .25rem;
  padding-top: .85rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.nav-group--muted .nav-link {
  color: rgba(255, 255, 255, .55);
  font-size: .86rem;
}

.nav-group-label {
  display: block;
  padding: 0 .75rem;
  margin-bottom: .4rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.nav-master {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem .75rem;
  margin-bottom: .35rem;
  border-radius: 10px;
  text-decoration: none;
  color: #fff;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  transition: background var(--transition), border-color var(--transition);
}

.nav-master:hover {
  background: rgba(255, 255, 255, .07);
  border-color: rgba(255, 255, 255, .14);
}

.nav-master.is-active {
  background: rgba(37, 99, 235, .2);
  border-color: rgba(59, 130, 246, .35);
}

.nav-master-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(59, 130, 246, .2);
  color: #93c5fd;
  flex-shrink: 0;
}

.nav-master-icon svg {
  width: 16px;
  height: 16px;
}

.nav-master-text {
  display: flex;
  flex-direction: column;
  gap: .05rem;
  min-width: 0;
}

.nav-master-title {
  font-size: .92rem;
  font-weight: 650;
  line-height: 1.2;
}

.nav-master-sub {
  font-size: .7rem;
  color: var(--sidebar-muted);
  font-weight: 500;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .75rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border: 1px solid transparent;
}

.nav-link:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
}

.nav-link.active {
  background: rgba(37, 99, 235, .18);
  color: #fff;
  border-color: rgba(59, 130, 246, .25);
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .85;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.nav-link.active .nav-icon { opacity: 1; }

.nav-children {
  margin-top: .1rem;
  margin-left: .55rem;
  padding-left: .75rem;
  border-left: 1px solid rgba(255, 255, 255, .1);
}

.nav-child-label {
  display: block;
  margin: .55rem 0 .15rem;
  padding: 0 .75rem;
  font-size: .65rem;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .38);
}

.nav-child-label:first-child {
  margin-top: .2rem;
}

.nav-child {
  padding: .42rem .75rem;
  font-size: .86rem;
  color: var(--sidebar-muted);
}

.nav-child.active {
  color: #fff;
  background: rgba(255, 255, 255, .05);
  box-shadow: inset 2px 0 0 #60a5fa;
}

.nav-group.is-open .nav-children {
  border-left-color: rgba(96, 165, 250, .35);
}

.sidebar-footer {
  flex-shrink: 0;
  padding: .75rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
  background: rgba(0, 0, 0, .15);
}

.logout-form { margin: 0; }

.main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--header-height);
  background: rgba(241, 245, 249, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.page-header-inner {
  width: 100%;
  padding: 0 2.5rem;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
}

.page-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

/* Legacy master-tabs kept as aliases → panel-tabs */
.master-tabs {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  gap: .25rem;
  padding: .3rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.master-tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  gap: .45rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .875rem;
  font-weight: 650;
  padding: .55rem .95rem;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}

.master-tab:hover {
  color: var(--text);
  background: #f8fafc;
}

.master-tab.active,
.master-tab.is-active {
  background: var(--primary);
  color: #fff;
}

.content {
  flex: 1;
  width: 100%;
  padding: 1.75rem 2.5rem 2.75rem;
}

/* ── Cards & Stats ──────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.grid { display: grid; gap: 1rem; }

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 1.5rem;
}

.two-col { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat {
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat .label {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stat .value {
  font-size: 2rem;
  font-weight: 700;
  margin-top: .35rem;
  letter-spacing: -.03em;
  color: var(--text);
}

/* ── Page shell (shared layout) ─────────────────────── */

.page-shell,
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page-hero,
.dash-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.page-hero-label,
.dash-hero-label {
  margin: 0 0 .25rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--primary);
}

.page-hero-desc,
.dash-hero-desc {
  margin: 0;
  font-size: .95rem;
  max-width: 42rem;
}

.page-hero-actions,
.dash-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  flex-shrink: 0;
  align-items: center;
}

.page-panel,
.dash-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 1.35rem 1.5rem;
}

.page-meta {
  margin: .35rem 0 0;
  font-size: .9rem;
}

.page-meta .stat-pill {
  margin-left: .35rem;
}

.page-hero-title {
  margin: .15rem 0 .25rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.25;
}

.page-hero-text .back-link {
  margin-bottom: .5rem;
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1rem;
  margin-bottom: 1.15rem;
  padding: .9rem 1.1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-wrap: wrap;
}

.filter-bar .search-bar {
  flex: 1 1 320px;
  min-width: 0;
}

.settings-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  max-width: 100%;
}

.settings-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  min-width: 0;
}

.settings-aside {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: calc(var(--header-height) + 1rem);
}

.settings-card {
  padding: 1.35rem 1.5rem;
}

.settings-card h2 {
  margin: 0;
  font-size: 1rem;
}

.settings-card-header {
  display: flex;
  align-items: flex-start;
  gap: .9rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.settings-card-header > div > .muted {
  margin: .2rem 0 0;
  font-size: .84rem;
}

.settings-card-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  flex-shrink: 0;
}

.settings-card-icon svg {
  width: 20px;
  height: 20px;
}

.settings-card-icon--schedule {
  background: var(--primary-soft);
  color: var(--primary);
}

.settings-card-icon--limits {
  background: var(--warning-soft);
  color: var(--warning);
}

.settings-card-icon--security {
  background: #faf5ff;
  color: #7c3aed;
}

.settings-card-icon--webhook {
  background: #f0fdf4;
  color: var(--success);
}

.settings-fields {
  display: grid;
  gap: 1rem;
}

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

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

.field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  min-width: 0;
}

.field label {
  margin: 0;
  font-size: .84rem;
  font-weight: 600;
  color: var(--text);
}

.field input {
  margin-top: 0;
  width: 100%;
}

.field-hint {
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.4;
}

.field-hint code {
  font-size: .74rem;
}

.settings-card-note {
  margin: 1rem 0 0;
  font-size: .84rem;
  line-height: 1.45;
}

.settings-card-note a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.settings-card-note a:hover {
  text-decoration: underline;
}

.security-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}

.config-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .28rem .7rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid var(--border);
}

.config-badge.is-configured {
  background: var(--success-soft);
  color: var(--success);
  border-color: #bbf7d0;
}

.config-badge.is-missing {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: #fde68a;
}

.toggle {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  margin: 0;
  cursor: pointer;
  font-weight: 500;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #cbd5e1;
  flex-shrink: 0;
  transition: background var(--transition);
  margin-top: .1rem;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .2);
  transition: transform var(--transition);
}

.toggle input:checked + .toggle-track {
  background: var(--success);
}

.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
}

.toggle input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .2);
}

.toggle-copy {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}

.toggle-copy strong {
  font-size: .92rem;
}

.toggle-copy .muted {
  font-size: .8rem;
  font-weight: 500;
}

.settings-aside-link {
  display: inline-flex;
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  font-size: .86rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.settings-aside-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: sticky;
  bottom: 1rem;
  z-index: 20;
}

.settings-status {
  font-size: .9rem;
  font-weight: 600;
  color: var(--success);
}

@media (max-width: 960px) {
  .settings-aside {
    position: static;
  }

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

@media (max-width: 640px) {
  .settings-fields--2,
  .settings-fields--3 {
    grid-template-columns: 1fr;
  }

  .settings-actions {
    bottom: .75rem;
  }
}

/* Legacy aliases kept for safety */
.settings-groups { display: contents; }
.settings-group { display: contents; }
.settings-hint { font-size: .84rem; }
.settings-footer { display: contents; }

.table-cell-truncate {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quota-cell {
  min-width: 140px;
}

.quota-cell-text {
  display: block;
  font-size: .84rem;
  margin-bottom: .35rem;
  font-variant-numeric: tabular-nums;
}

.quota-cell .quota-bar {
  height: 5px;
}

/* ── Dashboard stats ────────────────────────────────── */

.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
}

.stat-card-icon svg {
  width: 22px;
  height: 22px;
}

.stat-card--banks .stat-card-icon {
  background: var(--primary-soft);
  color: var(--primary);
}

.stat-card--branches .stat-card-icon {
  background: #f0fdf4;
  color: var(--success);
}

.stat-card--keys .stat-card-icon {
  background: var(--warning-soft);
  color: var(--warning);
}

.stat-card--webhooks .stat-card-icon {
  background: #faf5ff;
  color: #7c3aed;
}

.stat-card-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .02em;
}

.stat-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.2;
  margin-top: .15rem;
  font-variant-numeric: tabular-nums;
}

.dash-panel--sync .section-header {
  margin-bottom: 1rem;
}

.sync-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  flex-wrap: wrap;
}

.sync-bar-info {
  display: flex;
  align-items: center;
  gap: 1.5rem 2.5rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.sync-status-item {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.sync-status-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.sync-status-time {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .92rem;
  font-weight: 500;
}

.sync-status-time svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
  flex-shrink: 0;
}

.sync-status-empty {
  font-size: .92rem;
}

.dash-panel--sync .dash-actions {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  flex-shrink: 0;
}

.dash-panel--wide {
  margin-top: 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--border-light);
}

.section-header h2 {
  margin: 0;
  font-size: 1rem;
}

.section-link {
  font-size: .84rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}

.section-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.dash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border-light);
}

.quota-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .85rem;
}

.quota-list {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.quota-item {
  padding: .9rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.quota-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}

.quota-item-name {
  font-weight: 700;
  font-size: .92rem;
}

.quota-item-key {
  font-size: .78rem;
  color: var(--muted);
}

.quota-item-stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  font-size: .84rem;
  color: var(--muted);
  margin-bottom: .45rem;
}

.quota-item-stats strong {
  color: var(--text);
  font-size: .9rem;
}

.quota-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.quota-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width .3s ease;
}

.quota-bar > span.quota-ok {
  background: linear-gradient(90deg, var(--success), #4ade80);
}

.quota-bar > span.quota-warn {
  background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.quota-bar > span.quota-low {
  background: linear-gradient(90deg, var(--danger), #f87171);
}

.quota-empty {
  color: var(--muted);
  padding: 1.5rem 1rem;
  text-align: center;
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: .9rem;
  grid-column: 1 / -1;
}

.quota-more {
  grid-column: 1 / -1;
  margin: .1rem 0 0;
  font-size: .86rem;
}

.quota-more a {
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.quota-more a:hover {
  text-decoration: underline;
}

.quota-families {
  display: grid;
  gap: .65rem;
  margin-top: .55rem;
}

.quota-family-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.quota-stack {
  display: grid;
  gap: .45rem;
  min-width: 11rem;
}

.quota-stack-row {
  display: grid;
  gap: .2rem;
}

@media (max-width: 1100px) {
  .dash-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .dash-stats {
    grid-template-columns: 1fr;
  }

  .page-hero,
  .dash-hero {
    flex-direction: column;
  }

  .page-hero-actions,
  .dash-quick-links {
    width: 100%;
  }

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

  .dash-panel--sync .dash-actions {
    justify-content: stretch;
  }

  .dash-panel--sync .dash-actions .btn {
    flex: 1;
  }
}

/* ── Buttons ────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .55rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: .88rem;
  font-family: inherit;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border-light);
  border-color: #cbd5e1;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--sidebar-text);
  border-color: rgba(255, 255, 255, .1);
  width: 100%;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
  border-color: rgba(255, 255, 255, .15);
}

.btn-block { width: 100%; }

.btn-sm {
  padding: .35rem .7rem;
  font-size: .82rem;
  border-radius: 6px;
}

/* ── Tables ─────────────────────────────────────────── */

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.toolbar h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.list-header {
  margin-bottom: 1rem;
}

.list-header-title h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.list-header-title .muted {
  margin: .3rem 0 0;
}

.list-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1rem;
  margin-bottom: 1rem;
  padding: .85rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-wrap: wrap;
}

.search-bar {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex: 1 1 320px;
  min-width: 0;
}

.search-bar input[type="search"] {
  flex: 1 1 auto;
  min-width: 180px;
  max-width: 420px;
  margin-top: 0;
  height: 40px;
}

.search-bar .btn {
  flex-shrink: 0;
  height: 40px;
  padding-left: 1rem;
  padding-right: 1rem;
}

.page-size {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.page-size select {
  width: auto;
  margin-top: 0;
  height: 40px;
  padding: 0 .75rem;
  min-width: 72px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th, td {
  text-align: left;
  padding: .8rem 1rem;
  font-size: .9rem;
  border-bottom: 1px solid var(--border-light);
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

th:first-child { border-radius: 8px 0 0 0; }
th:last-child { border-radius: 0 8px 0 0; }

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover { background: #f8fafc; }

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

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

.table-wrap table { margin: 0; }

/* ── Badges ─────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #f1f5f9; color: #475569; }

/* ── Forms & Inputs ─────────────────────────────────── */

.muted { color: var(--muted); }

.alert {
  padding: .8rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .9rem;
}

.alert-error {
  background: var(--danger-soft);
  color: #991b1b;
  border: 1px solid #fecaca;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: .88rem;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
select {
  width: 100%;
  margin-top: .35rem;
  padding: .7rem .85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  background: #f8fafc;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input:focus,
select:focus {
  outline: none;
  background: #fff;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

input::placeholder {
  color: #94a3b8;
  font-weight: 450;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 500;
}

.checkbox input { width: auto; margin: 0; }

/* Shared form controls (modals + pages) */

.form-field {
  display: grid;
  gap: .4rem;
  margin: 0;
}

.form-field > label,
.form-label {
  margin: 0;
  font-size: .8rem;
  font-weight: 650;
  letter-spacing: .01em;
  color: #334155;
}

.form-optional {
  margin-left: .35rem;
  font-weight: 500;
  font-size: .75rem;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0;
}

.form-field input,
.form-field select {
  margin-top: 0;
}

.form-field--half {
  max-width: 10rem;
}

.form-switch {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin: 0;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 500;
}

.form-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.form-switch-track {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 24px;
  margin-top: .1rem;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background var(--transition);
}

.form-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .2);
  transition: transform var(--transition);
}

.form-switch input:checked + .form-switch-track {
  background: var(--primary);
}

.form-switch input:checked + .form-switch-track .form-switch-thumb {
  transform: translateX(16px);
}

.form-switch input:focus-visible + .form-switch-track {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .2);
}

.form-switch-copy {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  min-width: 0;
}

.form-switch-copy strong {
  font-size: .9rem;
  font-weight: 650;
  color: var(--text);
}

.form-switch-copy .muted {
  font-size: .8rem;
  font-weight: 450;
}

.form-check-grid {
  display: grid;
  gap: .5rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin: 0;
  padding: .7rem .85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 500;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.form-check:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.form-check:has(input:checked) {
  border-color: rgba(37, 99, 235, .35);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .08);
}

.form-check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.form-check-box {
  position: relative;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 1.5px solid #94a3b8;
  border-radius: 5px;
  background: #fff;
  transition: border-color var(--transition), background var(--transition);
}

.form-check input:checked + .form-check-box {
  border-color: var(--primary);
  background: var(--primary);
}

.form-check input:checked + .form-check-box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.form-check input:focus-visible + .form-check-box {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .2);
}

.form-check-text code {
  font-size: .82rem;
}

/* ── Pagination ─────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-light);
}

.pagination-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin-left: auto;
}

.list-range { font-size: .88rem; }

.page-info {
  min-width: 80px;
  text-align: center;
  font-size: .88rem;
  color: var(--muted);
  font-weight: 500;
}

/* ── Master cards ───────────────────────────────────── */

.master-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.master-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.master-card:hover {
  border-color: #93c5fd;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.master-card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}

.master-card-icon svg {
  width: 20px;
  height: 20px;
}

.master-card-body {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  min-width: 0;
}

.master-card-title {
  font-weight: 700;
  color: var(--text);
  font-size: 1rem;
}

.master-card-desc {
  font-size: .86rem;
  color: var(--muted);
  line-height: 1.45;
}

.master-card-arrow {
  margin-left: auto;
  align-self: center;
  color: var(--muted);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.master-card--hub {
  cursor: default;
}

.master-card--hub:hover {
  transform: none;
}

.master-card-links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .85rem;
  margin-top: .65rem;
}

.master-card-links a {
  font-size: .82rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.master-card-links a:hover {
  text-decoration: underline;
}

.dash-master-filter {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .85rem;
}

.dash-master-filter select {
  padding: .35rem .55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
}

/* ── Misc ───────────────────────────────────────────── */

td.num {
  color: var(--muted);
  font-size: .85rem;
  width: 3rem;
  font-variant-numeric: tabular-nums;
}

.stat-pill {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  margin-left: .4rem;
}

.back-link {
  color: var(--primary);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  margin-bottom: .5rem;
}

.back-link:hover { color: var(--primary-dark); text-decoration: underline; }

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
  white-space: nowrap;
}

code {
  font-size: .84rem;
  background: #f1f5f9;
  color: #334155;
  padding: .15rem .4rem;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── Modal ──────────────────────────────────────────── */

.modal {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(480px, 94vw);
  max-height: min(90vh, 760px);
  overflow: hidden;
  color: var(--text);
  background: #fff;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, .06),
    0 24px 64px rgba(15, 23, 42, .22);
}

.modal.modal--lg {
  width: min(640px, 96vw);
}

.modal[open] {
  display: flex;
  flex-direction: column;
}

.modal::backdrop {
  background: rgba(11, 31, 42, .52);
  backdrop-filter: blur(4px);
}

.modal-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: inherit;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  padding: 1.25rem 1.35rem 1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: #fff;
}

.modal-header-text {
  min-width: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.modal-desc {
  margin: .4rem 0 0;
  font-size: .86rem;
  color: var(--muted);
  line-height: 1.45;
}

.modal-close {
  appearance: none;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  margin: -.15rem 0 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.modal-close:hover {
  background: #f1f5f9;
  color: var(--text);
}

.modal-close svg {
  width: 1.05rem;
  height: 1.05rem;
}

.modal-fields {
  display: grid;
  gap: 1rem;
  flex: 1 1 auto;
  min-height: 0;
  padding: 1.15rem 1.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-body { padding: 1.5rem; }

.modal-body h3 {
  margin: 0 0 1.25rem;
  font-size: 1.1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .55rem;
  flex-shrink: 0;
  margin: 0;
  padding: 1rem 1.5rem 1.2rem;
  border-top: 1px solid var(--border-light);
  background: #f8fafc;
  border-radius: 0 0 16px 16px;
}

.modal-actions .btn {
  min-width: 88px;
}

.form-row {
  display: grid;
  gap: 1rem;
}

.form-row--2 {
  grid-template-columns: 1fr auto;
  align-items: end;
}

@media (max-width: 560px) {
  .form-row--2 {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

.form-field--switch .form-switch--compact {
  padding: .65rem .85rem;
  min-width: 8.5rem;
}

.form-switch--compact .form-switch-copy strong {
  font-size: .875rem;
}

.link-btn {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.event-picker-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .65rem;
}

.event-picker-actions {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.event-picker-sep {
  color: #cbd5e1;
  font-size: .8rem;
}

.event-groups {
  display: grid;
  gap: .85rem;
}

.event-group {
  padding: .85rem .95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.event-group-title {
  margin: 0 0 .55rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-check-grid--compact {
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: .4rem;
}

.form-check-grid--2 {
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
}

.form-check--sm {
  padding: .45rem .65rem;
  border-radius: 8px;
  gap: .5rem;
  background: #fff;
}

.form-check--sm .form-check-box {
  width: 15px;
  height: 15px;
  border-radius: 4px;
}

.form-check--sm .form-check-box::after,
.form-check--sm input:checked + .form-check-box::after {
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
}

.form-check--sm .form-check-text {
  font-size: .8rem;
  color: #334155;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.full-width { grid-column: 1 / -1; }

/* ── Login ──────────────────────────────────────────── */

.login-screen {
  --login-ink: #0b1f2a;
  --login-sea: #145a66;
  --login-foam: #e8f3f1;
  --login-accent: #f0a05a;
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  color: var(--login-foam);
  background: var(--login-ink);
}

.login-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(232, 243, 241, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 243, 241, .04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 70% at 30% 40%, #000 20%, transparent 75%);
  animation: login-grid-drift 28s linear infinite;
}

.login-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
}

.login-glow--a {
  width: 42vw;
  height: 42vw;
  top: -12%;
  left: -8%;
  background: rgba(20, 90, 102, .55);
  animation: login-glow-pulse 10s ease-in-out infinite;
}

.login-glow--b {
  width: 36vw;
  height: 36vw;
  right: -10%;
  bottom: -18%;
  background: rgba(240, 160, 90, .18);
  animation: login-glow-pulse 12s ease-in-out infinite reverse;
}

@keyframes login-grid-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-48px, -48px, 0); }
}

@keyframes login-glow-pulse {
  0%, 100% { opacity: .7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 420px);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
  padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1.5rem, 6vw, 5rem);
  max-width: 1120px;
  margin: 0 auto;
}

.login-hero {
  max-width: 34rem;
}

.login-kicker {
  margin: 0 0 1rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(232, 243, 241, .55);
}

.login-brand {
  margin: 0 0 1.1rem;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.04em;
  color: #fff;
}

.login-brand-jp {
  display: block;
  margin-bottom: .35rem;
  font-family: "Noto Sans JP", sans-serif;
  font-size: .42em;
  font-weight: 700;
  letter-spacing: .28em;
  color: var(--login-accent);
}

.login-tagline {
  margin: 0 0 1.75rem;
  font-size: 1.05rem;
  line-height: 1.6;
  color: rgba(232, 243, 241, .78);
  max-width: 28rem;
}

.login-points {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: .65rem;
}

.login-points li {
  position: relative;
  padding-left: 1.15rem;
  font-size: .92rem;
  color: rgba(232, 243, 241, .62);
}

.login-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .55em;
  width: .45rem;
  height: .45rem;
  border-radius: 1px;
  background: var(--login-accent);
  transform: rotate(45deg);
}

.login-panel {
  background: rgba(255, 255, 255, .96);
  color: var(--text);
  border-radius: 18px;
  padding: clamp(1.5rem, 3vw, 2rem);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .35) inset,
    0 24px 48px rgba(0, 0, 0, .28);
  animation: login-panel-in .55s ease both;
}

@keyframes login-panel-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-form-head h2 {
  margin: 0 0 .35rem;
  font-size: 1.35rem;
  letter-spacing: -.02em;
}

.login-form-head p {
  margin: 0 0 1.35rem;
  color: var(--muted);
  font-size: .92rem;
}

.login-field {
  display: grid;
  gap: .45rem;
  margin-bottom: 1rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
}

.login-field input {
  width: 100%;
  padding: .75rem .9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-weight: 500;
  background: #f8fafb;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.login-field input:focus {
  outline: none;
  background: #fff;
  border-color: var(--login-sea);
  box-shadow: 0 0 0 3px rgba(20, 90, 102, .18);
}

.login-submit {
  width: 100%;
  margin-top: .35rem;
  padding: .8rem 1rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #145a66 0%, #0b3d47 100%);
  box-shadow: 0 8px 20px rgba(11, 61, 71, .28);
}

.login-submit:hover {
  filter: brightness(1.06);
}

@media (max-width: 860px) {
  .login-shell {
    grid-template-columns: 1fr;
    align-content: center;
    padding-top: 3rem;
    padding-bottom: 3rem;
  }

  .login-hero {
    max-width: none;
  }

  .login-points {
    display: none;
  }
}

/* ── Responsive ───────────────────────────────────── */

@media (max-width: 1200px) {
  .content,
  .page-header-inner {
    padding-left: 1.75rem;
    padding-right: 1.75rem;
  }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 240px; }

  .content,
  .page-header-inner {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

@media (max-width: 720px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    max-height: none;
  }

  .main { margin-left: 0; }

  .sidebar-nav {
    max-height: 50vh;
  }

  .page-header { position: relative; }
}

/* Logs page */
.logs-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 0 0 1.25rem;
}
.logs-tab {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface, #fff);
  color: var(--text-muted, #64748b);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  padding: .45rem .9rem;
  border-radius: 8px;
  cursor: pointer;
}
.logs-tab:hover { color: var(--text); border-color: var(--primary); }
.logs-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.logs-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.logs-filters select {
  font: inherit;
  font-size: .85rem;
  padding: .35rem .55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface, #fff);
}
.logs-panel.is-hidden { display: none; }

/* ── Panel tabs (Webhooks) ──────────────────────────── */

.webhooks-page {
  gap: 1.15rem;
}

.master-panel-tabs {
  display: flex;
  width: 100%;
  margin: 0 0 1.25rem;
  max-width: 100%;
}

.webhook-tab-hero {
  margin-bottom: 1.15rem;
  padding-bottom: 1.05rem;
  border-bottom: 1px solid var(--border);
}

.webhook-tab-hero .page-hero-desc {
  max-width: 40rem;
}

.panel-tabs {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  gap: .25rem;
  padding: .3rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.panel-tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  gap: .45rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .875rem;
  font-weight: 650;
  padding: .55rem .95rem;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}

.panel-tab:hover {
  color: var(--text);
  background: #f8fafc;
}

.panel-tab.is-active,
.panel-tab.active {
  background: var(--primary);
  color: #fff;
}

.panel-tab-icon {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  opacity: .9;
}

.panel-tab-icon svg {
  width: 16px;
  height: 16px;
}

.panel-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 .35rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, .08);
  color: inherit;
  font-size: .72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.panel-tab.is-active .panel-tab-count {
  background: rgba(255, 255, 255, .22);
}

.webhook-tab-panel {
  animation: webhookPanelIn .18s ease;
}

.webhook-tab-panel[hidden] {
  display: none !important;
}

@keyframes webhookPanelIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.webhook-events-cell {
  max-width: 22rem;
  line-height: 1.7;
}

.webhook-events-cell code {
  display: inline-block;
  margin: .05rem .15rem .05rem 0;
  font-size: .72rem;
}

.webhook-endpoints-table table {
  table-layout: fixed;
  width: 100%;
}

.webhook-endpoints-table th:nth-child(1),
.webhook-endpoints-table td:nth-child(1) {
  width: 36%;
}

.webhook-endpoints-table th:nth-child(2),
.webhook-endpoints-table td:nth-child(2) {
  width: 12%;
}

.webhook-endpoints-table th:nth-child(3),
.webhook-endpoints-table td:nth-child(3),
.webhook-endpoints-table th:nth-child(4),
.webhook-endpoints-table td:nth-child(4) {
  width: 14%;
}

.webhook-endpoints-table th:nth-child(5),
.webhook-endpoints-table td:nth-child(5) {
  width: 7.5rem;
}

.webhook-endpoint-name {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  min-width: 0;
}

.webhook-endpoint-name strong {
  font-size: .925rem;
}

.webhook-endpoint-url {
  color: var(--muted);
  font-size: .8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.webhook-endpoint-meta {
  display: inline-flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .15rem;
}

.webhook-events-summary {
  color: var(--text);
  font-weight: 600;
  font-size: .875rem;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .35rem;
  white-space: nowrap;
}

.action-menu {
  position: relative;
}

.action-menu-btn {
  appearance: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.action-menu-btn:hover,
.action-menu.is-open .action-menu-btn {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--text);
}

.action-menu-btn svg {
  width: 1rem;
  height: 1rem;
}

.action-menu-panel {
  position: fixed;
  z-index: 1200;
  display: none;
  min-width: 10.5rem;
  padding: .35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .14);
}

.action-menu.is-open .action-menu-panel {
  display: grid;
  gap: .1rem;
}

.action-menu-item {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: .55rem .7rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .84rem;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
}

.action-menu-item:hover {
  background: #f1f5f9;
}

.action-menu-item--danger {
  color: #b91c1c;
}

.action-menu-item--danger:hover {
  background: #fef2f2;
}

@media (max-width: 720px) {
  .panel-tabs {
    width: 100%;
  }
  .panel-tab {
    flex: 1 1 auto;
    justify-content: center;
  }
  .webhook-endpoints-table th:nth-child(2),
  .webhook-endpoints-table td:nth-child(2) {
    display: none;
  }
}

/* ── Change Log ─────────────────────────────────────── */

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

.change-log-panel {
  gap: 0;
}

.change-log-toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.15rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.change-log-filters {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem .75rem;
}

.filter-group-label {
  flex: 0 0 4.5rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.seg-control {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: .2rem;
  padding: .2rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.seg-control--wrap {
  flex-wrap: wrap;
}

.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  padding: .4rem .75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.seg-btn:hover {
  color: var(--text);
  background: #f1f5f9;
}

.seg-btn.is-active {
  background: var(--primary);
  color: #fff;
}

.change-log-summary {
  margin: 0;
  font-size: .88rem;
}

.change-log-summary strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.change-log-table-wrap table {
  width: 100%;
}

.change-log-table-wrap th {
  white-space: nowrap;
}

.change-log-when {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  min-width: 7.5rem;
}

.change-log-when-main {
  font-weight: 600;
  font-size: .9rem;
}

.change-log-when-sub {
  font-size: .75rem;
}

.mono-id {
  font-size: .82rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .15rem .4rem;
}

.resource-pill {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.pill-bank {
  background: #eff6ff;
  color: #1d4ed8;
}

.pill-branch {
  background: #ecfeff;
  color: #0e7490;
}

.pill-muted {
  background: #f1f5f9;
  color: #475569;
}

.chg-badge {
  display: inline-flex;
  align-items: center;
  padding: .22rem .55rem;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .01em;
  text-transform: lowercase;
}

.chg-added { background: #f0fdf4; color: #15803d; }
.chg-updated { background: #eff6ff; color: #1d4ed8; }
.chg-removed { background: #fef2f2; color: #b91c1c; }
.chg-renamed { background: #fff7ed; color: #c2410c; }
.chg-code { background: #f5f3ff; color: #6d28d9; }
.chg-muted { background: #f1f5f9; color: #475569; }

.job-link {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  text-decoration: none;
}

.job-link:hover {
  text-decoration: underline;
}

.change-log-name {
  max-width: 16rem;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 1.5rem;
  gap: .35rem;
}

.empty-state-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: .65rem;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-state-icon svg {
  width: 26px;
  height: 26px;
}

.empty-state-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.empty-state-desc {
  margin: 0;
  max-width: 28rem;
  font-size: .9rem;
}

@media (max-width: 720px) {
  .filter-group-label {
    flex-basis: 100%;
  }
}
