:root {
  --bg: #f4f6f8;
  --surface: #fff;
  --border: #e2e8f0;
  --text: #1a2332;
  --text-2: #5c6b7e;
  --text-3: #94a3b8;
  --accent: #1e4d6b;
  --accent-deep: #0f2d3d;
  --accent-light: #e8f2f7;
  --accent-glow: rgba(45, 106, 143, 0.35);
  --success: #15803d;
  --success-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --map-cell: #f8fafc;
  --bubble: #2d6a8f;
  --bubble-light: #7eb8d4;
  --shadow-sm: 0 2px 8px rgba(15, 45, 61, 0.06);
  --shadow-md: 0 12px 40px rgba(15, 45, 61, 0.12);
  --shadow-lg: 0 24px 64px rgba(15, 45, 61, 0.18);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }
.hidden { display: none !important; }
.app { min-height: 100vh; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 60px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  position: sticky; top: 0; z-index: 50;
}
.brand-btn {
  display: flex; align-items: center; gap: 0.75rem; background: none; border: none;
  cursor: pointer; font-family: var(--font); text-align: left;
}
.brand-mark {
  width: 36px; height: 36px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-weight: 700; font-size: 0.75rem;
}
.brand-btn strong { display: block; font-size: 0.9rem; }
.brand-btn span { font-size: 0.7rem; color: var(--text-3); }
.topbar-center { flex: 1; text-align: center; font-size: 0.85rem; color: var(--text-2); }
.topbar-nav { display: flex; gap: 0.5rem; align-items: center; }
.topbar-nav a { font-size: 0.8rem; color: var(--text-2); text-decoration: none; padding: 0.4rem 0.6rem; }
.auth-chip {
  display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem;
  color: var(--text-2); background: var(--bg); padding: 0.25rem 0.5rem 0.25rem 0.75rem;
  border-radius: 999px; border: 1px solid var(--border);
}
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.7rem; }
.auth-panel { margin-top: 0.25rem; }
#recaptcha-container { min-height: 78px; margin: 0.75rem 0; display: flex; justify-content: center; }
.auth-hint { font-size: 0.8rem; margin-top: 0.35rem; }
.auth-error {
  font-size: 0.8rem; color: var(--danger); margin-top: 0.85rem;
  padding: 0.65rem 0.85rem; border-radius: 10px;
  background: rgba(220, 38, 38, 0.06); border: 1px solid rgba(220, 38, 38, 0.15);
}

/* Buttons */
.btn {
  font-family: var(--font); font-size: 0.8rem; font-weight: 500;
  padding: 0.45rem 0.9rem; border-radius: 8px; border: none; cursor: pointer;
}
.btn-primary {
  background: linear-gradient(180deg, #255f7f 0%, var(--accent) 100%);
  color: #fff; box-shadow: 0 2px 8px rgba(30, 77, 107, 0.25);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 4px 14px rgba(30, 77, 107, 0.3); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); }
.btn-block { width: 100%; margin-top: 0.5rem; }
.btn-icon { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-3); line-height: 1; }

/* Views */
.view { flex: 1; padding: 2rem; max-width: 1400px; margin: 0 auto; width: 100%; }

.hero { text-align: center; margin-bottom: 2.5rem; }
.hero h1 { font-family: var(--serif); font-size: 2.5rem; font-weight: 400; margin-bottom: 0.5rem; }
.hero p { color: var(--text-2); font-size: 1rem; }

/* Landing (public) */
#view-landing { padding: 0; max-width: none; width: 100%; overflow: hidden; }
.landing-shell {
  min-height: calc(100vh - 60px);
  max-height: calc(100vh - 60px);
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(320px, 1.05fr);
}
.landing-copy {
  display: flex; flex-direction: column; justify-content: center;
  padding: clamp(2rem, 5vw, 4.5rem);
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(126, 184, 212, 0.18) 0%, transparent 55%),
    linear-gradient(155deg, var(--accent-deep) 0%, var(--accent) 52%, #2d6a8f 100%);
  color: #fff;
  position: relative;
}
.landing-copy::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 70%, rgba(255,255,255,0.03) 100%);
  pointer-events: none;
}
.landing-eyebrow {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em;
  color: rgba(255,255,255,0.6); margin-bottom: 1.25rem;
}
.landing-copy h1 {
  font-family: var(--serif); font-size: clamp(2.2rem, 4.2vw, 3.5rem); font-weight: 400;
  line-height: 1.06; margin-bottom: 1rem; letter-spacing: -0.01em;
}
.landing-lead {
  color: rgba(255,255,255,0.76); font-size: 1rem; line-height: 1.6;
  margin-bottom: 2rem; max-width: 26rem;
}
.landing-cta { display: flex; gap: 0.75rem; flex-wrap: wrap; position: relative; z-index: 1; }
.landing-visual {
  display: flex; align-items: center; justify-content: center;
  padding: clamp(1.25rem, 3vw, 2.5rem);
  background:
    radial-gradient(circle at 70% 30%, rgba(232, 242, 247, 0.9) 0%, transparent 50%),
    linear-gradient(180deg, #eef4f8 0%, var(--bg) 100%);
  overflow: hidden;
  min-height: 0;
}
.landing-visual-inner {
  width: 100%; max-width: 720px;
  display: flex; flex-direction: column;
  justify-content: center;
  max-height: calc(100vh - 60px - 2.5rem);
}
.landing-visual-frame {
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 18px;
  padding: clamp(0.65rem, 1.5vw, 1rem);
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(100vh - 60px - 7rem);
}
.landing-visual-frame img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 60px - 9rem);
  object-fit: contain;
  border-radius: 12px;
}
.landing-caption {
  flex-shrink: 0;
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: var(--text-3);
  line-height: 1.5;
  text-align: center;
  padding: 0 0.5rem;
}

.btn-lg { padding: 0.75rem 1.5rem; font-size: 0.9rem; border-radius: 10px; }
.btn-outline {
  background: rgba(255,255,255,0.06); color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  backdrop-filter: blur(4px);
}
.btn-outline:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.7); }
.topbar-nav [data-open-auth].hidden { display: none !important; }
.topbar-link-api {
  font-size: 0.78rem; color: var(--text-3); text-decoration: none;
  padding: 0.4rem 0.65rem; border-radius: 8px;
}
.topbar-link-api:hover { color: var(--accent); background: var(--accent-light); }

#view-dashboard {
  padding: 0; max-width: none; width: 100%;
  display: flex; flex-direction: column; min-height: calc(100vh - 60px);
}
.dashboard-layout {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
}
.dashboard-main {
  flex: 1; padding: 2rem; max-width: 1400px; margin: 0 auto; width: 100%;
  overflow-y: auto;
}
.dashboard-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.dashboard-eyebrow {
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--text-3); margin-bottom: 0.35rem;
}
.dashboard-header h2 { font-family: var(--serif); font-size: 1.85rem; font-weight: 400; }
.dashboard-header .muted { font-size: 0.85rem; margin-top: 0.25rem; max-width: 36rem; }

.dashboard-directory {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, #f8fafc 0%, var(--surface) 100%);
  padding: 1rem 1.5rem 1.25rem;
  box-shadow: 0 -8px 24px rgba(15, 45, 61, 0.04);
}
.directory-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; margin-bottom: 0.85rem; flex-wrap: wrap;
  max-width: 1400px; margin-left: auto; margin-right: auto;
}
.directory-header h3 { font-size: 0.95rem; font-weight: 600; }
.directory-header .muted { font-size: 0.78rem; margin-top: 0.15rem; }
.directory-search {
  display: flex; gap: 0.5rem; align-items: center; flex: 1; max-width: 420px;
}
.directory-search input {
  flex: 1; padding: 0.55rem 0.85rem; border: 1px solid var(--border);
  border-radius: 10px; font-family: var(--font); font-size: 0.85rem;
  background: var(--surface);
}
.directory-search input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 77, 107, 0.1);
}
.projects-strip-wrap {
  max-width: 1400px; margin: 0 auto;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 0.35rem;
  scrollbar-width: thin;
}
.projects-strip {
  display: flex; gap: 0.75rem; min-width: min-content; padding: 0.15rem 0.1rem;
}
.project-strip-card {
  flex: 0 0 220px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  box-shadow: var(--shadow-sm);
  font-family: var(--font);
}
.project-strip-card:hover {
  border-color: #c5d5e3; box-shadow: var(--shadow-md); transform: translateY(-1px);
}
.strip-name {
  display: block; font-size: 0.88rem; font-weight: 600;
  color: var(--text); margin-bottom: 0.25rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.strip-meta, .strip-pm {
  display: block; font-size: 0.72rem; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.strip-phase {
  display: inline-block; margin-top: 0.55rem;
  font-size: 0.62rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 0.18rem 0.45rem;
  background: var(--accent-light); color: var(--accent); border-radius: 99px;
}
.strip-empty {
  font-size: 0.82rem; color: var(--text-3); padding: 0.75rem 0.25rem;
}

.modal { z-index: 200; }
.auth-load-banner {
  background: #7f1d1d; color: #fff; text-align: center; padding: 0.6rem 1rem;
  font-size: 0.8rem; z-index: 300; position: relative;
}
.auth-load-banner.hidden { display: none; }

@media (max-width: 900px) {
  .landing-shell {
    grid-template-columns: 1fr;
    max-height: none;
    min-height: auto;
  }
  .landing-copy { min-height: auto; padding: 2.5rem 1.5rem; }
  .landing-visual {
    padding: 1.25rem 1.5rem 2rem;
    max-height: none;
  }
  .landing-visual-inner { max-height: none; }
  .landing-visual-frame,
  .landing-visual-frame img {
    max-height: min(52vh, 480px);
  }
}

.projects-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem; margin-bottom: 2.5rem;
}
.project-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
  box-shadow: var(--shadow-sm);
}
.project-card:hover, .project-card:focus-visible {
  box-shadow: var(--shadow-md); border-color: #c5d5e3; transform: translateY(-2px);
  outline: none;
}
.project-card-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 0.35rem;
}
.project-card h3 { font-size: 1rem; line-height: 1.3; flex: 1; }
.project-card .code { font-size: 0.75rem; color: var(--text-3); }
.project-pm {
  margin-top: 0.5rem; font-size: 0.78rem; color: var(--accent); font-weight: 500;
}
.project-card .phase-badge {
  flex-shrink: 0;
  font-size: 0.65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; padding: 0.2rem 0.5rem;
  background: var(--accent-light); color: var(--accent); border-radius: 99px;
}
.project-card .stats { margin-top: 0.75rem; font-size: 0.75rem; color: var(--text-3); }

.reference-card {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem;
}
.reference-card img { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.reference-card h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.reference-card p { font-size: 0.85rem; color: var(--text-2); margin-bottom: 0.5rem; }
.reference-card .muted { color: var(--text-3); font-size: 0.8rem; }

.empty-card {
  grid-column: 1 / -1; text-align: center; padding: 3rem; color: var(--text-3);
  border: 2px dashed var(--border); border-radius: var(--radius);
}

/* Workspace */
#view-workspace { display: flex; flex-direction: row; padding: 0; max-width: none; height: calc(100vh - 60px); }

.workspace-sidebar {
  width: 260px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); padding: 1rem; display: flex; flex-direction: column; gap: 1rem;
}
.phase-card label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.phase-card select {
  width: 100%; margin-top: 0.35rem; padding: 0.5rem; border: 1px solid var(--border);
  border-radius: 8px; font-family: var(--font); font-size: 0.8rem;
}
.workspace-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item {
  text-align: left; padding: 0.6rem 0.75rem; border: none; background: none;
  border-radius: 8px; font-family: var(--font); font-size: 0.8rem; cursor: pointer; color: var(--text-2);
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.shared-mini { margin-top: auto; font-size: 0.75rem; color: var(--text-3); padding-top: 1rem; border-top: 1px solid var(--border); }
.shared-mini strong { display: block; color: var(--text); font-size: 0.8rem; }

.workspace-main { flex: 1; overflow-y: auto; padding: 1.5rem; }

/* Project workspace dashboard */
.project-dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.dash-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 220px;
}
.dash-widget.span-2 { grid-column: span 2; }
.dash-widget-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.dash-widget-header h3 {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 400;
  margin: 0;
}
.dash-widget-header p {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--text-3);
}
.dash-count {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.dash-link {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0;
  white-space: nowrap;
}
.dash-link:hover { text-decoration: underline; }
.dash-empty {
  font-size: 0.8rem;
  color: var(--text-3);
  font-style: italic;
  padding: 0.5rem 0;
}
.dash-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}
.dash-mini-table th {
  text-align: left;
  color: var(--text-3);
  font-weight: 600;
  padding: 0.35rem 0.5rem 0.35rem 0;
  border-bottom: 1px solid var(--border);
}
.dash-mini-table td {
  padding: 0.4rem 0.5rem 0.4rem 0;
  border-bottom: 1px solid var(--bg);
  vertical-align: top;
}
.dash-mini-table tr:last-child td { border-bottom: none; }
.dash-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
}
.dash-badge.warn { background: #fef3c7; color: #b45309; }
.dash-badge.danger { background: #fee2e2; color: #b91c1c; }
.dash-badge.ok { background: var(--success-bg); color: var(--success); }

.dash-phase-timeline { margin-top: 0.35rem; }
.dash-phase-bar-wrap {
  position: relative;
  padding: 1.35rem 0 0.5rem;
}
.dash-phase-bar {
  display: flex;
  height: 2.4rem;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.dash-phase-segment {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--phase-color);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-right: 1px solid rgba(255, 255, 255, 0.28);
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}
.dash-phase-segment:last-child { border-right: none; }
.dash-phase-segment.is-current {
  filter: brightness(1.08) saturate(1.1);
  box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.85);
  z-index: 1;
}
.dash-phase-segment-label {
  padding: 0 0.15rem;
  text-align: center;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.dash-today-marker {
  position: absolute;
  top: 0;
  bottom: 0.25rem;
  width: 0;
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
}
.dash-today-pin {
  display: block;
  width: 3px;
  height: calc(100% - 0.5rem);
  margin: 0.35rem auto 0;
  background: #0f172a;
  border-radius: 2px;
  box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(15, 23, 42, 0.35);
}
.dash-today-label {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0f172a;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}
.dash-phase-dates {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.45rem;
}
.dash-phase-date-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dash-phase-date-label {
  display: block;
  width: 100%;
  font-size: 0.62rem;
  padding: 0.28rem 0.15rem;
  text-align: center;
  color: var(--muted, #94a3b8);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-phase-date-label.is-set {
  color: var(--text);
  font-weight: 500;
}
.dash-phase-hint {
  font-size: 0.68rem;
  margin: 0.5rem 0 0;
  line-height: 1.4;
}
.dash-milestone-strip {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.dash-milestone-strip-title {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.45rem;
}
.dash-milestone-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.dash-milestone-chip {
  font-size: 0.68rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid transparent;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-milestone-chip.critical {
  background: #fee2e2;
  color: #b91c1c;
}

.dash-budget-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.dash-budget-stat {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}
.dash-budget-stat label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.dash-budget-stat strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.95rem;
}
.dash-budget-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.25rem;
}
.dash-budget-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.dash-budget-fill.over { background: linear-gradient(90deg, #f59e0b, var(--danger)); }

@media (max-width: 960px) {
  .project-dashboard { grid-template-columns: 1fr; }
  .dash-phase-dates { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-phase-bar { min-width: 520px; }
  .dash-phase-bar-wrap { overflow-x: auto; }
  .dash-widget.span-2 { grid-column: span 1; }
  .dash-budget-stats { grid-template-columns: 1fr; }
}

.panel-header { margin-bottom: 1.25rem; }
.panel-header h2 { font-family: var(--serif); font-size: 1.75rem; font-weight: 400; }
.panel-header p { color: var(--text-2); font-size: 0.85rem; }

/* Forms */
.shared-form, .tool-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.span-2 { grid-column: span 2; }
.form-group label { font-size: 0.75rem; font-weight: 600; color: var(--text-2); }
.form-group label .shared-icon { color: var(--accent); margin-left: 0.25rem; }
.form-group input, .form-group textarea, .form-group select {
  padding: 0.5rem 0.65rem; border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font); font-size: 0.85rem;
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-actions { margin-top: 1rem; }
.person-group { background: var(--bg); padding: 0.75rem; border-radius: 8px; border: 1px solid var(--border); }
.list-editor { display: flex; flex-direction: column; gap: 0.5rem; }
.list-row { display: flex; gap: 0.5rem; }
.list-row input { flex: 1; }
.list-row button { padding: 0.35rem 0.6rem; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; cursor: pointer; font-size: 0.75rem; }
.btn-add { align-self: flex-start; font-size: 0.75rem; padding: 0.35rem 0.75rem; border: 1px dashed var(--border); background: none; border-radius: 6px; cursor: pointer; color: var(--accent); }

/* Tool map */
.map-legend { display: flex; gap: 1.25rem; margin-bottom: 1rem; font-size: 0.75rem; color: var(--text-2); }
.map-legend span { display: flex; align-items: center; gap: 0.35rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.accessible { background: var(--bubble); }
.dot.activating { background: var(--success); box-shadow: 0 0 0 2px var(--success-bg); }
.dot.locked { background: #cbd5e1; }
.dot.complete { background: var(--success); }

.tool-map {
  display: grid;
  grid-template-columns: 140px repeat(9, 1fr);
  grid-template-rows: auto repeat(8, minmax(72px, auto));
  gap: 2px; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; font-size: 0.7rem;
}
.map-corner { background: #e8f0f5; }
.map-phase-header {
  background: #d4e8f2; padding: 0.5rem 0.25rem; text-align: center; font-weight: 600;
  font-size: 0.65rem; color: var(--accent); line-height: 1.2;
}
.map-phase-header.current { background: var(--accent); color: #fff; }
.map-cat-label {
  background: #d4e8f2; padding: 0.5rem; font-weight: 600; font-size: 0.65rem;
  color: var(--accent); display: flex; align-items: center;
}
.map-cell {
  background: var(--map-cell); padding: 0.35rem; display: flex; flex-wrap: wrap;
  gap: 4px; align-content: flex-start; min-height: 72px; position: relative;
}
.map-cell.current-phase { background: #f0f9ff; }

.tool-bubble {
  width: 28px; height: 28px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--bubble-light); color: #fff; font-size: 0.6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; transition: transform 0.1s;
  position: relative;
}
.tool-bubble:hover { transform: scale(1.15); z-index: 2; }
.tool-bubble.accessible { background: var(--bubble); }
.tool-bubble.activating { box-shadow: 0 0 0 2px var(--success); }
.tool-bubble.dropping { box-shadow: 0 0 0 2px var(--danger); }
.tool-bubble.locked { background: #cbd5e1; cursor: not-allowed; opacity: 0.6; }
.tool-bubble.complete { background: var(--success); }
.tool-bubble.large { width: 34px; height: 34px; font-size: 0.65rem; }

.tool-bubble[data-tip] { position: relative; }
.tool-bubble[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; font-size: 0.65rem; font-weight: 500;
  padding: 0.35rem 0.55rem; border-radius: 6px; white-space: normal;
  text-align: center; line-height: 1.3; max-width: 240px; min-width: 120px;
  z-index: 20; pointer-events: none; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.tool-bubble[data-tip]:hover::before {
  content: ""; position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%);
  border: 4px solid transparent; border-top-color: var(--text); z-index: 20;
}

/* Tools list */
.search-input {
  margin-top: 0.75rem; width: 100%; max-width: 320px; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: 8px; font-family: var(--font);
}
.tools-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.tool-list-item {
  display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: border-color 0.15s;
}
.tool-list-item:hover { border-color: #c5d5e3; }
.tool-list-item.locked { opacity: 0.55; }
.tool-list-item .num {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-light);
  color: var(--accent); font-weight: 700; font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tool-list-item .info { flex: 1; }
.tool-list-item .info h4 { font-size: 0.85rem; }
.tool-list-item .info span { font-size: 0.7rem; color: var(--text-3); }
.tool-list-item .status-tag {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
  padding: 0.2rem 0.5rem; border-radius: 99px; background: var(--bg);
}

/* Drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 80;
}
.drawer {
  position: fixed; top: 0; right: 0;
  width: min(92vw, 1280px);
  min-width: 360px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface); z-index: 90; display: flex; flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
}
.drawer-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 1.25rem; border-bottom: 1px solid var(--border);
}
.drawer-title-row { display: flex; gap: 0.5rem; align-items: flex-start; flex: 1; min-width: 0; }
.drawer-title-wrap { flex: 1; min-width: 0; }
.drawer-title-line { display: flex; align-items: center; gap: 0.5rem; }
.tool-number { font-size: 0.7rem; font-weight: 600; color: var(--accent); display: block; margin-bottom: 0.25rem; }
.drawer-header h2 { font-size: 1.1rem; margin: 0; line-height: 1.3; }
.drawer-header p { font-size: 0.75rem; color: var(--text-3); margin-top: 0.25rem; }
.btn-info {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--accent);
  background: var(--accent-light); color: var(--accent); font-size: 0.7rem; font-weight: 700;
  font-style: italic; font-family: Georgia, serif; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; line-height: 1;
  transition: background 0.15s, transform 0.15s;
}
.btn-info:hover, .btn-info.active { background: var(--accent); color: #fff; }
.btn-copilot {
  flex-shrink: 0;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  border: 1.5px solid #7c3aed;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  color: #6d28d9;
  font-size: 0.62rem;
  font-weight: 800;
  font-style: normal;
  font-family: var(--font);
  letter-spacing: 0.04em;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.btn-copilot:hover, .btn-copilot.active {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #fff;
  transform: scale(1.05);
}
.drawer-content {
  flex: 1; display: flex; min-height: 0; overflow: hidden; position: relative;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 1.25rem; min-width: 0; }

/* AI Copilot panel */
.drawer-copilot {
  width: 340px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, #f8fbfd 0%, var(--surface) 100%);
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: width 0.2s ease, opacity 0.2s ease;
}
.drawer-copilot.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  overflow: hidden;
  border-left: none;
  padding: 0;
  pointer-events: none;
}
.copilot-expand-tab {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  width: 2rem;
  padding: 0.65rem 0.35rem;
  border: 1px solid #c4b5fd;
  border-right: none;
  border-radius: 10px 0 0 10px;
  background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%);
  color: #6d28d9;
  cursor: pointer;
  box-shadow: -2px 0 10px rgba(109, 40, 217, 0.12);
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.copilot-expand-tab:hover,
.copilot-expand-tab:focus-visible {
  background: linear-gradient(180deg, #7c3aed 0%, #6d28d9 100%);
  color: #fff;
  outline: none;
}
.copilot-expand-tab-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
}
.copilot-expand-tab-icon {
  font-size: 0.95rem;
  line-height: 1;
  font-weight: 700;
}
.copilot-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.copilot-header h3 {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 400;
  margin: 0;
}
.copilot-tool-label {
  font-size: 0.68rem;
  color: var(--text-3);
  margin: 0.2rem 0 0;
  line-height: 1.3;
}
.copilot-header-actions { display: flex; gap: 0.15rem; }
.copilot-disclaimer {
  font-size: 0.62rem;
  color: var(--warn);
  background: var(--warn-bg);
  margin: 0;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid #f5dfc0;
  line-height: 1.4;
}
.copilot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.copilot-placeholder {
  font-size: 0.75rem;
  color: var(--text-3);
  font-style: italic;
  margin: 0;
  line-height: 1.5;
}
.copilot-msg { display: flex; }
.copilot-msg-user { justify-content: flex-end; }
.copilot-msg-assistant { justify-content: flex-start; }
.copilot-bubble {
  max-width: 92%;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.55;
  word-break: break-word;
}
.copilot-msg-user .copilot-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.copilot-msg-assistant .copilot-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 3px;
}
.copilot-status {
  font-size: 0.68rem;
  color: var(--text-3);
  padding: 0 1rem 0.25rem;
  margin: 0;
  min-height: 1rem;
}
.copilot-status.error { color: var(--danger); }
.copilot-compose {
  padding: 0.65rem 1rem 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.copilot-compose-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.copilot-suggestions {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border);
}
.copilot-suggestions-title {
  margin: 0 0 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6d28d9;
}
.copilot-suggestion-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 0.55rem;
  cursor: pointer;
}
.copilot-suggestion-row input { margin-top: 0.2rem; flex-shrink: 0; }
.copilot-suggestion-body { min-width: 0; flex: 1; }
.copilot-suggestion-body strong {
  display: block;
  font-size: 0.76rem;
  color: var(--text);
}
.copilot-suggestion-key {
  display: block;
  font-size: 0.62rem;
  color: var(--text-3);
  margin-top: 0.1rem;
}
.copilot-suggestion-reason {
  margin: 0.2rem 0 0;
  font-size: 0.68rem;
  color: var(--text-2);
  line-height: 1.4;
}
.copilot-suggestion-preview {
  margin: 0.35rem 0 0;
  padding: 0.4rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.64rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow: auto;
}
.copilot-suggestions-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.35rem;
}
.copilot-suggestions-note,
.copilot-suggestions-done {
  margin: 0.45rem 0 0;
  font-size: 0.62rem;
  color: var(--text-3);
  line-height: 1.4;
}
.form-group.ai-field-updated {
  animation: ai-field-flash 2s ease;
}
@keyframes ai-field-flash {
  0% { box-shadow: 0 0 0 2px #c4b5fd; background: #f5f3ff; }
  100% { box-shadow: none; background: transparent; }
}
.copilot-compose textarea {
  width: 100%;
  resize: vertical;
  min-height: 52px;
  max-height: 120px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.8rem;
}
.drawer-copilot.loading .copilot-compose textarea,
.drawer-copilot.loading #copilot-send { opacity: 0.65; }
.tool-info-panel {
  background: linear-gradient(135deg, #f0f7fb 0%, var(--bg) 100%);
  border: 1px solid #c5dce8; border-radius: 10px; padding: 1rem; margin-bottom: 1rem;
}
.tool-info-panel section + section { margin-top: 0.875rem; padding-top: 0.875rem; border-top: 1px solid var(--border); }
.tool-info-panel h4 {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent); margin-bottom: 0.4rem;
}
.tool-info-panel p { font-size: 0.8rem; color: var(--text-2); line-height: 1.6; }
.info-related { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.info-related button {
  font-size: 0.7rem; padding: 0.3rem 0.6rem; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-family: var(--font); color: var(--accent);
}
.info-related button:hover { background: var(--accent-light); }
.phase-lock-banner {
  font-size: 0.78rem; padding: 0.65rem 0.85rem; border-radius: 8px; margin-bottom: 1rem;
  background: var(--warn-bg); color: var(--warn); border: 1px solid #f5dfc0;
}
.shared-hint { font-size: 0.75rem; color: var(--accent); margin-bottom: 1rem; display: flex; gap: 0.35rem; align-items: center; }
.attachments-section, .signatures-section {
  margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.attachments-section h4, .signatures-section h4 {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3); margin-bottom: 0.5rem;
}
.attachments-list, .signatures-list { font-size: 0.78rem; margin-bottom: 0.5rem; }
.attachment-item, .signature-item {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-light);
}
.attachment-item a { color: var(--accent); text-decoration: none; flex: 1; }
.attachment-item button, .attachment-item .btn-remove { font-size: 0.7rem; color: var(--danger); background: none; border: none; cursor: pointer; }
.attachment-upload { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.attachment-upload input[type=file] { font-size: 0.75rem; }
.attachment-upload input[type=text] { flex: 1; min-width: 120px; padding: 0.4rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.75rem; }
.signature-item { color: var(--text-2); }
.signature-item strong { color: var(--text); }

.struct-table-wrap { overflow-x: auto; margin-top: 0.35rem; }
.struct-table { width: 100%; border-collapse: collapse; font-size: 0.72rem; }
.struct-table th {
  background: var(--accent-light); color: var(--accent); font-weight: 600;
  padding: 0.4rem 0.35rem; text-align: left; white-space: nowrap;
}
.struct-table td { padding: 0.25rem; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.struct-table input { width: 100%; min-width: 60px; padding: 0.3rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.72rem; font-family: var(--font); }
.struct-table .tbl-rm { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.9rem; }

.drawer-footer {
  padding: 1rem 1.25rem; border-top: 1px solid var(--border);
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
}
.drawer-footer select { flex: 1; min-width: 100px; padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px; font-family: var(--font); font-size: 0.75rem; }
.sign-disclaimer {
  font-size: 0.78rem; color: var(--text-2); margin-bottom: 1rem; line-height: 1.55;
  padding: 0.75rem 0.9rem; background: var(--accent-light); border-radius: 10px;
  border: 1px solid #d4e8f2;
}
.modal-sign { max-width: 560px; width: 94%; }
.sign-field { margin-bottom: 0.85rem; }
.sign-field label {
  display: block; font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-3); margin-bottom: 0.35rem;
}
.sign-field input, .sign-field select {
  width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border);
  border-radius: 10px; font-family: var(--font); font-size: 0.85rem;
}
.sign-field input:focus, .sign-field select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30, 77, 107, 0.1);
}
.sign-fields-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
}
.sign-hint { font-size: 0.72rem; color: var(--text-3); margin-top: 0.35rem; line-height: 1.4; }
.sign-pad-block {
  margin: 1rem 0; padding: 0.85rem; border: 1px solid var(--border);
  border-radius: 12px; background: var(--bg);
}
.sign-pad-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem;
}
.sign-pad-header label {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-3);
}
#signature-pad {
  width: 100%; height: 140px; border-radius: 10px;
  border: 1.5px dashed #c5d5e3; background: #fff; touch-action: none; cursor: crosshair;
}
.sign-part11 {
  display: flex; gap: 0.65rem; align-items: flex-start;
  font-size: 0.78rem; color: var(--text-2); line-height: 1.5;
  margin: 1rem 0; padding: 0.75rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
}
.sign-part11 input { margin-top: 0.2rem; flex-shrink: 0; }
.signature-item {
  padding: 0.75rem 0; border-bottom: 1px solid var(--border);
}
.signature-item-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem;
}
.signature-role { font-size: 0.78rem; color: var(--text-2); font-weight: 400; }
.signature-meta { font-size: 0.72rem; color: var(--text-3); margin-top: 0.2rem; }
.signature-hash { font-size: 0.65rem; color: var(--text-3); display: block; margin-top: 0.35rem; }
.signature-thumb {
  max-width: 120px; max-height: 48px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; object-fit: contain;
}

.tool-version-bar {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin-bottom: 0.75rem; padding: 0.45rem 0;
}
.tool-version-badge {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.3rem 0.55rem; border-radius: 6px; background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.tool-version-badge.state-draft { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.tool-version-badge.state-in_review { background: #fef3c7; color: #92400e; border-color: #f5dfc0; }
.tool-version-badge.state-approved { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.tool-version-select {
  font-size: 0.75rem; padding: 0.25rem 0.45rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface);
}

.signature-freeze-banner {
  font-size: 0.78rem; padding: 0.7rem 0.9rem; border-radius: 8px; margin-bottom: 1rem;
  background: #fef3c7; color: #92400e; border: 1px solid #f5dfc0;
}
.signature-freeze-banner.approved {
  background: #ecfdf5; color: #047857; border-color: #a7f3d0;
}
.sig-workflow-hint, .sig-workflow-message {
  font-size: 0.78rem; color: var(--text-2); margin-bottom: 0.65rem; line-height: 1.45;
}
.sig-workflow-status {
  font-size: 0.78rem; font-weight: 600; margin-bottom: 0.5rem;
}
.sig-workflow-status.pending { color: var(--warn); }
.sig-workflow-status.complete { color: var(--success); }
.sig-assignee-list {
  list-style: none; margin: 0.5rem 0 0.75rem; padding: 0;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.sig-assignee-row {
  display: grid; grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem; padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border); font-size: 0.78rem;
}
.sig-assignee-row:last-child { border-bottom: none; }
.sig-assignee-row.signed { background: var(--success-bg); }
.sig-assignee-row.pending { background: var(--warn-bg); }
.sig-assignee-name { font-weight: 600; grid-column: 1; }
.sig-assignee-meta { color: var(--text-3); grid-column: 1; font-size: 0.72rem; }
.sig-assignee-status {
  grid-column: 2; grid-row: 1 / span 2; align-self: center;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
}
.sig-assignee-row.yours {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.sig-you-tag {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  color: var(--accent); margin-left: 0.35rem;
}
.sig-row-sign-btn {
  grid-column: 2; grid-row: 1 / span 3; align-self: center;
}
.sig-your-turn {
  margin: 0.65rem 0 0.75rem; padding: 0.75rem 0.85rem;
  border-radius: 10px; background: var(--accent-soft, #eff6ff);
  border: 1px solid var(--accent-border, #bfdbfe);
}
.sig-your-turn p { margin: 0 0 0.55rem; font-size: 0.8rem; line-height: 1.45; }
.sign-assigned-banner {
  margin: 0 0 0.85rem; padding: 0.65rem 0.75rem; border-radius: 8px;
  background: var(--warn-bg); border: 1px solid var(--warn-border, #fde68a);
  font-size: 0.78rem; line-height: 1.45;
}
.signature-workflow-actions {
  display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap;
}

.modal-sig-request { max-width: 560px; }
.sig-request-toolbar {
  display: flex; justify-content: space-between; align-items: center; margin: 0.75rem 0 0.5rem;
}
.sig-request-toolbar-actions {
  display: flex; gap: 0.35rem; flex-wrap: wrap;
}
.sig-request-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-3);
}
.sig-request-list {
  max-height: 280px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 12px;
}
.sig-request-row {
  display: grid; grid-template-columns: auto 1fr 130px; gap: 0.65rem;
  align-items: center; padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.sig-request-row:last-child { border-bottom: none; }
.sig-request-row:hover { background: var(--bg); }
.sig-request-person strong { display: block; font-size: 0.85rem; }
.sig-request-person span { display: block; font-size: 0.72rem; color: var(--text-3); }
.sig-request-email { font-size: 0.68rem !important; color: var(--accent) !important; }
.sig-request-meaning {
  padding: 0.4rem; border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font); font-size: 0.75rem;
}

.signature-inbox-panel {
  margin-bottom: 1.5rem; padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #fffbeb 0%, var(--surface) 100%);
  border: 1px solid #f5dfc0; border-radius: var(--radius);
}
.signature-inbox-header h3 { font-size: 1rem; margin-bottom: 0.2rem; }
.signature-inbox-list {
  display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 0.75rem;
}
.signature-inbox-card {
  text-align: left; flex: 1 1 220px; max-width: 320px;
  padding: 0.85rem 1rem; border-radius: 12px;
  border: 1px solid #f5dfc0; background: var(--surface);
  cursor: pointer; font-family: var(--font);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.signature-inbox-card:hover { box-shadow: var(--shadow-md); border-color: var(--warn); }
.inbox-tool { display: block; font-weight: 600; font-size: 0.88rem; }
.inbox-project { display: block; font-size: 0.75rem; color: var(--text-3); margin-top: 0.15rem; }
.inbox-meta { display: block; font-size: 0.72rem; color: var(--accent); margin-top: 0.35rem; }
.inbox-when { display: block; font-size: 0.68rem; color: var(--text-3); margin-top: 0.25rem; }
@media (max-width: 600px) {
  .sign-fields-grid { grid-template-columns: 1fr; }
}

/* Modal */
.modal {
  border: none; border-radius: 16px; padding: 1.5rem; max-width: 440px; width: 92%;
  box-shadow: var(--shadow-lg);
}
.modal::backdrop {
  background: rgba(15, 45, 61, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal h3 { margin-bottom: 1rem; }
.modal label { display: block; margin-bottom: 0.75rem; font-size: 0.8rem; font-weight: 500; }
.modal input, .modal textarea {
  display: block; width: 100%; margin-top: 0.35rem; padding: 0.5rem;
  border: 1px solid var(--border); border-radius: 8px; font-family: var(--font);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

.modal-project { max-width: 520px; }
.modal-subtitle {
  font-size: 0.82rem; color: var(--text-2); margin: -0.35rem 0 1.25rem;
  line-height: 1.5; padding: 0.65rem 0.85rem;
  background: var(--accent-light); border-radius: 10px; border: 1px solid #d4e8f2;
}
.modal-fieldset {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem; margin-bottom: 1rem;
}
.modal-fieldset legend {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-2); padding: 0 0.35rem;
}
.modal-fieldset .required { color: var(--danger); }

/* Auth modal — split layout */
.modal-auth {
  padding: 0; max-width: 860px; width: min(92vw, 860px);
  border-radius: 20px; overflow: hidden;
  background: var(--surface);
}
.modal-auth::backdrop {
  background: rgba(10, 28, 38, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.auth-modal-shell {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  min-height: 520px;
}
.auth-modal-brand {
  position: relative;
  padding: 2.5rem 2rem;
  background:
    radial-gradient(ellipse 90% 70% at 0% 0%, rgba(126, 184, 212, 0.22) 0%, transparent 55%),
    linear-gradient(165deg, var(--accent-deep) 0%, var(--accent) 100%);
  color: #fff;
  display: flex; flex-direction: column; justify-content: center;
  overflow: hidden;
}
.auth-brand-glow {
  position: absolute; width: 280px; height: 280px; border-radius: 50%;
  background: var(--accent-glow); filter: blur(60px);
  top: -80px; right: -60px; pointer-events: none;
}
.auth-brand-mark {
  width: 48px; height: 48px; border-radius: 14px;
  background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; letter-spacing: 0.04em;
  margin-bottom: 1.5rem; position: relative; z-index: 1;
}
.auth-modal-brand h4 {
  font-family: var(--serif); font-size: 1.75rem; font-weight: 400;
  margin-bottom: 0.5rem; position: relative; z-index: 1;
}
.auth-brand-tagline {
  font-size: 0.88rem; color: rgba(255,255,255,0.72);
  line-height: 1.5; margin-bottom: 2rem; position: relative; z-index: 1;
}
.auth-brand-list {
  list-style: none; display: flex; flex-direction: column; gap: 0.85rem;
  position: relative; z-index: 1;
}
.auth-brand-list li {
  font-size: 0.82rem; color: rgba(255,255,255,0.8);
  display: flex; align-items: center; gap: 0.65rem;
}
.auth-brand-list span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2rem; height: 2rem; border-radius: 8px;
  background: rgba(255,255,255,0.12); font-weight: 700; font-size: 0.8rem;
  border: 1px solid rgba(255,255,255,0.15);
}
.auth-modal-body {
  position: relative;
  padding: 2.25rem 2rem 2rem;
  display: flex; flex-direction: column;
}
.auth-modal-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-3); font-size: 1.35rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.auth-modal-close:hover {
  background: var(--bg); color: var(--text); border-color: #c5d5e3;
}
.auth-modal-header { margin-bottom: 1.5rem; padding-right: 2.5rem; }
.auth-modal-header h3 {
  font-family: var(--serif); font-size: 1.65rem; font-weight: 400;
  margin-bottom: 0.35rem; letter-spacing: -0.01em;
}
.auth-modal-subtitle {
  font-size: 0.88rem; color: var(--text-2); line-height: 1.5;
}
.auth-method-tabs {
  display: flex; gap: 0.35rem; padding: 0.3rem;
  background: var(--bg); border-radius: 12px; border: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.auth-method-tab {
  flex: 1; padding: 0.55rem 0.75rem; border: none; background: transparent;
  border-radius: 9px; font-family: var(--font); font-size: 0.82rem;
  font-weight: 500; color: var(--text-2); cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.auth-method-tab.active {
  background: var(--surface); color: var(--accent);
  box-shadow: var(--shadow-sm); font-weight: 600;
}
.auth-mode-switch {
  display: flex; gap: 0; margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  flex: none; padding: 0.55rem 0; margin-right: 1.25rem;
  border: none; background: none; border-radius: 0;
  font-family: var(--font); font-size: 0.82rem; font-weight: 500;
  color: var(--text-3); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.auth-tab:hover { color: var(--text-2); }
.auth-tab.active {
  color: var(--accent); font-weight: 600;
  border-bottom-color: var(--accent);
}
.auth-field { margin-bottom: 1rem; }
.auth-field label {
  display: block; margin-bottom: 0.4rem;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-3);
}
.auth-field input {
  display: block; width: 100%; padding: 0.72rem 0.9rem;
  border: 1px solid var(--border); border-radius: 11px;
  font-family: var(--font); font-size: 0.9rem; color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-field input::placeholder { color: #b8c5d4; }
.auth-field input:hover { border-color: #c5d5e3; }
.auth-field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 77, 107, 0.12);
}
.btn-auth-submit {
  width: 100%; margin-top: 0.5rem; padding: 0.8rem 1rem;
  font-size: 0.9rem; font-weight: 600; border-radius: 11px;
  letter-spacing: 0.01em;
}
.auth-phone-actions {
  display: flex; gap: 0.5rem; margin-top: 0.5rem;
}
.auth-phone-actions .btn-ghost { flex: 0 0 auto; }
.auth-phone-actions .btn-auth-submit { flex: 1; margin-top: 0; }

@media (max-width: 720px) {
  .auth-modal-shell { grid-template-columns: 1fr; min-height: auto; }
  .auth-modal-brand { display: none; }
  .auth-modal-body { padding: 1.75rem 1.25rem 1.5rem; }
  .auth-modal-header h3 { font-size: 1.4rem; }
}

.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; padding: 0.75rem 1.25rem;
  background: var(--text); color: #fff; border-radius: 8px; font-size: 0.8rem; z-index: 100;
}

/* URS decision tree (Tool 24) */
.urs-tree-panel {
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); padding: 1rem;
}
.urs-tree-panel.urs-tree-frozen {
  border-color: #c5d5e3;
  background: linear-gradient(180deg, #f8fafc 0%, var(--surface) 100%);
}
.urs-tree-header {
  display: grid; grid-template-columns: 1fr auto; gap: 1rem;
  margin-bottom: 0.75rem; align-items: start;
}
.urs-tree-stats {
  display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem;
  font-size: 0.82rem; color: var(--text-2); margin-bottom: 0.45rem;
}
.urs-tree-progress-bar {
  height: 8px; background: var(--border); border-radius: 4px; overflow: hidden;
}
.urs-tree-progress-fill {
  height: 100%; background: var(--accent); transition: width 0.25s ease;
}
.urs-tree-metric-cards { display: flex; gap: 0.5rem; }
.urs-metric-card {
  min-width: 72px; padding: 0.45rem 0.65rem; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; text-align: center;
}
.urs-metric-label {
  display: block; font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-3); margin-bottom: 0.15rem;
}
.urs-metric-value { font-size: 1.15rem; font-weight: 700; line-height: 1.1; }
.urs-metric-good { color: #15803d; }
.urs-metric-warn { color: #b91c1c; }
.urs-metric-critical { color: #92400e; }
.urs-tree-insight {
  font-size: 0.78rem; color: var(--text-2); line-height: 1.45;
  padding: 0.6rem 0.75rem; border-radius: 8px; margin-bottom: 0.75rem;
  background: #f0fdf4; border: 1px solid #bbf7d0;
}
.urs-tree-insight-alert {
  background: #fef3c7; border-color: #fcd34d; color: #92400e;
}
.urs-tree-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.5rem;
}
.urs-tree-toolbar-right { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.urs-tree-legend {
  display: flex; gap: 1rem; font-size: 0.75rem; color: var(--text-2);
}
.urs-tree-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.urs-status-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08); flex-shrink: 0;
}
.urs-status-dot.committed { background: #22c55e; }
.urs-status-dot.not-committed { background: #ef4444; }
.urs-tree-count { font-size: 0.82rem; color: var(--text-2); }
.urs-tree-hint {
  font-size: 0.75rem; color: var(--text-3); margin: 0 0 0.75rem;
  line-height: 1.45;
}
.urs-tree-root {
  max-height: 480px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0.75rem; background: #fff;
}
.urs-tree-row {
  display: flex; align-items: center; gap: 0.4rem;
  cursor: pointer; user-select: none;
}
.urs-tree-name { font-size: 0.85rem; color: var(--text); font-weight: 500; }
.urs-tree-name-open { color: var(--text-2); }
.urs-tree-branch-name { font-weight: 600; }
.urs-tree-chevron {
  border: none; background: none; padding: 0;
  font-size: 0.75rem; color: var(--text-3); cursor: pointer;
  width: 1rem; transition: transform 0.15s ease;
}
.urs-tree-chevron.open { transform: rotate(90deg); }
.urs-tree-branch-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.35rem 0.5rem; border-radius: 6px;
}
.urs-tree-branch-top .urs-tree-branch-head {
  margin-top: 0.65rem; background: var(--bg);
  border: 1px solid var(--border);
}
.urs-tree-branch-head:hover { background: var(--bg); }
.urs-branch-badges { display: flex; gap: 0.4rem; font-size: 0.72rem; }
.urs-branch-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.12rem 0.45rem; border-radius: 12px; border: 1px solid;
}
.urs-branch-badge.good { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }
.urs-branch-badge.bad { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.urs-tree-leaf {
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto;
  gap: 0.25rem 0.75rem; padding: 0.5rem 0.65rem; margin: 0.25rem 0;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  cursor: pointer;
}
.urs-tree-leaf:hover { background: var(--bg); }
.urs-tree-leaf-main {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  grid-column: 1;
}
.urs-tree-leaf-side {
  display: flex; align-items: center; gap: 0.65rem;
  grid-column: 2; grid-row: 1;
}
.urs-critical-badge {
  padding: 0.12rem 0.5rem; border-radius: 12px; font-size: 0.62rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-3);
  cursor: pointer;
}
.urs-critical-badge.active {
  border-color: #b45309; background: #fef3c7; color: #92400e;
}
.urs-tree-preview {
  font-size: 0.72rem; color: var(--text-3); margin: 0;
  line-height: 1.4; grid-column: 1 / -1;
}
.urs-tree-muted { opacity: 0.45; }
.urs-tree-muted .urs-tree-name { text-decoration: line-through; }
.urs-tree-children {
  border-left: 2px solid var(--border);
  margin-left: 0.5rem; padding-left: 0.35rem;
}
.urs-leaf-modal {
  border: none; border-radius: 12px; padding: 0; max-width: 520px; width: calc(100vw - 2rem);
  box-shadow: var(--shadow-lg);
}
.urs-leaf-modal::backdrop { background: rgba(15, 45, 61, 0.45); }
.urs-leaf-modal-accent { height: 6px; border-radius: 12px 12px 0 0; }
.urs-leaf-modal-accent.committed { background: #22c55e; }
.urs-leaf-modal-accent.not-committed { background: #ef4444; }
.urs-leaf-modal-body { padding: 1.25rem; }
.urs-leaf-modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 0.75rem; margin-bottom: 1rem;
}
.urs-leaf-modal-title { margin: 0; font-size: 1.1rem; }
.urs-leaf-modal-badge {
  display: inline-block; margin-top: 0.35rem; font-size: 0.65rem;
  padding: 0.15rem 0.45rem; border-radius: 4px; font-weight: 700;
  text-transform: uppercase; background: #fef3c7; color: #92400e;
}
.urs-leaf-modal-close {
  border: none; background: none; font-size: 1.1rem; color: var(--text-3); cursor: pointer;
}
.urs-leaf-modal-fields {
  display: flex; flex-direction: column; gap: 0.75rem;
}
.urs-leaf-modal-fields label {
  display: flex; flex-direction: column; gap: 0.3rem;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-3);
}
.urs-leaf-modal-fields input,
.urs-leaf-modal-fields textarea {
  font-size: 0.85rem; font-weight: 400; text-transform: none;
  letter-spacing: normal; color: var(--text);
}
.urs-leaf-modal-actions {
  display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem;
}
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.75rem; }

@media (max-width: 900px) {
  .urs-tree-header { grid-template-columns: 1fr; }
  .urs-tree-metric-cards { justify-content: flex-start; }
}

@media (max-width: 900px) {
  .reference-card { grid-template-columns: 1fr; }
  #view-workspace { flex-direction: column; height: auto; }
  .workspace-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .shared-form, .tool-form { grid-template-columns: 1fr; }
  .form-group.span-2 { grid-column: span 1; }
  .tool-map { overflow-x: auto; min-width: 800px; }
  .drawer { width: 100vw; min-width: 0; }
  .drawer-copilot { width: 100%; max-height: 42vh; border-left: none; border-top: 1px solid var(--border); }
  .drawer-content { flex-direction: column; }
}