:root {
  --bg: #f4f6f7;
  --border: #dbe2e5;
  --border-strong: #c3cdd2;
  --danger: #b42318;
  --danger-soft: #fde7e5;
  --ink: #101820;
  --muted: #687883;
  --muted-soft: #8b98a1;
  --panel: #ffffff;
  --panel-soft: #f9fbfb;
  --primary: #128277;
  --primary-dark: #0b5f58;
  --primary-soft: #e3f4f1;
  --sky: #2f67d8;
  --sky-soft: #e8effc;
  --warning: #b76e00;
  --warning-soft: #fff1d6;
  --purple: #6846b8;
  --purple-soft: #efe7fb;
  --rose: #b8325d;
  --rose-soft: #fde8ef;
  --shadow: 0 10px 30px rgba(16, 24, 32, 0.08);
  --shadow-soft: 0 6px 18px rgba(16, 24, 32, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  background:
    linear-gradient(180deg, #fbfcfc 0, var(--bg) 240px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.boot-screen {
  align-items: center;
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-screen {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 480px);
  min-height: 100vh;
}

.login-copy {
  align-content: space-between;
  background: linear-gradient(
      145deg,
      rgba(18, 130, 119, 0.94),
      rgba(47, 103, 216, 0.86)
    ),
    url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='rgba(255,255,255,0.24)' stroke-width='1'%3E%3Cpath d='M0 30h120M0 60h120M0 90h120M30 0v120M60 0v120M90 0v120'/%3E%3C/g%3E%3C/svg%3E");
  color: #fff;
  display: grid;
  padding: 42px;
}

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

.brand.large {
  align-self: start;
}

.brand-mark {
  align-items: center;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  color: var(--primary-dark);
  display: inline-flex;
  font-size: 13px;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  letter-spacing: 0;
  width: 42px;
}

.brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.brand span {
  color: rgba(255, 255, 255, 0.78);
  display: block;
  font-size: 13px;
  margin-top: 2px;
}

.sidebar .brand span {
  color: var(--muted);
}

.login-status {
  max-width: 560px;
}

.login-status h1 {
  font-size: 44px;
  line-height: 1.1;
  margin: 14px 0 16px;
}

.login-status p {
  color: rgba(255, 255, 255, 0.82);
  font-size: 16px;
  line-height: 1.7;
  margin: 0;
}

.login-panel {
  align-items: center;
  display: flex;
  padding: 40px;
}

.form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(16, 24, 32, 0.12);
  display: grid;
  gap: 18px;
  padding: 28px;
  width: 100%;
}

label {
  color: var(--ink);
  display: grid;
  font-size: 13px;
  font-weight: 800;
  gap: 8px;
}

input,
select,
textarea {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  min-height: 44px;
  padding: 0 12px;
  transition: background-color 0.16s ease, border-color 0.16s ease,
    box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: rgba(18, 130, 119, 0.54);
  box-shadow: 0 0 0 4px rgba(18, 130, 119, 0.12);
  outline: 0;
  outline-offset: 2px;
}

input[readonly] {
  background: #eef2f4;
  color: var(--muted);
}

textarea {
  line-height: 1.55;
  padding-bottom: 10px;
  padding-top: 10px;
  resize: vertical;
}

.optional-field,
.optional-name {
  display: none;
}

.primary-button,
.secondary-button,
.ghost-button,
.link-button,
.nav-button,
.segmented {
  border: 0;
  border-radius: 6px;
  min-height: 38px;
}

.primary-button {
  background: var(--primary);
  box-shadow: 0 8px 16px rgba(18, 130, 119, 0.18);
  color: #fff;
  font-weight: 850;
  padding: 0 16px;
  transition: background-color 0.16s ease, box-shadow 0.16s ease,
    transform 0.16s ease;
}

.primary-button:hover {
  background: var(--primary-dark);
  box-shadow: 0 10px 20px rgba(11, 95, 88, 0.22);
  transform: translateY(-1px);
}

.secondary-button {
  background: #eef4f6;
  color: var(--primary-dark);
  font-weight: 800;
  padding: 0 14px;
  transition: background-color 0.16s ease, color 0.16s ease,
    transform 0.16s ease;
}

.secondary-button:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
  transform: translateY(-1px);
}

.button-link {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: 38px;
  text-decoration: none;
}

.ghost-button {
  background: #edf2f4;
  color: var(--ink);
  font-weight: 800;
  margin-top: 14px;
  padding: 0 12px;
  width: 100%;
}

.link-button {
  background: transparent;
  color: var(--primary-dark);
  font-weight: 850;
  padding: 0;
  text-align: left;
}

.link-button:hover {
  color: var(--sky);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
  min-height: 18px;
}

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

.sidebar {
  background: rgba(255, 255, 255, 0.94);
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 28px rgba(16, 24, 32, 0.035);
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 100vh;
  padding: 24px 18px;
  position: sticky;
  top: 0;
}

.nav {
  align-content: start;
  align-self: start;
  display: grid;
  gap: 6px;
  margin-top: 34px;
}

.nav-button {
  align-items: center;
  align-self: start;
  background: transparent;
  color: var(--muted);
  display: flex;
  font-weight: 800;
  gap: 10px;
  justify-content: flex-start;
  padding: 0 12px;
  position: relative;
  transition: background-color 0.16s ease, color 0.16s ease,
    transform 0.16s ease;
  white-space: nowrap;
}

.nav-button.active,
.nav-button:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.nav-button.active::before {
  background: var(--primary);
  border-radius: 99px;
  content: '';
  height: 18px;
  left: 0;
  position: absolute;
  width: 3px;
}

.nav-dot {
  background: #b6c3c8;
  border-radius: 99px;
  display: inline-block;
  height: 7px;
  width: 7px;
}

.nav-button.active .nav-dot,
.nav-button:hover .nav-dot {
  background: var(--primary);
}

.session-panel {
  align-self: end;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 4px;
  padding-top: 18px;
}

.session-panel strong {
  font-size: 15px;
}

.session-panel span:last-of-type {
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  overflow-x: hidden;
  min-width: 0;
  padding: 30px;
}

.page-header {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-header h1 {
  font-size: 30px;
  line-height: 1.2;
  margin: 4px 0 0;
}

.eyebrow {
  color: var(--primary);
  display: inline-block;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

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

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(128px, 1fr));
  margin-bottom: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 10px;
  min-height: 96px;
  padding: 16px;
  position: relative;
}

.metric::before {
  background: var(--primary);
  border-radius: 8px 0 0 8px;
  content: '';
  inset: 0 auto 0 0;
  position: absolute;
  width: 4px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.metric.danger {
  background: var(--danger-soft);
  border-color: #f4b4ad;
}

.metric.danger::before {
  background: var(--danger);
}

.metric.warning {
  background: var(--warning-soft);
  border-color: #f3d18b;
}

.metric.warning::before {
  background: var(--warning);
}

.dashboard-grid,
.split-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.6fr) minmax(310px, 0.7fr);
}

.project-layout {
  align-items: start;
  grid-template-columns: minmax(0, 1fr) 360px;
}

.project-layout .data-table {
  min-width: 860px;
  table-layout: fixed;
}

.project-layout .data-table th:nth-child(1) {
  width: 300px;
}

.project-layout .data-table th:nth-child(2) {
  width: 130px;
}

.project-layout .data-table th:nth-child(6) {
  width: 122px;
}

.project-layout .data-table th:nth-child(8) {
  text-align: center;
  width: 58px;
}

.project-name-cell {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.project-name-cell .link-button {
  justify-self: start;
  line-height: 1.25;
  min-height: auto;
  overflow-wrap: anywhere;
  text-align: left;
}

.project-layout .detail-pane {
  max-height: calc(100vh - 56px);
  overflow: auto;
  position: sticky;
  top: 18px;
}

.panel,
.detail-pane,
.folder-tree,
.create-project {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.panel,
.detail-pane {
  min-width: 0;
  padding: 20px;
}

.panel.wide {
  overflow: auto;
}

.dashboard-grid .panel.wide {
  grid-row: span 2;
}

.panel-title {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-title.collapsible-title {
  margin-bottom: 0;
}

.panel-title-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.panel-title.compact {
  border-top: 1px solid var(--border);
  margin: 18px 0 8px;
  padding-top: 14px;
}

.panel-title h2,
.panel-title h3 {
  font-size: 16px;
  line-height: 1.2;
  margin: 0;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.collapse-toggle {
  align-items: center;
  background: #eef2f4;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  font-size: 18px;
  font-weight: 900;
  height: 32px;
  justify-content: center;
  line-height: 1;
  min-height: 32px;
  padding: 0;
  width: 32px;
}

.collapse-toggle:hover {
  background: #e2e8eb;
  color: var(--primary-dark);
}

.collapsible-body {
  margin-top: 14px;
  min-width: 0;
}

.collapsible-body[hidden] {
  display: none;
}

.data-table {
  align-self: start;
  border-collapse: collapse;
  min-width: 860px;
  table-layout: auto;
  width: 100%;
}

.data-table th {
  background: #f3f6f7;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  padding: 11px 10px;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  border-top: 1px solid var(--border);
  font-size: 13px;
  padding: 13px 10px;
  height: auto;
  vertical-align: middle;
}

.data-table input,
.data-table select {
  min-height: 36px;
}

.data-table input[readonly] {
  background: #eef2f4;
  color: var(--muted);
}

.data-table tr:hover td {
  background: #f8fbfb;
}

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

.muted-line {
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.badge,
.danger-badge {
  align-items: center;
  background: #eef2f4;
  border: 1px solid rgba(195, 205, 210, 0.74);
  border-radius: 999px;
  color: #42515a;
  display: inline-flex;
  gap: 6px;
  font-size: 12px;
  font-weight: 900;
  min-height: 24px;
  padding: 0 10px;
  white-space: nowrap;
}

.badge::before,
.danger-badge::before {
  background: currentColor;
  border-radius: 999px;
  content: '';
  height: 6px;
  opacity: 0.82;
  width: 6px;
}

.health-green {
  background: var(--primary-soft);
  border-color: rgba(18, 130, 119, 0.2);
  color: var(--primary-dark);
}

.health-yellow {
  background: var(--warning-soft);
  border-color: rgba(183, 110, 0, 0.2);
  color: var(--warning);
}

.health-red,
.danger-badge {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.2);
  color: var(--danger);
}

.health-gray {
  background: #eef2f4;
  border-color: rgba(104, 120, 131, 0.2);
  color: #53616b;
}

.status {
  background: var(--sky-soft);
  border-color: rgba(47, 103, 216, 0.2);
  color: #2455b8;
}

.status-draft {
  background: #eef2f4;
  border-color: rgba(104, 120, 131, 0.2);
  color: #53616b;
}

.status-reviewing,
.status-approved {
  background: var(--warning-soft);
  border-color: rgba(183, 110, 0, 0.22);
  color: var(--warning);
}

.status-active {
  background: var(--primary-soft);
  border-color: rgba(18, 130, 119, 0.22);
  color: var(--primary-dark);
}

.status-waiting_external,
.status-on_hold {
  background: var(--rose-soft);
  border-color: rgba(184, 50, 93, 0.22);
  color: var(--rose);
}

.status-finalizing {
  background: var(--sky-soft);
  border-color: rgba(47, 103, 216, 0.22);
  color: #2455b8;
}

.status-completed,
.status-archive_pending,
.status-archived {
  background: var(--purple-soft);
  border-color: rgba(104, 70, 184, 0.22);
  color: var(--purple);
}

.status-cancelled,
.status-failed {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.22);
  color: var(--danger);
}

.security {
  background: #edf1f2;
  border-color: rgba(104, 120, 131, 0.18);
  color: #35424b;
}

.phase-chip {
  min-width: 76px;
  justify-content: center;
}

.phase-contract {
  background: #fff0df;
  border-color: rgba(194, 105, 38, 0.24);
  color: #a45316;
}

.phase-progress {
  background: #dff3f7;
  border-color: rgba(30, 118, 138, 0.24);
  color: #166574;
}

.phase-done {
  background: var(--purple-soft);
  border-color: rgba(104, 70, 184, 0.24);
  color: var(--purple);
}

.phase-discuss {
  background: #eef2f4;
  border-color: rgba(104, 120, 131, 0.22);
  color: #2f3d45;
}

.phase-default {
  background: var(--sky-soft);
  border-color: rgba(47, 103, 216, 0.2);
  color: #2455b8;
}

.progress {
  background: #dfe7ea;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  width: 110px;
}

.progress span {
  background: linear-gradient(90deg, var(--primary), var(--sky));
  border-radius: inherit;
  display: block;
  height: 100%;
}

.expand-cell {
  width: 44px;
}

.expand-button {
  align-items: center;
  background: #eef2f4;
  border: 0;
  border-radius: 6px;
  color: var(--primary-dark);
  display: inline-flex;
  font-size: 18px;
  font-weight: 900;
  height: 32px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: transform 160ms ease, background-color 160ms ease;
  width: 32px;
}

.expand-button.open {
  background: var(--primary-soft);
  transform: rotate(180deg);
}

.process-expand-row td {
  background: #f8fafb;
  padding: 0 10px 14px;
}

.data-table tr.process-expand-row:hover td {
  background: #f8fafb;
}

.process-editor {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.process-editor-header,
.process-summary,
.process-create-form {
  align-items: center;
  display: flex;
  gap: 10px;
}

.process-editor-header {
  justify-content: space-between;
}

.process-editor-header strong {
  display: block;
  font-size: 15px;
  margin-top: 2px;
}

.process-summary span {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  min-height: 30px;
  padding: 6px 10px;
}

.process-create-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.process-create-form input {
  flex: 1;
  min-width: 220px;
}

.process-create-form select {
  min-width: 120px;
}

.process-table {
  border-collapse: collapse;
  min-width: 680px;
  width: 100%;
}

.process-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  padding: 7px 8px;
  text-align: left;
}

.process-table td {
  border-top: 1px solid var(--border);
  font-size: 13px;
  padding: 8px;
}

small {
  color: var(--muted);
  display: inline-block;
  font-size: 12px;
  margin-top: 4px;
}

.timeline-list,
.risk-list,
.compact-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-list li,
.risk-list li,
.compact-list li {
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
}

.timeline-list li:last-child,
.risk-list li:last-child,
.compact-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.timeline-list time,
.timeline-list span,
.risk-list span,
.compact-list span {
  color: var(--muted);
  font-size: 12px;
}

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

.create-project {
  margin-bottom: 16px;
  padding: 14px;
}

.hidden {
  display: none !important;
}

.project-form {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1.4fr 1fr 1fr 0.8fr 0.8fr 0.8fr auto;
}

.project-form input,
.project-form select {
  min-width: 0;
}

.task-create-form {
  grid-template-columns: minmax(190px, 1fr) minmax(220px, 1.4fr) minmax(
      160px,
      0.9fr
    ) minmax(140px, 0.8fr) minmax(110px, 0.7fr) 94px 150px auto;
}

.task-table {
  min-width: 1120px;
}

.task-table th:nth-child(1) {
  width: 230px;
}

.personnel-create-form {
  grid-template-columns: minmax(120px, 0.7fr) minmax(130px, 0.8fr) minmax(
      150px,
      0.9fr
    ) minmax(110px, 0.7fr) minmax(110px, 0.7fr) 96px minmax(170px, 1fr) auto;
}

.edit-form {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
}

.edit-form .panel-title.compact {
  border-top: 0;
  margin: 0;
  padding-top: 0;
}

.form-grid {
  display: grid;
  gap: 10px;
}

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

.table-input {
  font-size: 13px;
  min-width: 128px;
  width: 100%;
}

.compact-input {
  min-width: 72px;
  text-align: right;
}

.table-save {
  min-width: 58px;
  white-space: nowrap;
}

.stacked-input {
  margin-top: 6px;
}

.detail-pane {
  align-self: start;
}

.detail-pane h2 {
  font-size: 20px;
  line-height: 1.25;
  margin: 6px 0 12px;
  overflow-wrap: anywhere;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.definition-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.definition-list div {
  display: grid;
  gap: 2px;
  grid-template-columns: 82px 1fr;
}

.definition-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.definition-list dd {
  font-size: 13px;
  margin: 0;
}

.toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.calendar-controls {
  align-items: center;
  display: flex;
  gap: 10px;
}

.calendar-controls strong {
  font-size: 14px;
  min-width: 112px;
  text-align: center;
}

.calendar-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 360px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(108px, 1fr));
}

.calendar-weekdays {
  background: #f3f6f7;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  overflow: hidden;
}

.calendar-weekdays span {
  padding: 10px;
}

.calendar-grid {
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

.calendar-day {
  background: #fff;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 132px;
  padding: 8px;
}

.calendar-day.empty {
  background: #f8fafb;
}

.calendar-day time {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 6px;
}

.calendar-day-events {
  display: grid;
  gap: 5px;
}

.calendar-event {
  background: #eef2f4;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  display: grid;
  gap: 2px;
  min-height: 42px;
  padding: 6px 8px;
  text-align: left;
  width: 100%;
}

.calendar-event strong {
  font-size: 12px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.calendar-event span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}

.calendar-event.deadline {
  background: var(--danger-soft);
  border-color: #f4b4ad;
  color: var(--danger);
}

.calendar-event.process {
  background: var(--primary-soft);
  border-color: rgba(17, 94, 89, 0.18);
  color: var(--primary-dark);
}

.calendar-event.start {
  background: #edf1f2;
  border-color: rgba(104, 120, 131, 0.14);
}

.calendar-event.task {
  background: var(--sky-soft);
  border-color: rgba(47, 103, 216, 0.16);
  color: #2455b8;
}

.more-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.calendar-summary {
  max-height: calc(100vh - 56px);
  overflow: auto;
  position: sticky;
  top: 18px;
}

.calendar-agenda {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.calendar-agenda li {
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 5px;
  padding-bottom: 10px;
}

.calendar-agenda time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.segmented {
  background: #eef2f4;
  border: 1px solid transparent;
  color: var(--muted);
  font-weight: 850;
  padding: 0 14px;
  transition: background-color 0.16s ease, border-color 0.16s ease,
    color 0.16s ease;
}

.segmented.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 8px 18px rgba(18, 130, 119, 0.18);
  color: #fff;
}

.segmented:hover:not(.active) {
  background: var(--primary-soft);
  border-color: rgba(18, 130, 119, 0.18);
  color: var(--primary-dark);
}

.file-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: 230px minmax(0, 1fr);
}

.analytics-filter-panel {
  margin-bottom: 16px;
}

.analytics-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.analytics-add-panel {
  margin-bottom: 16px;
}

.analytics-filter-form,
.analytics-source-form {
  align-items: end;
  display: grid;
  gap: 10px;
}

.analytics-filter-form {
  grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
}

.analytics-source-form {
  grid-template-columns: minmax(190px, 0.8fr) minmax(190px, 0.8fr) minmax(
      280px,
      1.2fr
    ) auto;
}

.analytics-source-form label {
  min-width: 0;
}

.analytics-source-form input {
  min-width: 0;
  width: 100%;
}

.analytics-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  margin: 10px 0 0;
}

.analytics-metrics {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.analytics-filter-form label,
.analytics-source-detail-form label {
  min-width: 0;
}

.analytics-filter-form input,
.analytics-filter-form select,
.analytics-source-detail-form input {
  min-width: 0;
  width: 100%;
}

.analytics-dashboard-grid {
  margin-bottom: 16px;
}

.analytics-trend-list {
  display: grid;
  gap: 10px;
  min-width: 620px;
}

.analytics-trend-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 96px minmax(180px, 1fr) 72px 150px;
}

.analytics-trend-row time,
.analytics-trend-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.analytics-trend-row strong {
  font-size: 13px;
  text-align: right;
}

.analytics-trend-bar {
  background: #e2e8eb;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.analytics-trend-bar span {
  background: linear-gradient(90deg, var(--primary), var(--sky));
  border-radius: inherit;
  display: block;
  height: 100%;
}

.analytics-live-list div {
  grid-template-columns: 92px 1fr;
}

.analytics-source-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.analytics-source-list li {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding-bottom: 10px;
}

.analytics-source-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.analytics-source-list strong,
.analytics-source-list span,
.analytics-source-list time {
  display: block;
}

.analytics-source-list span,
.analytics-source-list time {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.analytics-source-list time {
  grid-column: 1 / -1;
}

.analytics-source-open {
  background: transparent;
  border: 0;
  color: var(--ink);
  display: grid;
  gap: 3px;
  justify-items: start;
  min-height: auto;
  padding: 0;
  text-align: left;
}

.analytics-source-open:hover strong {
  color: var(--primary-dark);
  text-decoration: underline;
}

.analytics-health-healthy {
  background: var(--primary-soft);
  border-color: rgba(18, 130, 119, 0.2);
  color: var(--primary-dark);
}

.analytics-health-delayed,
.analytics-health-no_data {
  background: var(--warning-soft);
  border-color: rgba(183, 110, 0, 0.2);
  color: var(--warning);
}

.analytics-health-stopped {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.2);
  color: var(--danger);
}

.analytics-health-inactive {
  background: #eef2f4;
  border-color: rgba(104, 120, 131, 0.2);
  color: #53616b;
}

.analytics-detail-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  margin-bottom: 16px;
}

.analytics-source-overview {
  margin-bottom: 16px;
}

.analytics-table {
  min-width: 720px;
}

.zep-map-table {
  min-width: 960px;
}

.modal-panel.analytics-source-modal {
  overflow-x: hidden;
  width: min(960px, calc(100vw - 44px));
}

.modal-panel.analytics-source-modal h2 {
  margin-bottom: 16px;
}

.analytics-source-detail-form {
  align-items: end;
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(160px, 220px)) auto;
  margin-bottom: 16px;
  padding-bottom: 16px;
}

.source-stat-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  margin-bottom: 16px;
}

.source-stat-grid .metric {
  min-height: 84px;
  min-width: 0;
}

.source-stat-grid .metric strong {
  font-size: 22px;
  white-space: nowrap;
}

.source-detail-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.source-trend-list {
  min-width: 0;
}

.source-trend-list .analytics-trend-row {
  grid-template-columns: 96px minmax(180px, 1fr) 64px 92px;
}

.source-page-list {
  display: grid;
  gap: 8px;
}

.source-page-row {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  padding: 12px;
}

.source-page-name {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.source-page-name strong {
  overflow-wrap: anywhere;
}

.source-page-name span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.source-page-row dl {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 62px);
  margin: 0;
}

.source-page-row dl div {
  display: grid;
  gap: 2px;
  justify-items: end;
}

.source-page-row dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.source-page-row dd {
  font-size: 15px;
  font-weight: 900;
  margin: 0;
}

.file-topbar {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(260px, 440px) minmax(180px, 260px) auto;
  justify-content: space-between;
  margin-bottom: 16px;
}

.file-topbar select {
  min-width: 100%;
}

.upload-summary {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  min-height: 44px;
  padding: 0 14px;
}

.upload-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.upload-summary strong {
  color: var(--primary-dark);
  font-size: 13px;
}

.file-collection-strip {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  min-width: 0;
}

.file-collection-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  min-width: 0;
}

.collection-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  color: var(--ink);
  display: grid;
  gap: 6px;
  min-height: 106px;
  padding: 14px;
  text-align: left;
  transition: background 0.18s ease, border-color 0.18s ease,
    transform 0.18s ease;
}

.collection-card:hover,
.collection-card.active {
  background: var(--primary-soft);
  border-color: rgba(24, 111, 101, 0.28);
  transform: translateY(-1px);
}

.collection-card strong {
  font-size: 15px;
  line-height: 1.25;
}

.collection-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.collection-card em {
  align-self: end;
  color: var(--primary-dark);
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
}

.folder-tree {
  align-self: start;
  display: grid;
  gap: 4px;
  padding: 10px;
}

.folder-tree-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  padding: 2px 10px 6px;
}

.folder-tree button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  min-height: 34px;
  padding: 0 10px;
  text-align: left;
}

.folder-tree button.active,
.folder-tree button:hover,
.folder-tree button.drag-over {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.drop-zone {
  align-items: center;
  background: repeating-linear-gradient(
    -45deg,
    #fbfcfc,
    #fbfcfc 8px,
    #eef3f4 8px,
    #eef3f4 16px
  );
  border: 1px dashed #aebcc3;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  justify-items: center;
  margin-bottom: 14px;
  min-height: 118px;
  padding: 20px;
  text-align: center;
  transition: background 0.18s ease, border-color 0.18s ease,
    transform 0.18s ease;
}

.drop-zone span {
  color: var(--muted);
  font-size: 13px;
}

.drop-zone button {
  margin-top: 8px;
}

.drop-zone.drag-over {
  background: #e8f6f3;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.drop-zone.disabled {
  opacity: 0.74;
}

.upload-queue {
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
}

.empty-queue {
  padding-bottom: 10px;
}

.upload-item {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 128px auto;
  padding: 12px;
}

.upload-item.completed {
  background: #f1fbf8;
  border-color: #b7e4da;
}

.upload-item.paused {
  background: #fff9ec;
  border-color: #f0d799;
}

.upload-item.cancelled {
  background: #f3f5f6;
  color: var(--muted);
}

.upload-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.upload-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-main span,
.upload-meta span {
  color: var(--muted);
  font-size: 12px;
}

.upload-progress {
  width: 100%;
}

.upload-meta {
  display: grid;
  gap: 3px;
  justify-items: end;
}

.upload-actions {
  display: flex;
  gap: 6px;
}

.upload-actions button {
  align-items: center;
  background: #eef2f4;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  font-size: 13px;
  font-weight: 900;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.file-content-grid {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
}

.file-table {
  align-self: start;
  min-width: 860px;
}

.file-name-cell {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.final-badge {
  align-items: center;
  background: var(--primary-soft);
  border: 1px solid rgba(24, 111, 101, 0.18);
  border-radius: 999px;
  color: var(--primary-dark);
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  min-height: 22px;
  padding: 0 8px;
  white-space: nowrap;
}

.selected-row td {
  background: #eef8f6;
}

.file-edit-form {
  margin-top: 16px;
}

.file-edit-form input,
.file-edit-form select,
.file-edit-form textarea {
  min-width: 0;
  width: 100%;
}

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

.checkbox-line input {
  min-height: auto;
  width: auto;
}

.personnel-table {
  min-width: 900px;
}

.personnel-name-cell,
.personnel-contact {
  display: grid;
  gap: 3px;
}

.personnel-name-cell .link-button {
  justify-self: start;
  min-height: auto;
}

.personnel-name-cell span,
.personnel-contact span {
  color: var(--muted);
  font-size: 12px;
}

.personnel-skill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.skill-chip {
  background: #eef2f4;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-size: 12px;
  font-weight: 850;
  min-height: 24px;
  padding: 4px 8px;
}

.modal-backdrop {
  align-items: center;
  backdrop-filter: blur(3px);
  background: rgba(16, 24, 32, 0.42);
  display: grid;
  inset: 0;
  justify-items: center;
  padding: 22px;
  position: fixed;
  z-index: 120;
}

.modal-panel {
  background: var(--panel);
  border: 1px solid rgba(217, 224, 227, 0.92);
  border-radius: 8px;
  box-shadow: 0 28px 90px rgba(16, 24, 32, 0.24);
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 22px;
  position: relative;
  width: min(680px, 100%);
}

.modal-panel h2 {
  font-size: 22px;
  line-height: 1.25;
  margin: 6px 40px 0 0;
  overflow-wrap: anywhere;
}

.file-modal {
  padding: 24px;
  width: min(760px, calc(100vw - 32px));
}

.file-modal-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.file-modal-header h2 {
  margin-bottom: 0;
}

.file-modal-summary {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 8px 14px;
}

.file-modal-summary div {
  border-bottom: 1px solid rgba(217, 224, 227, 0.72);
  padding: 10px 0;
}

.file-modal-summary div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.file-modal-actions {
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 16px;
}

.file-modal-actions .primary-button {
  min-width: 168px;
}

.project-modal {
  padding: 24px;
  width: min(920px, calc(100vw - 32px));
}

.project-modal-header {
  align-items: flex-start;
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.project-modal-header h2 {
  font-size: 24px;
  margin-bottom: 0;
}

.project-modal-summary {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 0 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 8px 14px;
}

.project-modal-summary div {
  border-bottom: 1px solid rgba(217, 224, 227, 0.72);
  padding: 10px 0;
}

.project-modal-summary div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.project-modal-summary dd .badge {
  justify-self: start;
}

.project-modal-form input,
.project-modal-form select,
.project-modal-form textarea {
  min-width: 0;
  width: 100%;
}

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

.project-modal-actions .primary-button {
  min-width: 168px;
}

.project-modal-sections {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
  padding-top: 18px;
}

.project-modal-sections section {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  padding: 14px;
}

.project-modal-sections .compact-list {
  max-height: 220px;
  overflow: auto;
}

.modal-close {
  align-items: center;
  background: #eef2f4;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  font-size: 20px;
  font-weight: 900;
  height: 36px;
  justify-content: center;
  position: absolute;
  right: 14px;
  top: 14px;
  width: 36px;
}

.personnel-edit-form {
  border-top: 0;
  margin-top: 18px;
  padding-top: 0;
}

.personnel-edit-form textarea {
  min-height: 96px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.file-modal-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.visually-hidden {
  height: 1px;
  left: -9999px;
  overflow: hidden;
  position: absolute;
  top: auto;
  width: 1px;
}

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

.person-card {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 14px;
}

.person-card .avatar {
  align-items: center;
  background: var(--primary-soft);
  border-radius: 8px;
  color: var(--primary-dark);
  display: inline-flex;
  font-weight: 900;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.person-card strong,
.person-card span {
  display: block;
}

.person-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.person-card small {
  grid-column: 2 / -1;
  margin: 0;
}

.toast {
  background: var(--ink);
  border-radius: 6px;
  bottom: 18px;
  box-shadow: 0 12px 34px rgba(16, 24, 32, 0.24);
  color: #fff;
  font-weight: 800;
  left: 50%;
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 14px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 100;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(128px, 1fr));
  }

  .analytics-metrics {
    grid-template-columns: repeat(3, minmax(128px, 1fr));
  }

  .dashboard-grid,
  .analytics-detail-grid,
  .source-detail-layout,
  .calendar-layout,
  .split-layout {
    grid-template-columns: 1fr;
  }

  .project-layout .detail-pane,
  .calendar-summary {
    max-height: none;
    position: static;
  }

  .project-form,
  .analytics-filter-form,
  .analytics-source-form,
  .analytics-source-detail-form,
  .personnel-create-form,
  .task-create-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-copy {
    min-height: 320px;
    padding: 28px;
  }

  .login-status h1 {
    font-size: 32px;
  }

  .login-panel {
    padding: 20px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
    width: 100%;
  }

  .nav {
    display: flex;
    flex-wrap: wrap;
    margin-top: 18px;
  }

  .nav-button {
    font-size: 13px;
    justify-content: center;
    min-width: max-content;
    padding: 0 8px;
    white-space: nowrap;
  }

  .session-panel {
    margin-top: 16px;
  }

  .workspace {
    padding: 18px;
    width: 100%;
  }

  .metric-grid,
  .analytics-metrics {
    grid-template-columns: 1fr;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .analytics-detail-grid,
  .analytics-filter-form,
  .analytics-source-form,
  .analytics-source-detail-form,
  .source-detail-layout,
  .calendar-weekdays,
  .calendar-grid,
  .file-layout,
  .file-topbar,
  .file-content-grid,
  .form-grid.two,
  .project-form,
  .personnel-create-form,
  .process-create-form,
  .task-create-form {
    grid-template-columns: 1fr;
  }

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

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

  .analytics-trend-row {
    grid-template-columns: 82px minmax(120px, 1fr);
  }

  .source-trend-list .analytics-trend-row {
    grid-template-columns: 82px minmax(0, 1fr) 52px;
  }

  .source-trend-list .analytics-trend-row > span {
    grid-column: 2 / -1;
  }

  .analytics-trend-row strong,
  .analytics-trend-row span {
    text-align: left;
  }

  .calendar-weekdays {
    display: none;
  }

  .calendar-grid {
    border-top: 0;
  }

  .calendar-day.empty {
    display: none;
  }

  .process-editor-header,
  .process-create-form {
    align-items: stretch;
    flex-direction: column;
  }

  .process-create-form input,
  .process-create-form select,
  .process-create-form button {
    min-width: 100%;
  }

  .modal-backdrop {
    align-items: start;
    padding: 12px;
  }

  .modal-panel {
    max-height: calc(100vh - 24px);
    padding: 18px;
  }

  .file-modal {
    padding: 18px;
    width: min(100%, calc(100vw - 24px));
  }

  .modal-panel.analytics-source-modal {
    width: min(100%, calc(100vw - 24px));
  }

  .file-modal-summary {
    grid-template-columns: 1fr;
  }

  .file-modal-summary div:nth-last-child(-n + 2) {
    border-bottom: 1px solid rgba(217, 224, 227, 0.72);
  }

  .file-modal-summary div:last-child {
    border-bottom: 0;
  }

  .project-modal {
    padding: 18px;
    width: min(100%, calc(100vw - 24px));
  }

  .project-modal-summary,
  .project-modal-sections {
    grid-template-columns: 1fr;
  }

  .project-modal-summary div:nth-last-child(-n + 2) {
    border-bottom: 1px solid rgba(217, 224, 227, 0.72);
  }

  .project-modal-summary div:last-child {
    border-bottom: 0;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions button {
    width: 100%;
  }

  .upload-item {
    grid-template-columns: 1fr;
  }

  .upload-meta {
    justify-items: start;
  }
}

@media (max-width: 520px) {
  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .metric strong {
    font-size: 24px;
  }

  .login-copy,
  .login-panel {
    padding: 16px;
  }
}
