/* Morgan Debrief Dashboard v2 */

:root, [data-theme="light"] {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1.0625rem;
  --text-lg: 1.1875rem;
  --text-xl: 1.5rem;

  --s1: 0.25rem; --s2: 0.5rem; --s3: 0.75rem;
  --s4: 1rem; --s5: 1.25rem; --s6: 1.5rem; --s8: 2rem; --s10: 2.5rem;

  --r-sm: 0.375rem; --r-md: 0.5rem; --r-lg: 0.75rem;

  --bg: #f5f4f0;
  --surface: #fff;
  --border: #e2e0db;
  --text: #1a1a18;
  --muted: #6b6a66;
  --faint: #9e9d99;

  --c-red: #c53030;
  --c-red-bg: #fff5f5;
  --c-red-border: #feb2b2;
  --c-orange: #c05621;
  --c-orange-bg: #fffaf0;
  --c-orange-border: #fbd38d;
  --c-blue: #2b6cb0;
  --c-blue-bg: #ebf8ff;
  --c-blue-border: #90cdf4;
  --c-green: #276749;
  --c-green-bg: #f0fff4;
  --c-green-border: #9ae6b4;
  --c-yellow: #975a16;
  --c-yellow-bg: #fffff0;
  --c-yellow-border: #fefcbf;
  --c-purple: #6b46c1;
  --c-purple-bg: #faf5ff;
  --c-purple-border: #d6bcfa;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
}

[data-theme="dark"] {
  --bg: #111110;
  --surface: #1a1a18;
  --border: #2d2d2a;
  --text: #e0dfdc;
  --muted: #8a8985;
  --faint: #5a5955;

  --c-red: #fc8181;
  --c-red-bg: #1a1210;
  --c-red-border: #4a2020;
  --c-orange: #f6ad55;
  --c-orange-bg: #1a1610;
  --c-orange-border: #4a3418;
  --c-blue: #63b3ed;
  --c-blue-bg: #101418;
  --c-blue-border: #1a3048;
  --c-green: #68d391;
  --c-green-bg: #101810;
  --c-green-border: #1a3a22;
  --c-yellow: #f6e05e;
  --c-yellow-bg: #1a1810;
  --c-yellow-border: #4a4018;
  --c-purple: #b794f4;
  --c-purple-bg: #1a1420;
  --c-purple-border: #3a2850;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #111110; --surface: #1a1a18; --border: #2d2d2a;
    --text: #e0dfdc; --muted: #8a8985; --faint: #5a5955;
    --c-red: #fc8181; --c-red-bg: #1a1210; --c-red-border: #4a2020;
    --c-orange: #f6ad55; --c-orange-bg: #1a1610; --c-orange-border: #4a3418;
    --c-blue: #63b3ed; --c-blue-bg: #101418; --c-blue-border: #1a3048;
    --c-green: #68d391; --c-green-bg: #101810; --c-green-border: #1a3a22;
    --c-yellow: #f6e05e; --c-yellow-bg: #1a1810; --c-yellow-border: #4a4018;
    --c-purple: #b794f4; --c-purple-bg: #1a1420; --c-purple-border: #3a2850;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2); --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; background: none; border: none; color: inherit; }

.dashboard { display: flex; flex-direction: column; min-height: 100dvh; }

/* ===== HEADER ===== */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.header-left { display: flex; align-items: center; gap: var(--s3); }
.logo { color: var(--text); flex-shrink: 0; }
.header h1 { font-size: var(--text-lg); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.header-meta { font-size: var(--text-xs); color: var(--muted); }
.header-right { display: flex; align-items: center; gap: var(--s4); }
.pulse-counts { display: flex; gap: var(--s3); font-size: var(--text-xs); font-weight: 500; }
.pulse-count { display: flex; align-items: center; gap: var(--s1); }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ===== MAIN ===== */
.main {
  flex: 1; padding: var(--s6) var(--s5);
  max-width: 1100px; width: 100%; margin: 0 auto;
}

/* ===== REPORT TIMESTAMP ===== */
.report-timestamp {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  margin-bottom: var(--s6);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--border);
}

/* ===== QUESTIONS ===== */
.questions-section {
  margin-bottom: var(--s8);
  padding: var(--s4) var(--s5);
  background: var(--c-purple-bg);
  border: 1px solid var(--c-purple-border);
  border-radius: var(--r-lg);
}
.section-header { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); color: var(--c-purple); }
.section-title { font-size: var(--text-sm); font-weight: 600; color: var(--c-purple); }
.questions-list { list-style: none; display: flex; flex-direction: column; gap: var(--s2); }
.questions-list li {
  font-size: var(--text-sm); line-height: 1.5; color: var(--text);
  padding-left: var(--s4); position: relative;
}
.questions-list li::before {
  content: ''; position: absolute; left: 0; top: 0.55em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-purple); opacity: 0.6;
}

/* ===== KPI ROW ===== */
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s3); margin-bottom: var(--s8); }
.kpi-card {
  padding: var(--s4); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md); text-align: center;
}
.kpi-value { font-size: var(--text-xl); font-weight: 700; line-height: 1; margin-bottom: var(--s1); }
.kpi-label { font-size: var(--text-xs); font-weight: 500; }
.kpi-sub { font-size: var(--text-xs); color: var(--faint); margin-top: 2px; }

/* ===== TIER SECTIONS ===== */
.tier { margin-bottom: var(--s10); }

.tier-header {
  display: flex; align-items: center; gap: var(--s2);
  margin-bottom: var(--s4); padding-bottom: var(--s2);
}
.tier-indicator { width: 3px; height: 20px; border-radius: 2px; flex-shrink: 0; }
.tier-title { font-size: var(--text-base); font-weight: 600; letter-spacing: -0.01em; }
.tier-count { font-size: var(--text-xs); color: var(--muted); font-weight: 400; margin-left: var(--s1); }
.tier-subtitle { font-size: var(--text-xs); color: var(--muted); margin-left: auto; }

/* ===== TICKET CARDS ===== */
.ticket-list { display: flex; flex-direction: column; gap: var(--s4); }
.ticket-list .ticket-card + .ticket-card { padding-top: var(--s4); border-top: 1px solid var(--border); border-radius: var(--r-md); }

.ticket-card {
  display: grid; grid-template-columns: 4px 1fr;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: box-shadow 0.15s ease;
}
.ticket-card:hover { box-shadow: var(--shadow-md); }

.ticket-edge { width: 4px; border-radius: 2px; align-self: stretch; }
.ticket-body { min-width: 0; }
.ticket-body > div,
.ticket-body > .ticket-context,
.ticket-body > .ticket-action { margin-bottom: var(--s3); }
.ticket-body > .ticket-meta { margin-bottom: 0; }

/* Line 1: Company + SR link */
.ticket-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s2);
}

/* Client company - own line, distinct color */
.ticket-company {
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1.3;
  color: var(--c-blue);
}

/* Line 2: Requester Name */
.ticket-requester {
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
}
.ticket-client-email {
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--muted);
}

/* Field labels */
.ticket-field-label {
  font-weight: 400;
  color: var(--muted);
}

/* SR link - links to Monday item */
.ticket-sr-link {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-blue);
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  background: var(--c-blue-bg);
  border: 1px solid var(--c-blue-border);
  transition: background 0.15s ease;
}
.ticket-sr-link:hover {
  text-decoration: underline;
  background: var(--c-blue-border);
}
.sr-link-icon {
  flex-shrink: 0;
  margin-right: 3px;
  vertical-align: -1px;
  opacity: 0.7;
}
.ticket-sr-link:hover .sr-link-icon {
  opacity: 1;
}

/* Ticket name / subject */
.ticket-name {
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.3;
  color: var(--muted);
}

/* Last updated timestamp - stands out */
.ticket-timestamp {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--c-purple);
  letter-spacing: 0.01em;
}
.ticket-relative-age {
  font-weight: 600;
}
.ticket-relative-age.age-warning {
  color: var(--c-orange);
}
.ticket-relative-age.age-critical {
  color: var(--c-red);
}

/* Context - full client statement, paragraph formatted */
.ticket-context {
  font-size: var(--text-sm);
  color: var(--text);
  line-height: 1.6;
}
.ticket-context p {
  margin: 0 0 var(--s2) 0;
}
.ticket-context p:last-child {
  margin-bottom: 0;
}

/* Action - what to do */
.ticket-action {
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.4;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  background: var(--bg);
}

/* Meta row */
.ticket-meta {
  display: flex; flex-wrap: wrap; gap: var(--s2);
  font-size: var(--text-xs); color: var(--faint);
  align-items: center;
}
.ticket-meta-item { display: flex; align-items: center; gap: 3px; }

.ticket-assignee-badge {
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: var(--r-sm);
}
.assignee-label {
  font-weight: 400;
  color: var(--muted);
}

.ticket-status-badge {
  font-size: 0.6875rem;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--border);
  color: var(--muted);
}
.ticket-flag-badge {
  font-size: 0.6875rem;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--c-red-bg);
  color: var(--c-red);
  border: 1px solid var(--c-red-border);
}

/* ===== TIER COLORS ===== */
.tier-act-now .tier-indicator, .tier-act-now .ticket-edge { background: var(--c-red); }
.tier-act-now .ticket-action { color: var(--c-red); }

.tier-overdue .tier-indicator, .tier-overdue .ticket-edge { background: var(--c-orange); }
.tier-overdue .ticket-action { color: var(--c-orange); }

.tier-new .tier-indicator, .tier-new .ticket-edge { background: var(--c-yellow); }
.tier-new .ticket-action { color: var(--c-yellow); }

.tier-stale .tier-indicator, .tier-stale .ticket-edge { background: var(--c-blue); }
.tier-stale .ticket-action { color: var(--c-blue); }

.tier-hold .tier-indicator, .tier-hold .ticket-edge { background: var(--muted); }

.tier-clear .tier-indicator, .tier-clear .ticket-edge { background: var(--c-green); }

/* ===== WORKLOAD ===== */
.assignee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--s3); margin-top: var(--s3);
}
.assignee-card {
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.assignee-name { font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--s1); }
.assignee-total { font-size: var(--text-xs); color: var(--muted); margin-bottom: var(--s1); }
.assignee-tags { display: flex; flex-wrap: wrap; gap: var(--s1); font-size: var(--text-xs); }
.tag-urgent { color: var(--c-red); font-weight: 600; }
.tag-overdue { color: var(--c-orange); }
.tag-new { color: var(--c-yellow); }
.tag-stale { color: var(--c-blue); }

/* ===== COLLAPSIBLE ===== */
.tier-toggle {
  display: flex; align-items: center; gap: var(--s2);
  width: 100%; text-align: left; padding: 0;
}
.tier-toggle .chevron { transition: transform 0.15s ease; color: var(--muted); flex-shrink: 0; }
.tier.collapsed .tier-toggle .chevron { transform: rotate(-90deg); }
.tier.collapsed .ticket-list,
.tier.collapsed .assignee-grid { display: none; }

/* ===== FOOTER ===== */
.footer {
  padding: var(--s4) var(--s5); text-align: center;
  border-top: 1px solid var(--border);
  font-size: var(--text-xs); color: var(--faint);
}
.footer a:hover { text-decoration: underline; }

/* ===== MOBILE ===== */
@media (max-width: 640px) {
  .header { flex-wrap: wrap; gap: var(--s2); }
  .pulse-counts { order: 3; width: 100%; flex-wrap: wrap; }
  .main { padding: var(--s4) var(--s3); }
  .kpi-row { grid-template-columns: repeat(2, 1fr); grid-template-rows: auto auto auto; }
  .ticket-card { padding: var(--s3) var(--s4); }
  .tier-subtitle { display: none; }
  .assignee-grid { grid-template-columns: 1fr 1fr; }
  .ticket-client-email { display: block; margin-top: 2px; }
}
