@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;600;700&display=swap");

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  line-height: 1.5;
  font-family: "Noto Sans JP", "Noto Sans", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  line-height: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  background: none;
  border: none;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e0ebff;
  --accent-soft: #e2e8f0;
  --border: #e2e8f0;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.08);
}

body {
  background: var(--bg);
  color: var(--ink);
}

body.sidebar-open {
  overflow: hidden;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 256px;
  background: #ffffff;
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-profile {
  margin-bottom: 20px;
}

.profile-card {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: #f1f5f9;
  border: 1px solid var(--border);
}

.profile-name {
  font-weight: 700;
}

.profile-role {
  font-size: 13px;
  color: var(--muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 6px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  min-height: 44px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-parent {
  width: 100%;
  text-align: left;
  justify-content: space-between;
  cursor: pointer;
}

.nav-caret {
  font-size: 12px;
  color: #64748b;
  transition: transform 0.15s ease;
}

.nav-group.open .nav-caret {
  transform: rotate(180deg);
}

.nav-submenu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 6px;
}

.nav-sub-item {
  display: block;
  margin-left: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  border-left: 2px solid transparent;
}

.nav-sub-item:hover {
  background: #f1f5f9;
}

.nav-sub-item.active {
  background: #eff6ff;
  color: #1d4ed8;
  border-left-color: var(--primary);
}

.nav-item:hover {
  background: #f1f5f9;
}

.nav-item.active {
  background: #eff6ff;
  color: #1d4ed8;
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding-left: 10px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.menu-toggle:hover {
  background: #f1f5f9;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 35;
}

.content {
  padding: 24px;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--card);
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

h1, h2, h3, h4 {
  margin-top: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 20px;
  font-weight: 700;
}

h3 {
  font-size: 16px;
  font-weight: 600;
}

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

.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  color: var(--muted);
}

.form-grid input,
.form-grid textarea,
.form-grid select {
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.btn,
.form-grid button,
.button {
  padding: 10px 16px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-weight: 400;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover,
.form-grid button:hover,
.button:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  grid-column: 1 / -1;
}

.form-actions .event-delete-inline {
  margin-left: auto;
}

.btn.ghost,
.form-actions .ghost {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn.ghost.danger {
  color: #dc2626;
  border-color: #fecaca;
}

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

.event-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.event-card {
  display: block;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--ink);
  background: var(--accent-soft);
}

.event-title {
  font-weight: 700;
}

.event-meta {
  font-size: 13px;
  color: var(--muted);
}

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

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  position: relative;
  z-index: 1000;
  background: var(--bg);
  isolation: isolate;
}

.page-header h1 {
  margin: 0 0 4px 0;
  font-size: 24px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-filter {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.inline-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.inline-label select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: #ffffff;
  min-width: 140px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 14px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.plan-list-wrapper {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}

.plan-list-table {
  margin-top: 0;
}

.plan-list-table th {
  white-space: nowrap;
}

.plan-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
}

.plan-sort-btn::after {
  content: "↕";
  font-size: 11px;
  color: #94a3b8;
}

.plan-sort-btn.is-asc::after {
  content: "↑";
  color: #334155;
}

.plan-sort-btn.is-desc::after {
  content: "↓";
  color: #334155;
}

.plan-sort-btn:hover {
  color: #1f2937;
}

.plan-list-link {
  color: #1d4ed8;
  font-weight: 700;
}

.plan-list-link:hover {
  text-decoration: underline;
}

.table .col-area {
  min-width: 180px;
}

.inline-submit {
  display: flex;
  align-items: flex-end;
}

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

.trend-controls {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.trend-filter {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #f8fafc;
}

.trend-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.trend-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.trend-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.trend-chart {
  height: 320px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 8px;
}

.table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
}

.table input[type="number"] {
  width: 100%;
  min-width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

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

.inline-form input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  min-width: 200px;
}

.inline-form input.month-input {
  min-width: 72px;
  width: 88px;
}

.asset-delete-form {
  width: 100%;
  justify-content: flex-end;
}

.asset-grid {
  display: grid;
  gap: 20px;
}

.asset-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}

.asset-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.asset-title {
  font-weight: 700;
}

.asset-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.asset-actions .inline-form {
  margin: 0;
}

.asset-actions .btn.is-selected {
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
}

.asset-panel {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.asset-meta {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.analysis-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}

.analysis-preview-column h3,
.analysis-data-column h3 {
  margin-bottom: 8px;
}

.analysis-page-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.analysis-page-button {
  padding: 6px 10px;
  min-height: 34px;
}

.analysis-page-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.analysis-page-indicator {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.analysis-preview-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  background: #f8fafc;
  line-height: 0;
}

.analysis-preview-image {
  width: 100%;
  height: auto;
  display: block;
  background: #ffffff;
}

.analysis-preview-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  pointer-events: none;
}

.analysis-overlay-cell {
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.42);
}

.analysis-overlay-cell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(37, 99, 235, 0.72);
  opacity: 0.18;
  transition: opacity 0.15s ease, box-shadow 0.15s ease;
}

.analysis-overlay-label {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
  font-size: 11px;
  color: #1e3a8a;
  background: rgba(219, 234, 254, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 999px;
  padding: 1px 6px;
}

.analysis-overlay-cell.is-active::before {
  opacity: 0.9;
  box-shadow: inset 0 0 0 2px #1d4ed8;
}

.analysis-overlay-cell.is-active .analysis-overlay-label {
  background: #1d4ed8;
  color: #ffffff;
  border-color: #1d4ed8;
}

.analysis-preview-caption {
  margin: 10px 0 0;
  font-size: 12px;
}

.analysis-data-column > p {
  margin-top: 0;
  margin-bottom: 12px;
}

.analysis-page-summary {
  font-size: 14px;
}

.analysis-grid-note {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 12px;
}

.analysis-grid-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.analysis-grid-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--area-border-color, #d1d5db);
  border-radius: 10px;
  background:
    linear-gradient(
      135deg,
      var(--area-color-start, #ffffff) 0%,
      var(--area-color-end, #ffffff) 100%
    ),
    #f8fafc;
  color: var(--area-text-color, var(--ink));
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.analysis-grid-item:hover {
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 0 0 1px rgba(147, 197, 253, 0.45) inset;
}

.analysis-grid-item:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 1px;
}

.analysis-grid-item.is-active {
  border-color: #1d4ed8;
  box-shadow: inset 0 0 0 1px #1d4ed8, 0 0 0 2px rgba(29, 78, 216, 0.18);
}

.analysis-grid-label {
  font-size: 12px;
  color: var(--area-subtext-color, var(--muted));
  font-weight: 600;
}

.analysis-grid-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--area-text-color, var(--ink));
}

.analysis-grid-unit {
  font-size: 11px;
  color: var(--area-subtext-color, var(--muted));
  font-weight: 600;
}

.source-text-order {
  margin: 0 0 12px;
  padding: 0 0 0 20px;
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.source-text-order li {
  font-size: 13px;
  line-height: 1.6;
  color: #1f2937;
}

.font-table h4 {
  margin-bottom: 8px;
}

.analysis-insight-list {
  display: grid;
  gap: 10px;
}

.analysis-insight-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px;
}

.analysis-insight-item h4 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
}

.analysis-insight-item p {
  margin: 0;
  font-size: 13px;
  color: #334155;
  line-height: 1.6;
}

.font-histogram {
  display: grid;
  gap: 8px;
}

.font-bar-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items: center;
}

.font-bar-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.font-bar-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
}

.font-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  min-width: 2px;
}

.font-bar-row[data-zero="true"] .font-bar-fill {
  min-width: 0;
}

.font-bar-value {
  font-size: 12px;
  color: #1e293b;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.map-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.map-legend {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-legend form {
  margin: 0;
}

.map-legend .btn {
  padding: 6px 10px;
  font-size: 12px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.base {
  background: #2563eb;
}

.legend-dot.facility {
  background: #f59e0b;
}

.area-map {
  position: relative;
  min-height: 380px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #e2e8f0;
  overflow: hidden;
  z-index: 1;
}

.leaflet-container {
  z-index: 0;
}

.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

.map-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.2);
  cursor: default;
}

.map-marker.base {
  background: #2563eb;
}

.map-marker.facility {
  background: #f59e0b;
}

.marker-label {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.map-marker:hover .marker-label {
  opacity: 1;
}

.preview-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.preview-card {
  min-width: 260px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  padding: 12px;
}

.preview-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.preview-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}

.preview-frame {
  width: 100%;
  height: 320px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

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

.row-actions .inline-form {
  margin: 0;
}

.icon-btn {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--ink);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.icon-btn:hover {
  border-color: #94a3b8;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.icon-btn.danger {
  color: #dc2626;
  border-color: #fecaca;
  background: #fff7f7;
}

.edit-row td {
  background: #f8fafc;
}

.branch-grid {
  display: grid;
  gap: 16px;
}

.branch-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: #ffffff;
}

.branch-board-wrap {
  position: relative;
  margin-top: 12px;
}

.branch-board {
  --flow-zoom: 1;
  position: relative;
  min-height: 260px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  overflow: auto;
}

.branch-canvas {
  position: relative;
  min-height: 520px;
  min-width: 1200px;
  transform: scale(var(--flow-zoom));
  transform-origin: 0 0;
  background:
    radial-gradient(circle, rgba(148, 163, 184, 0.35) 1px, transparent 1px) 0 0 / 20px 20px,
    #f8fafc;
}

.zoom-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.95);
  box-shadow: var(--shadow-sm);
  z-index: 6;
}

.flow-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.flow-line {
  stroke: #94a3b8;
  stroke-width: 2;
  pointer-events: stroke;
}

.flow-line.join {
  stroke: #16a34a;
}

.flow-line.not-join {
  stroke: #ef4444;
}

.flow-line.temp {
  stroke: #2563eb;
  stroke-dasharray: 4 4;
}

.branch-board .jtk-connector {
  z-index: 1;
}

.branch-board .jtk-endpoint {
  z-index: 2;
}

.branch-node {
  position: absolute;
  top: 0;
  left: 0;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d7dde8;
  background: #ffffff;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.1);
  cursor: grab;
  user-select: none;
  z-index: 3;
}

.node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.node-icon {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: #22c55e;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.branch-port {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid #94a3b8;
  transform: translateY(-50%);
  z-index: 4;
  cursor: crosshair;
}

.branch-port.in {
  left: -8px;
}

.branch-port.out {
  right: -8px;
}

.branch-port.out.join {
  top: 44%;
  border-color: #16a34a;
}

.branch-port.out.not-join {
  top: 70%;
  border-color: #ef4444;
}

.branch-node:active {
  cursor: grabbing;
}

.branch-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.branch-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.branch-offer {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.branch-actions {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.branch-flag {
  padding: 4px 6px;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.branch-flag.join {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.branch-flag.not-join {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0;
}

.grid-cell {
  background: #f1f5f9;
  padding: 10px;
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
}

.annual-calendar-wrapper {
  margin-top: 12px;
  border: 1px solid #c7d3de;
  border-radius: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  background: #edf2f6;
}

.annual-calendar-sheet {
  --calendar-label-width: 124px;
  --calendar-month-width: 88px;
  --calendar-track-gap: 8px;
  width: max-content;
  min-width: calc(
    var(--calendar-label-width) +
    (var(--calendar-month-width) * 12) +
    (var(--calendar-track-gap) * 11) +
    20px
  );
}

.annual-calendar-head {
  display: grid;
  grid-template-columns: var(--calendar-label-width) max-content;
  border-bottom: 1px solid #cad7e2;
  background: #e4ecf2;
}

.annual-head-legend {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  border-right: 1px solid #cad7e2;
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: var(--calendar-label-width);
  background: #e4ecf2;
  box-shadow: 1px 0 0 #cad7e2;
}

.annual-head-legend-item {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #365570;
}

.annual-head-legend-item + .annual-head-legend-item {
  border-top: 1px solid #cad7e2;
  background: #f3f7fb;
}

.annual-month-track {
  display: grid;
  grid-template-columns: repeat(12, var(--calendar-month-width));
  gap: var(--calendar-track-gap);
  padding: 10px 10px 12px;
}

.annual-month-pill {
  position: relative;
  height: 112px;
  border-radius: 999px;
  border: 2px solid var(--month-accent);
  background: linear-gradient(to bottom, var(--month-accent) 0 52%, #f7fafd 52% 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
}

.annual-month-pill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.annual-month-recommended,
.annual-month-execution {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.15;
  position: relative;
  z-index: 1;
}

.annual-month-recommended {
  margin-top: 12px;
  color: #ffffff;
}

.annual-month-execution {
  margin-bottom: 14px;
  color: var(--month-accent);
}

.annual-calendar-body {
  background: #edf2f6;
}

.annual-calendar-row {
  display: grid;
  grid-template-columns: var(--calendar-label-width) max-content;
  border-bottom: 1px dashed #b7c8d7;
}

.annual-calendar-row:last-child {
  border-bottom: none;
}

.annual-calendar-row.is-seasonal-row {
  border-bottom-color: #8fb0c8;
}

.annual-row-label {
  background: #d4dfe8;
  border-right: 1px solid #c1cfdb;
  padding: 12px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #2f4f68;
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: var(--calendar-label-width);
  box-shadow: 1px 0 0 #c1cfdb;
}

.annual-calendar-row.is-seasonal-row .annual-row-label {
  background: #c8dceb;
  color: #1f4f70;
  border-right-color: #8faec2;
  box-shadow: 1px 0 0 #8faec2;
}

.annual-row-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #7e9bb1;
  flex: 0 0 auto;
}

.annual-calendar-row.is-seasonal-row .annual-row-label::before {
  background: #3f7598;
}

.annual-row-grid {
  display: grid;
  grid-template-columns: repeat(12, var(--calendar-month-width));
  grid-template-rows: repeat(var(--track-count), minmax(36px, auto));
  gap: 7px var(--calendar-track-gap);
  padding: 7px 10px;
  align-items: center;
  position: relative;
}

.annual-calendar-row.is-seasonal-row .annual-row-grid {
  background: rgba(93, 142, 169, 0.07);
}

.annual-month-band {
  background: rgba(255, 255, 255, 0.44);
  border-left: 1px solid rgba(125, 149, 170, 0.24);
  border-right: 1px solid rgba(125, 149, 170, 0.15);
  z-index: 0;
}

.annual-month-band.is-alt {
  background: rgba(220, 230, 238, 0.5);
}

.annual-calendar-row.is-seasonal-row .annual-month-band {
  background: rgba(93, 142, 169, 0.18);
  border-left-color: rgba(79, 127, 153, 0.35);
  border-right-color: rgba(79, 127, 153, 0.25);
}

.annual-calendar-row.is-seasonal-row .annual-month-band.is-alt {
  background: rgba(93, 142, 169, 0.26);
}

.annual-event-bar {
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 32px;
  min-width: 0;
  max-width: 100%;
  padding: 4px 10px;
  border: 1px solid #5f8fae;
  background: #f7fbff;
  color: #2b5a7d;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.annual-event-bar:hover {
  transform: translateY(-1px);
  background: #e9f2f9;
}

.annual-event-bar.is-seasonal {
  background: #5d8ea9;
  color: #ffffff;
  border-color: #5d8ea9;
}

.annual-event-bar.is-seasonal:hover {
  background: #4f7f99;
  color: #ffffff;
}

.annual-row-empty {
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  color: #6b8296;
  font-size: 12px;
  font-weight: 600;
  padding-left: 4px;
}

.annual-empty {
  margin: 0;
  padding: 16px;
  color: var(--muted);
}

.year-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 24px;
  min-width: 0;
}

.year-card {
  padding: 20px;
  min-width: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
}

.card-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.inline-editor {
  display: block;
  width: 100%;
  margin-bottom: 16px;
}

.inline-editor summary {
  list-style: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.inline-editor summary::-webkit-details-marker {
  display: none;
}

.inline-editor .year-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0 12px;
}

.event-summary-main {
  min-width: 0;
}

.event-kpi-summary {
  margin-top: 8px;
}

.event-kpi-summary-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.event-kpi-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
  font-size: 12px;
}

.event-kpi-name {
  color: var(--muted);
  font-weight: 600;
}

.event-kpi-value {
  font-weight: 700;
}

.event-kpi-empty {
  margin: 0;
  font-size: 13px;
}

.event-kpi-inline {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #f8fafc;
}

.event-kpi-inline-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.event-kpi-inline-note {
  margin: 0 0 8px;
  font-size: 12px;
}

.summary-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-actions .inline-form {
  margin: 0;
}

.summary-actions .summary-action {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: var(--radius-md);
  min-height: 36px;
}

.summary-actions .summary-action--edit {
  font-size: inherit;
}

.summary-actions .btn {
  padding: 8px 12px;
  font-size: 13px;
  min-height: 36px;
}

.inline-editor .summary-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-weight: 400;
  border: 1px solid var(--primary-dark);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.inline-editor .summary-action .label-close {
  display: none;
}

.inline-editor[open] .summary-action {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #475569;
  box-shadow: none;
}

.inline-editor[open] .summary-action .icon-plus,
.inline-editor[open] .summary-action .label-open {
  display: none;
}

.inline-editor[open] .summary-action .label-close {
  display: inline;
}

.inline-editor summary:hover .summary-action {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.inline-editor form {
  margin-top: 12px;
  background: #ffffff;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: none;
  position: static;
  width: 100%;
  min-width: auto;
  max-width: none;
  z-index: 10;
}

.step-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: #ffffff;
}

.step-card + .step-card {
  margin-top: 16px;
}

.step-card form {
  border: none;
  padding: 0;
  background: transparent;
}

.signin-card {
  max-width: 520px;
}

@media (min-width: 1025px) {
  .topbar {
    display: none;
  }
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
    z-index: 40;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open .topbar {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .analysis-layout {
    grid-template-columns: 1fr;
  }

  .analysis-page-controls {
    flex-wrap: wrap;
  }

  .analysis-page-indicator {
    width: 100%;
    order: 3;
  }

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

  .content {
    padding: 20px;
  }

  .asset-header {
    flex-direction: column;
  }

  .annual-calendar-sheet {
    --calendar-label-width: 100px;
    --calendar-month-width: 80px;
    --calendar-track-gap: 6px;
  }

  .annual-row-label {
    font-size: 13px;
    padding: 10px 8px;
  }

  .annual-head-legend-item {
    font-size: 12px;
  }

  .inline-editor form {
    position: static;
    width: 100%;
    box-shadow: none;
  }

  .menu-toggle {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .analysis-grid-detail {
    grid-template-columns: 1fr;
  }
}
