:root {
  --primary-deep: #042C53;
  --primary: #185FA5;
  --primary-light: #E6F1FB;
  --surface: #FFFFFF;
  --bg: #F7F9FC;
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.18);
  --text: #1a2330;
  --text-muted: #5a6478;
  --text-dim: #9aa3b3;
  --success: #1D9E75;
  --success-bg: #E1F5EE;
  --warning: #BA7517;
  --warning-bg: #FAEEDA;
  --danger: #A32D2D;
  --danger-bg: #FCEBEB;
  --brand-sebia: #D4537E;
  --brand-snibe: #378ADD;
  --brand-lifo: #1D9E75;
  --brand-sansure: #E24B4A;
  --brand-diasys: #EF9F27;
}

* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  margin: 0; padding: 0; line-height: 1.5; font-size: 14px;
}

/* HEADER */
.app-header {
  background: var(--primary-deep);
  color: white;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 24px;
}
.app-header .brand-mark { font-weight: 600; letter-spacing: 0.5px; font-size: 16px; }
.app-header .brand-mark small { opacity: 0.6; font-weight: 400; margin-left: 6px; font-size: 11px; }
.app-header nav { display: flex; gap: 6px; margin-left: auto; }
.app-header nav a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  transition: background 0.15s;
}
.app-header nav a:hover { background: rgba(255,255,255,0.08); color: white; }
.app-header nav a.active { background: rgba(255,255,255,0.12); color: white; }

/* KPI STRIP */
.kpi-strip {
  background: var(--primary-deep);
  color: white;
  padding: 0 24px 18px;
  display: flex; gap: 12px;
}
.kpi {
  background: rgba(255,255,255,0.08);
  padding: 10px 16px;
  border-radius: 6px;
  min-width: 110px;
}
.kpi .num {
  font-size: 22px; font-weight: 500; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi .lbl {
  font-size: 10.5px; opacity: 0.7; letter-spacing: 0.4px;
  text-transform: uppercase; margin-top: 3px;
}
.kpi.danger .num { color: #F5C4B3; }
.kpi.warn .num { color: #FAC775; }
.kpi.success .num { color: #C0DD97; }

/* FILTER BAR */
.filter-bar {
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.filter-chip {
  background: white; padding: 4px 12px; border-radius: 14px;
  border: 1px solid #B5D4F4; font-size: 12px; color: var(--primary-deep);
  cursor: pointer;
}
.filter-chip.active { background: var(--primary-deep); color: white; border-color: var(--primary-deep); }
.filter-bar input[type=text] {
  margin-left: auto; padding: 5px 12px; border-radius: 4px;
  border: 1px solid #B5D4F4; font-size: 12px; min-width: 220px;
  background: white;
}

/* CONTAINER */
.container {
  max-width: 1400px; margin: 0 auto; padding: 18px 24px;
}

/* ANALYZER GRID */
.analyzer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.analyzer-card {
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 14px 14px 12px;
  position: relative;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  text-decoration: none; color: inherit;
  display: block;
  border-left: 3px solid var(--success);
}
.analyzer-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  border-color: var(--border-strong);
}
.analyzer-card.at-risk { border-left-color: var(--danger); }
.analyzer-card.on-hold { border-left-color: var(--text-dim); }

.analyzer-card .row1 {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; margin-bottom: 7px;
}
.analyzer-card .status {
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500;
  color: var(--success);
}
.analyzer-card.at-risk .status { color: var(--danger); }
.analyzer-card.on-hold .status { color: var(--text-muted); }
.analyzer-card .status::before {
  content: "●"; margin-right: 4px;
}

.analyzer-card .brand-pill {
  padding: 2px 8px; border-radius: 3px;
  font-weight: 500; font-size: 10px;
  background: rgba(0,0,0,0.04);
}
.brand-pill.SEBIA { background: #FBEAF0; color: #72243E; }
.brand-pill.SNIBE { background: #E6F1FB; color: #042C53; }
.brand-pill.LIFOTRONIC { background: #E1F5EE; color: #04342C; }
.brand-pill.SANSURE { background: #FCEBEB; color: #501313; }
.brand-pill.DIASYS { background: #FAEEDA; color: #412402; }

.analyzer-card .model {
  font-size: 14px; font-weight: 500;
  font-family: 'Roboto Mono', 'Consolas', monospace;
  margin: 0 0 2px 0;
}
.analyzer-card .sn {
  font-size: 11px; color: var(--text-muted);
  font-family: 'Roboto Mono', 'Consolas', monospace;
  margin: 0;
}
.analyzer-card .footer {
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
}
.analyzer-card .customer { color: var(--text); font-weight: 500; }
.analyzer-card .meta { color: var(--text-muted); margin-top: 2px; }
.analyzer-card .meta.danger { color: var(--danger); }

/* SECTION HEADERS */
.section-title {
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 18px 0 10px 0;
}

/* DETAIL PAGES */
.detail-header {
  background: white; padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.detail-header h1 {
  margin: 0; font-size: 22px; font-weight: 500;
  font-family: 'Roboto Mono', 'Consolas', monospace;
}
.detail-header .sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.detail-grid {
  display: grid; grid-template-columns: 2fr 1fr; gap: 20px; padding: 20px 24px;
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border-radius: 6px;
  border: 1px solid var(--border); padding: 16px;
}
.card h2 {
  margin: 0 0 12px 0; font-size: 13px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted);
}

.task-row {
  padding: 10px 0; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.task-row:last-child { border-bottom: none; }
.task-row .ticon {
  width: 24px; text-align: center; font-size: 14px;
}
.task-row .ttext { flex: 1; }
.task-row .tname { font-weight: 500; font-size: 13px; }
.task-row .tmeta { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.task-row .tstatus { font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.tstatus.done { background: var(--success-bg); color: #04342C; }
.tstatus.in-progress { background: var(--warning-bg); color: #412402; }
.tstatus.scheduled { background: var(--primary-light); color: var(--primary-deep); }

/* FOOTER */
.app-footer {
  margin-top: 30px; padding: 18px 24px;
  text-align: center; font-size: 11px; color: var(--text-dim);
  border-top: 1px solid var(--border);
}

/* === Detail page enrichment === */

.dh-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.dh-crumb { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.dh-crumb a { color: var(--primary); text-decoration: none; }
.dh-crumb a:hover { text-decoration: underline; }
.detail-header h1 {
  margin: 0 0 4px 0; font-size: 24px; font-weight: 500;
  font-family: 'Roboto Mono', 'Consolas', monospace;
}
.dh-sub { color: var(--text-muted); font-size: 13px; }
.dh-stats { display: flex; gap: 8px; }
.dh-stat {
  background: var(--primary-light); padding: 8px 14px; border-radius: 6px;
  text-align: center; min-width: 70px;
}
.dh-stat .dh-num { font-size: 20px; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--primary-deep); }
.dh-stat .dh-num.danger { color: var(--danger); }
.dh-stat .dh-lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 3px; }

.detail-grid > div > .card { margin-bottom: 14px; }

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

/* Task cards in detail */
.task-card {
  display: flex; gap: 10px; padding: 10px 12px;
  border-radius: 5px; border: 1px solid var(--border);
  margin-bottom: 6px; background: var(--surface);
  align-items: center;
}
.task-card.overdue {
  background: #FFFBF8; border-color: #F0C4B3; border-left: 3px solid var(--danger);
}
.tc-icon { font-size: 16px; }
.tc-body { flex: 1; min-width: 0; }
.tc-title { font-weight: 500; font-size: 13px; }
.tc-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.tc-stage {
  padding: 1px 7px; border-radius: 9px; font-size: 10px;
  background: var(--primary-light); color: var(--primary-deep);
}
.tc-stage.done { background: var(--success-bg); color: #04342C; }
.tc-stage.in-progress { background: var(--warning-bg); color: #412402; }
.tc-stage.scheduled { background: var(--primary-light); color: var(--primary-deep); }
.tc-stage.awaiting { background: #FAEAE8; color: var(--danger); }
.tc-stage.todo { background: #F1EFE8; color: var(--text); }
.tc-due.danger { color: var(--danger); font-weight: 500; }
.tc-badge.done { background: var(--success-bg); color: #04342C; padding: 2px 8px; border-radius: 3px; font-size: 10px; font-weight: 500; }

/* Timeline */
.timeline { position: relative; padding-left: 18px; }
.timeline::before {
  content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px;
  width: 1px; background: var(--border);
}
.tl-item { position: relative; padding: 4px 0 14px 0; }
.tl-dot {
  position: absolute; left: -18px; top: 5px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--primary); border: 2px solid white;
}
.tl-dot.note { background: var(--warning); }
.tl-meta { font-size: 12px; margin-bottom: 4px; }
.tl-meta strong { font-weight: 500; }
.tl-tag { background: var(--warning-bg); color: #412402; padding: 1px 6px; border-radius: 3px; font-size: 10px; margin-left: 6px; }
.tl-date { color: var(--text-muted); font-size: 11px; margin-left: 6px; font-family: 'Roboto Mono', monospace; }
.tl-body { font-size: 13px; color: var(--text); }
.tl-body p { margin: 4px 0; }
.tl-body img { max-width: 200px; height: auto; border-radius: 4px; border: 1px solid var(--border); margin: 4px 0; }

/* Report cards */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.report-card {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px; background: var(--success-bg);
  border-radius: 5px; border-left: 3px solid var(--success);
}
.report-icon { font-size: 18px; }
.report-meta { flex: 1; min-width: 0; }
.report-title { font-weight: 500; font-size: 12px; }
.report-sub { font-size: 10.5px; color: #04342C; margin-top: 2px; }
.report-hours { font-size: 11px; color: var(--success); font-weight: 500; }

/* Key-value table */
.kv { width: 100%; font-size: 13px; }
.kv td { padding: 4px 0; vertical-align: top; }
.kv td:first-child { color: var(--text-muted); width: 110px; font-size: 12px; }
.kv td.mono { font-family: 'Roboto Mono', 'Consolas', monospace; font-size: 12px; }
.status-pill {
  padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 500;
  background: var(--success-bg); color: #04342C;
}
.status-pill.at_risk { background: var(--danger-bg); color: var(--danger); }
.status-pill.on_hold { background: #F1EFE8; color: var(--text); }

/* Activity rows */
.act-row {
  display: flex; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: 12.5px;
}
.act-row:last-child { border-bottom: none; }
.act-date {
  min-width: 60px; font-family: 'Roboto Mono', monospace;
  font-size: 11px; color: var(--primary);
}
.act-body { flex: 1; }
.act-summary { font-weight: 500; }
.act-user { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Contributors */
.contrib-row { display: flex; gap: 10px; padding: 6px 0; align-items: center; }
.contrib-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500;
}
.contrib-info { flex: 1; }
.contrib-name { font-size: 13px; font-weight: 500; }
.contrib-hours { font-size: 11px; color: var(--text-muted); }

/* === TEAM PAGE === */
.team-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.team-card {
  background: var(--surface); border-radius: 6px; border: 1px solid var(--border);
  padding: 16px; text-decoration: none; color: inherit;
  transition: transform 0.12s, box-shadow 0.12s;
  display: block;
}
.team-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
  border-color: var(--border-strong);
}
.tc-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.tc-name { font-weight: 500; font-size: 14px; }
.tc-role { font-size: 11px; color: var(--text-muted); }
.tc-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 10px 0; }
.tc-kpi { background: var(--primary-light); padding: 6px 8px; border-radius: 4px; text-align: center; }
.tc-kpi-num { font-size: 16px; font-weight: 500; color: var(--primary-deep); font-variant-numeric: tabular-nums; }
.tc-kpi-num.danger { color: var(--danger); }
.tc-kpi-lbl { font-size: 9px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); margin-top: 2px; }
.tc-tasks { padding-top: 10px; border-top: 1px solid var(--border); }
.tc-section-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 6px; }
.tc-task-row { display: flex; gap: 6px; padding: 3px 0; font-size: 12px; align-items: center; }
.tc-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.tc-task-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-more { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.team-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 6px; overflow: hidden; }
.team-table th { background: var(--primary-light); color: var(--primary-deep); padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; text-align: left; font-weight: 500; }
.team-table td { padding: 12px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
.team-table tr:last-child td { border-bottom: none; }
.team-table a { color: var(--primary); text-decoration: none; font-weight: 500; }
.team-table a:hover { text-decoration: underline; }
.badge-danger { background: var(--danger-bg); color: var(--danger); padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 500; }

/* === ACTION PANEL === */
.action-tabs { display: flex; gap: 4px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.action-tab {
  background: none; border: none; padding: 8px 14px;
  font-size: 12.5px; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.action-tab.active { color: var(--primary-deep); border-bottom-color: var(--primary-deep); font-weight: 500; }
.action-tab:hover { color: var(--primary); }
.action-pane { padding: 8px 0; }
.action-pane textarea, .action-pane input[type=text], .action-pane input[type=number], .action-pane input[type=date] {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 4px;
  font-family: inherit; margin-bottom: 8px;
}
.action-pane textarea { resize: vertical; min-height: 60px; }
.form-row { display: flex; gap: 6px; align-items: center; }
.form-row input { margin-bottom: 0; }
.btn-primary {
  background: var(--primary-deep); color: white; border: none;
  padding: 8px 18px; font-size: 12.5px; border-radius: 4px;
  cursor: pointer; font-weight: 500;
}
.btn-primary:hover { background: var(--primary); }
#action-status { padding: 6px 0; font-size: 12px; font-weight: 500; }

/* === MY DAY (Service Tech, mobile-first) === */
.my-day-header { background: var(--primary-deep); color: white; padding: 18px 20px; }
.md-row { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.md-greeting { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px; }
.md-title { margin: 4px 0 0; color: white; font-weight: 500; font-size: 22px; }
.md-date { font-size: 12px; opacity: 0.7; font-family: 'Roboto Mono', monospace; }
.md-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.md-kpi { background: rgba(255,255,255,0.08); padding: 10px; border-radius: 6px; text-align: center; }
.md-kpi-num { font-size: 22px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.md-kpi-lbl { font-size: 10px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.4px; margin-top: 4px; }
.md-kpi.danger .md-kpi-num { color: #F5C4B3; }
.md-kpi.success .md-kpi-num { color: #C0DD97; }
.md-container { max-width: 760px; padding: 14px; }
.md-section { margin-bottom: 18px; }
.md-section-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 8px; font-weight: 500; }
.md-section-lbl.danger { color: var(--danger); }
.md-task { display: block; background: var(--surface); border-radius: 6px; border: 1px solid var(--border); padding: 12px 14px; margin-bottom: 8px; text-decoration: none; color: inherit; transition: transform 0.12s, box-shadow 0.12s; }
.md-task:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.md-task.overdue { border-left: 3px solid var(--danger); background: #FFFBF8; }
.md-task-top { display: flex; justify-content: space-between; align-items: center; font-size: 11px; margin-bottom: 6px; }
.md-task-stage { padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.md-task-stage.stage-to-do { background: #F1EFE8; color: var(--text); }
.md-task-stage.stage-scheduled { background: var(--primary-light); color: var(--primary-deep); }
.md-task-stage.stage-in-progress { background: var(--warning-bg); color: #412402; }
.md-task-stage.stage-awaiting-parts-customer { background: #FAEAE8; color: var(--danger); }
.md-task-late { color: var(--danger); font-weight: 500; }
.md-task-due { color: var(--text-muted); }
.md-task-title { font-weight: 500; font-size: 14px; margin-bottom: 3px; }
.md-task-meta { font-size: 12px; color: var(--text-muted); }
.mono { font-family: 'Roboto Mono', monospace; }
.md-empty { background: var(--surface); border-radius: 6px; padding: 30px 20px; text-align: center; }
.md-empty p { margin: 6px 0; }

/* Mobile responsive */
@media (max-width: 640px) {
  .my-day-header { padding: 14px; }
  .md-title { font-size: 20px; }
  .md-kpis { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .md-kpi { padding: 8px 4px; }
  .md-kpi-num { font-size: 18px; }
  .md-kpi-lbl { font-size: 9px; }
  .app-header { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .app-header nav { gap: 4px; flex-wrap: wrap; }
  .app-header nav a { padding: 4px 10px; font-size: 12px; }
}

/* === FAULT PATTERNS === */
.fault-row { display: flex; gap: 10px; padding: 6px 0; align-items: flex-start; }
.fault-bullet { color: var(--success); font-weight: bold; flex-shrink: 0; }
.fault-body { flex: 1; }
.fault-title { font-size: 13px; font-weight: 500; }
.fault-meta { font-size: 11px; color: var(--text-muted); }
.common-faults { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px; }
.fault-shortcut {
  background: var(--primary-light); color: var(--primary-deep);
  border: 1px solid #B5D4F4; padding: 8px 10px; border-radius: 5px;
  cursor: pointer; text-align: left; font: inherit;
  transition: background 0.12s;
}
.fault-shortcut:hover { background: #DCEAF7; }
.fs-sym { font-weight: 500; font-size: 12px; display: block; }
.fs-fix { font-size: 11px; color: var(--text-muted); display: block; margin-top: 2px; }

/* === MOBILE-FIRST ANALYZER PAGE === */
@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .dh-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .dh-stats { width: 100%; }
  .dh-stat { flex: 1; min-width: 0; padding: 6px 8px; }
  .dh-stat .dh-num { font-size: 16px; }
  .detail-header h1 { font-size: 18px; }
  .card { padding: 12px; }
  .card h2 { font-size: 12px; }
  /* Photo input on mobile prefers camera */
  #photo-input::-webkit-file-upload-button { background: var(--primary-light); border: none; padding: 6px 10px; }
  /* Make action tabs scrollable on narrow screens */
  .action-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .action-tab { white-space: nowrap; }
}

/* === KPI CLICKABLE === */
.kpi.clickable { cursor: pointer; transition: background 0.12s, transform 0.12s; }
.kpi.clickable:hover { background: rgba(255,255,255,0.14); }
.kpi.kpi-active { outline: 2px solid white; background: rgba(255,255,255,0.18); }

/* === PORTFOLIO === */
.portfolio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.portfolio-card {
  background: var(--surface); border-radius: 6px; border: 1px solid var(--border);
  padding: 14px; text-decoration: none; color: inherit;
  border-left: 4px solid var(--success);
  transition: transform 0.12s, box-shadow 0.12s;
}
.portfolio-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.portfolio-card.at-risk { border-left-color: var(--danger); background: #FFFBF8; }
.portfolio-card.on-hold { border-left-color: var(--text-dim); }
.pc-row1 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); }
.pc-segment { font-weight: 500; }
.pc-name { font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.pc-stats { font-size: 11.5px; color: var(--text-muted); display: flex; gap: 10px; margin-bottom: 8px; }
.pc-overdue { background: var(--danger-bg); color: var(--danger); padding: 3px 8px; border-radius: 3px; font-size: 11.5px; font-weight: 500; margin-bottom: 6px; }
.pc-foot { font-size: 11px; color: var(--text-muted); display: flex; justify-content: space-between; }

/* === MINI ANALYZER CARD (in customer page) === */
.analyzer-card.mini { padding: 10px 12px; }
.analyzer-card.mini .model { font-size: 13px; }
.analyzer-card.mini .sn { font-size: 10.5px; }

/* === OPS === */
.ops-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 900px) { .ops-grid { grid-template-columns: 1fr; } }
.workload-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 12.5px; }
.wr-name { min-width: 110px; }
.wr-bar { flex: 1; height: 14px; background: var(--primary-light); border-radius: 7px; overflow: hidden; }
.wr-fill { height: 100%; background: var(--primary); transition: width 0.3s; }
.wr-fill.full { background: var(--warning); }
.wr-fill.overload { background: var(--danger); }
.wr-hrs { min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

/* =============================================================
   TIER 1 INTERACTIVE — quick-create modal, stage pill, toast
   ============================================================= */

/* Floating + button */
.quick-create-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #042C53;
  color: #fff;
  border: none;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(4, 44, 83, 0.35);
  z-index: 900;
  transition: transform .15s, background .15s;
}
.quick-create-fab:hover {
  background: #063b6e;
  transform: translateY(-2px) scale(1.05);
}
.quick-create-fab:active { transform: scale(0.95); }

/* Modal overlay */
.qc-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  padding-top: 6vh;
}
.qc-overlay.open { display: flex; }

.qc-modal {
  background: #fff;
  width: 100%;
  max-width: 640px;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: 88vh;
}

.qc-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px;
  background: #042C53;
  color: #fff;
}
.qc-header h2 { margin: 0; font-size: 17px; font-weight: 600; }
.qc-close {
  background: rgba(255,255,255,0.15);
  border: none; color: #fff;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 18px; cursor: pointer; line-height: 1;
}
.qc-close:hover { background: rgba(255,255,255,0.3); }

.qc-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}

.qc-row { margin-bottom: 14px; }
.qc-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.qc-row .req { color: #dc2626; }
.qc-row input[type="text"],
.qc-row input[type="date"],
.qc-row select,
.qc-row textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.qc-row input:focus, .qc-row select:focus, .qc-row textarea:focus {
  outline: none;
  border-color: #042C53;
  box-shadow: 0 0 0 3px rgba(4,44,83,0.10);
}
.qc-row textarea { resize: vertical; min-height: 70px; }

.qc-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.qc-footer {
  padding: 14px 22px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
}
.qc-footer .btn-primary,
.qc-footer .btn-secondary { padding: 8px 16px; font-size: 14px; }
.qc-footer .btn-secondary { margin-right: 8px; }
.qc-help { font-size: 11px; }
.qc-help kbd {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 10px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #042C53;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 1100;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #166534; }
.toast.error { background: #991b1b; }

/* Stage pill (clickable + dropdown) */
.stage-pill-wrap { position: relative; display: inline-block; }
.stage-pill-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all .15s;
}
.stage-pill-btn:hover { background: #e2e8f0; border-color: #cbd5e1; }
.stage-pill-btn .caret { font-size: 8px; opacity: 0.6; }

.stage-pill-btn.s-todo        { background: #f1f5f9; color: #475569; }
.stage-pill-btn.s-scheduled   { background: #e0e7ff; color: #3730a3; }
.stage-pill-btn.s-in-progress { background: #fef3c7; color: #92400e; }
.stage-pill-btn.s-awaiting    { background: #fed7aa; color: #9a3412; }
.stage-pill-btn.s-done        { background: #dcfce7; color: #166534; }

.stage-pill-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.12);
  min-width: 180px;
  z-index: 100;
  display: none;
  overflow: hidden;
}
.stage-pill-menu.open { display: block; }
.stage-pill-menu .opt {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stage-pill-menu .opt:hover { background: #f0f9ff; }
.stage-pill-menu .opt.current { background: #f8fafc; font-weight: 600; }
.stage-pill-menu .opt .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1;
}
.stage-pill-menu .divider {
  height: 1px; background: #f1f5f9; margin: 4px 0;
}
.stage-pill-menu .opt.complete-action {
  background: #042C53; color: #fff;
}
.stage-pill-menu .opt.complete-action:hover { background: #063b6e; }

/* Mark Done modal (reuses .qc-modal styling but with signature canvas) */
.signature-pad {
  border: 2px dashed #94a3b8;
  border-radius: 8px;
  background: #fafbfc;
  width: 100%;
  height: 140px;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
.signature-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: #64748b;
}
.signature-clear {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
  .quick-create-fab {
    right: 16px;
    bottom: 16px;
    width: 50px; height: 50px;
    font-size: 28px;
  }
  .qc-modal { border-radius: 12px 12px 0 0; margin-top: auto; max-height: 92vh; }
  .qc-overlay { padding-top: 0; align-items: flex-end; }
  .qc-grid-2 { grid-template-columns: 1fr; }
  .qc-footer { flex-direction: column-reverse; align-items: stretch; gap: 8px; }
  .qc-footer > div:last-child { display: flex; gap: 8px; }
  .qc-footer .btn-primary, .qc-footer .btn-secondary { flex: 1; }
}

/* =============================================================
   TIER 2 — @mentions, follow button, unread badges
   ============================================================= */

/* Follow button (next to analyzer h1) */
.follow-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1.5px solid #cbd5e1;
  color: #475569;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 12px;
  transition: all .15s;
}
.follow-btn:hover { border-color: #042C53; color: #042C53; background: #f0f9ff; }
.follow-btn.following {
  background: #fef9c3;
  border-color: #facc15;
  color: #854d0e;
}
.follow-btn.following:hover { background: #fef08a; }

/* @mention dropdown */
.mention-wrap { position: relative; }
.mention-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.14);
  min-width: 240px;
  max-width: 320px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 200;
  display: none;
}
.mention-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}
.mention-opt:last-child { border-bottom: none; }
.mention-opt:hover { background: #f0f9ff; }
.mention-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #042C53;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mention-name { font-size: 13px; font-weight: 600; color: #0f172a; }
.mention-title { font-size: 11px; color: #64748b; }

/* Mention chips below textarea (preview of who'll be notified) */
.mention-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px 0;
  min-height: 0;
}
.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 4px 3px 10px;
  border-radius: 12px;
}
.mention-chip button {
  background: rgba(30, 64, 175, 0.15);
  color: #1e40af;
  border: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mention-chip button:hover { background: rgba(30, 64, 175, 0.3); }

/* Unread badge on analyzer cards */
.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  margin-left: auto;
  box-shadow: 0 0 0 2px #fff;
  animation: pulseRed 2s ease-in-out infinite;
}
@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50%      { box-shadow: 0 0 0 2px #fff, 0 0 0 6px rgba(220, 38, 38, 0); }
}

/* In nav, optional "Inbox (N)" badge */
nav .nav-badge {
  display: inline-block;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  vertical-align: top;
}

/* Mention rendering inside chatter messages (logbook) */
.logbook .mention,
.event-body .mention {
  background: #dbeafe;
  color: #1e40af;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-decoration: none;
}

/* =============================================================
   TIER 3 — PM scheduler card on analyzer page
   ============================================================= */

.pm-card { border-top: 3px solid #16a34a; }
.pm-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.pm-stat {
  background: #f0fdf4;
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
}
.pm-stat.danger { background: #fef2f2; }
.pm-num {
  font-size: 16px;
  font-weight: 700;
  color: #166534;
}
.pm-stat.danger .pm-num { color: #991b1b; }
.pm-num small { font-size: 10px; color: #64748b; margin-left: 2px; }
.pm-lbl {
  font-size: 10px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 4px;
}
.pm-actions {
  border-top: 1px solid #f1f5f9;
  padding-top: 12px;
}
.pm-actions label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.pm-actions select {
  padding: 5px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
}

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

/* =============================================================
   TIER 4 — Knowledge area (analyzer page) + Discuss tweaks
   ============================================================= */

.knowledge-card { border-top: 3px solid #0e7490; }
.knowledge-card h2 { display: flex; align-items: center; }

.kw-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.kw-tab-empty {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #94a3b8;
}

.kw-cat { margin-bottom: 16px; }
.kw-cat-head {
  font-size: 13px;
  font-weight: 600;
  color: #075985;
  margin: 0 0 6px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kw-cat-count {
  background: #e0f2fe;
  color: #0c4a6e;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 700;
}
.kw-docs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
.kw-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  border: 1px solid #f1f5f9;
  transition: all .15s;
}
.kw-doc:hover {
  background: #f0f9ff;
  border-color: #0ea5e9;
  transform: translateX(2px);
}
.kw-doc-icon { font-size: 20px; flex-shrink: 0; }
.kw-doc-info { flex: 1; min-width: 0; }
.kw-doc-name {
  font-size: 13px;
  font-weight: 500;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kw-doc-meta {
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
}

.kw-summary { font-size: 12px; }

/* Logbook source-task tag — visual indicator that a message came from a sub-task */
.tl-tag {
  display: inline-block;
  padding: 1px 8px;
  background: #f1f5f9;
  color: #475569;
  font-size: 10px;
  font-weight: 600;
  border-radius: 8px;
  margin-left: 4px;
  text-transform: none;
  letter-spacing: 0;
}
