@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e1e4e8;
  --border-subtle: #eef0f2;
  --text: #0d1117;
  --text-secondary: #57606a;
  --text-muted: #8b949e;
  --accent: #0969da;
  --accent-subtle: #ddf4ff;
  --red: #cf222e;
  --red-subtle: #ffebe9;
  --green: #1a7f37;
  --green-subtle: #dafbe1;
  --amber: #bf8700;
  --amber-subtle: #fff8c5;
  --purple: #8250df;
  --purple-subtle: #fbefff;
  --blue-chart: #0969da;
  --green-chart: #1a7f37;
  --red-chart: #cf222e;
  --gray-chart: #8c959f;
  --header-bg: rgba(255, 255, 255, 0.94);
  --header-border: #d8dee4;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
}

@keyframes skeleton-shimmer {
  100% { transform: translateX(100%); }
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button:focus-visible,
input:focus-visible,
a:focus-visible,
tr:focus-visible,
.ticket-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.is-slide-over-open {
  overflow: hidden;
}

/* ── Header ── */
.header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 32px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--text);
  color: #f0f6fc;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.header h1 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
  line-height: 1.2;
}

.header p {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.25;
}

.header nav { display: flex; gap: 2px; }

.header nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.header nav a:hover {
  color: var(--text);
  background: #f6f8fa;
}

.header nav a.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.last-updated {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Main ── */
.main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

/* ── Focus row + KPI cards ── */
.focus-row {
  display: grid;
  grid-template-columns: minmax(360px, 0.34fr) minmax(0, 0.66fr);
  gap: 12px;
  align-items: stretch;
}

.kpi-grid {
  display: block;
  min-width: 0;
}

.support-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  min-width: 0;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}

.kpi-card:hover {
  border-color: #d0d7de;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.skeleton-card {
  pointer-events: none;
}

.skeleton-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
  transform: none;
}

.skeleton-line,
.skeleton-chart,
.skeleton-bars span {
  position: relative;
  overflow: hidden;
  background: #eaeef2;
  border-radius: 6px;
}

.skeleton-line::after,
.skeleton-chart::after,
.skeleton-bars span::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.58), transparent);
  animation: skeleton-shimmer 1.35s ease-in-out infinite;
}

.skeleton-line {
  width: 100%;
  height: 12px;
  margin-bottom: 10px;
}

.skeleton-value {
  height: 44px;
  margin: 8px 0 12px;
}

.skeleton-number {
  height: 26px;
  margin: 0;
}

.skeleton-row {
  display: flex;
  gap: 8px;
}

.skeleton-row .skeleton-line {
  margin-bottom: 0;
}

.skeleton-chart {
  width: 100%;
  height: 100%;
  min-height: 180px;
}

.skeleton-chart.mini {
  min-height: 56px;
  margin-top: auto;
  opacity: 0.55;
}

.w-20 { width: 20%; }
.w-24 { width: 24%; }
.w-28 { width: 28%; }
.w-32 { width: 32%; }
.w-36 { width: 36%; }
.w-42 { width: 42%; }
.w-56 { width: 56%; }
.w-64 { width: 64%; }
.w-72 { width: 72%; }
.w-80 { width: 80%; }

.skeleton-row-table {
  pointer-events: none;
}

.skeleton-row-table td {
  cursor: default;
}

.skeleton-row-table .skeleton-line {
  height: 10px;
  margin: 2px 0;
}

/* Colored top accent bar */
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.kpi-card.accent-red::before { background: var(--red); }
.kpi-card.accent-blue::before { background: var(--accent); }
.kpi-card.accent-green::before { background: var(--green); }
.kpi-card.accent-purple::before { background: var(--purple); }

.kpi-card .label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-card .value-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.kpi-card .value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.kpi-card .change {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: 20px;
}

.kpi-card .change.improving { color: var(--green); background: var(--green-subtle); }
.kpi-card .change.worsening { color: var(--red); background: var(--red-subtle); }
.kpi-card .change.neutral { color: var(--text-muted); background: var(--bg); }

.kpi-card .context {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.kpi-card .sparkline-wrap {
  margin-top: 12px;
}

.kpi-card .sparkline-wrap svg {
  display: block;
  width: 100%;
}

/* Hero card */
.kpi-card.hero {
  background: linear-gradient(135deg, #1c1c1c 0%, #2d1f1f 100%);
  border: none;
  color: #f0f6fc;
  min-height: 278px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.kpi-card.hero.improving {
  background: linear-gradient(135deg, #151f19 0%, #1e2b23 100%);
}

.kpi-card.hero.skeleton-card {
  background: linear-gradient(135deg, #151f19 0%, #1e2b23 100%);
}

.kpi-card.hero.skeleton-card .skeleton-line,
.kpi-card.hero.skeleton-card .skeleton-chart {
  background: rgba(255,255,255,0.08);
}

.kpi-card.hero::before { display: none; }

.kpi-card.hero .label { color: rgba(240,246,252,0.5); }
.kpi-card.hero .value { color: #f0f6fc; font-size: 44px; }
.kpi-card.hero .change.improving { background: rgba(26,127,55,0.2); color: #3fb950; }
.kpi-card.hero .change.worsening { background: rgba(207,34,46,0.2); color: #f85149; }
.kpi-card.hero .context { color: rgba(240,246,252,0.5); }

.hero-trend {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 26px;
  margin-bottom: 10px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.hero-trend.improving {
  background: rgba(63, 185, 80, 0.14);
  color: #3fb950;
}

.hero-trend.worsening {
  background: rgba(248, 81, 73, 0.14);
  color: #f85149;
}

.hero-value-label {
  color: rgba(240,246,252,0.58);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
  color: rgba(240,246,252,0.62);
  font-size: 12px;
  line-height: 1.35;
}

.hero-metrics span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
}

.hero-metrics strong {
  color: #f0f6fc;
  font-weight: 800;
}

.kpi-card.hero .sparkline-wrap {
  margin-top: auto;
}

.support-kpi {
  min-height: 82px;
  padding: 14px 16px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label value"
    "context value";
  align-items: center;
  column-gap: 12px;
  row-gap: 4px;
}

.support-kpi .label {
  grid-area: label;
  margin: 0;
}

.support-kpi .value-row {
  grid-area: value;
  justify-content: flex-end;
  gap: 6px;
}

.support-kpi .value {
  font-size: 26px;
}

.support-kpi .change {
  font-size: 11px;
  padding: 1px 6px;
}

.support-kpi .context {
  grid-area: context;
  margin-top: 0;
}

/* ── Charts ── */
.charts-row { margin-bottom: 0; }

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px 22px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

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

.chart-card h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.chart-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chart-note {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.chart-shell {
  position: relative;
  min-height: 220px;
}

.trend-card .chart-shell {
  min-height: 220px;
}

.chart-card canvas {
  width: 100% !important;
  height: 220px !important;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  background: repeating-linear-gradient(
    -45deg,
    transparent 0,
    transparent 10px,
    rgba(208, 215, 222, 0.22) 10px,
    rgba(208, 215, 222, 0.22) 11px
  );
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.chart-empty[hidden] {
  display: none;
}

.chart-skeleton {
  position: absolute;
  inset: 0;
  display: none;
}

.chart-shell.skeleton-loading canvas,
.chart-shell.skeleton-loading .chart-empty {
  visibility: hidden;
}

.chart-shell.skeleton-loading .chart-skeleton {
  display: block;
}

.skeleton-bars {
  display: grid;
  gap: 14px;
  padding: 30px 18px;
}

.skeleton-bars span {
  display: block;
  width: var(--w);
  height: 18px;
}

/* ── Active data filter ── */
.data-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
  font-size: 13px;
}

.data-filter-bar[hidden] {
  display: none;
}

.data-filter-bar strong {
  color: var(--text);
  font-weight: 600;
}

.data-filter-bar button {
  border: 1px solid var(--border);
  background: #f6f8fa;
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.data-filter-bar button:hover {
  background: var(--surface);
  border-color: #d0d7de;
  color: var(--text);
}

/* ── Bottom row ── */
.bottom-row {
  display: grid;
  grid-template-columns: minmax(380px, 5fr) minmax(0, 7fr);
  gap: 12px;
}

.bottom-row .chart-shell { min-height: 260px; }
.bottom-row .chart-card canvas { height: 260px !important; }

/* ── Patterns table ── */
.patterns-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: fixed;
}

.patterns-table th {
  text-align: left;
  padding: 6px 12px 10px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.patterns-table th:nth-child(2),
.patterns-table td.count {
  width: 72px;
}

.patterns-table th:nth-child(3),
.patterns-table td:nth-child(3) {
  width: 84px;
}

.patterns-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.patterns-table tr {
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.patterns-table tbody tr:hover {
  background: #f6f8fa;
}

.pattern-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  min-width: 0;
}

.pattern-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
}

.af-badge {
  display: inline-flex;
  align-items: center;
  background: var(--red-subtle);
  color: var(--red);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  line-height: 1.6;
}

.mini-bar-wrap {
  width: 60px;
  height: 6px;
  background: #eaeef2;
  border-radius: 3px;
  overflow: hidden;
}

.mini-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--blue-chart);
  min-width: 3px;
  transition: width 0.3s ease;
}

.mini-bar.af { background: var(--red-chart); }

/* ── Category cross-filter ── */
.cat-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.cat-filter-chip:hover { background: #c8e1ff; }
.cat-filter-chip .x { opacity: 0.5; font-size: 13px; }
.cat-filter-chip .x:hover { opacity: 1; }

/* ── Slide-over panel ── */
.slide-over-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.slide-over-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.slide-over {
  position: fixed;
  top: 0;
  right: 0;
  width: min(680px, 92vw);
  max-width: 92vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.slide-over-backdrop.open .slide-over {
  transform: translateX(0);
}

.slide-over-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  box-shadow: 0 1px 0 rgba(27, 31, 36, 0.02);
}

.slide-over-header h2 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 10px;
  padding-right: 32px;
  overflow-wrap: anywhere;
}

.slide-over-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.slide-over-close:hover {
  background: var(--bg);
  border-color: #d0d7de;
  color: var(--text);
}

.slide-over-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.slide-over-meta .tag {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
  font-weight: 500;
}

.slide-over-body {
  padding: 16px 24px 24px;
  flex: 1;
}

.slide-over-description {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.slide-over-body h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Ticket cards in slide-over */
.ticket-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.ticket-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(9, 105, 218, 0.22);
  transform: translateY(-1px);
}

.ticket-card.expanded {
  border-color: #b6d7ff;
  box-shadow: 0 0 0 1px rgba(9, 105, 218, 0.12);
}

.ticket-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 5px;
}

.ticket-card .ticket-id {
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.ticket-card .ticket-subject {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.ticket-card .ticket-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.ticket-card .ticket-meta span:not(:first-child)::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  margin: 0 8px 2px 0;
  border-radius: 999px;
  background: #d0d7de;
}

.ticket-expanded {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.ticket-detail-section {
  margin-top: 12px;
}

.ticket-detail-section:first-child {
  margin-top: 0;
}

.ticket-detail-section h4 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
}

.ticket-detail-section h4 span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}

.ticket-expanded dl {
  display: grid;
  grid-template-columns: minmax(112px, 0.34fr) minmax(0, 1fr);
  gap: 8px 12px;
  padding: 10px 12px;
  background: #f6f8fa;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.ticket-expanded dt {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding-top: 2px;
}

.ticket-expanded dd {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ticket-expanded pre {
  overflow: auto;
  max-height: 220px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre;
}

.ticket-messages {
  background: #f6f8fa;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 12px;
}

.ticket-message {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--border-subtle);
}

.ticket-message:first-child {
  border-top: 0;
  padding-top: 0;
}

.ticket-message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.message-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.message-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
}

.ticket-message-head span {
  color: var(--text-muted);
  font-size: 11px;
  text-align: right;
}

.ticket-message-body {
  max-height: none !important;
  background: var(--surface) !important;
  white-space: pre-wrap;
}

.ticket-attachments {
  background: #f6f8fa;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 12px;
}

.ticket-attachment {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
}

.ticket-attachment:first-child {
  border-top: 0;
  padding-top: 0;
}

.ticket-attachment a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.ticket-attachment a:hover {
  text-decoration: underline;
}

.ticket-attachment span {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.ticket-empty-detail {
  color: var(--text-muted);
  font-size: 12px;
  margin: 2px 0 0;
}

.empty-state,
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state {
  min-height: 160px;
}

.table-empty {
  height: 96px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  cursor: default;
}

.loading {
  min-height: 96px;
}

/* ── Granularity Toggle ── */
.granularity-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.granularity-toggle button {
  border: none;
  background: none;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.granularity-toggle button:not(:last-child) {
  border-right: 1px solid var(--border);
}

.granularity-toggle button:hover { color: var(--text); }
.granularity-toggle button.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ── Date Range Picker ── */
.date-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.date-picker-menu-anchor {
  position: relative;
}

.date-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.date-picker-btn:hover {
  border-color: #b6bcc4;
  background: #f6f8fa;
}

.date-picker-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(9, 105, 218, 0.18);
}

.date-picker-btn svg { opacity: 0.5; flex-shrink: 0; }
.date-picker-btn .range-text { font-variant-numeric: tabular-nums; }

.date-picker-compare {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 31px;
}

.date-picker-compare label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.date-picker-compare input[type="checkbox"] {
  accent-color: var(--accent);
}

.compare-label {
  font-size: 11px;
  color: var(--text-muted);
  background: #eaeef2;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.compare-label:empty {
  display: none;
}

/* Dropdown */
.date-picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  min-width: 200px;
  padding: 4px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top left;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.date-picker-dropdown.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.date-picker-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}

.date-picker-dropdown button:hover { background: #f6f8fa; }
.date-picker-dropdown button.selected { background: var(--accent-subtle); color: var(--accent); font-weight: 600; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .support-kpi {
    min-height: 76px;
    padding: 12px 14px;
  }

  .support-kpi .value {
    font-size: 24px;
  }

  .bottom-row { grid-template-columns: 1fr; }
  .explorer-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .focus-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .header-inner {
    padding: 10px 16px;
  }

  .header-left {
    gap: 12px;
  }

  .header p {
    display: none;
  }

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

  .last-updated {
    display: none;
  }

  .main {
    padding: 16px;
  }

  .focus-row,
  .support-kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-card.hero {
    min-height: 240px;
  }

  .chart-card {
    padding: 16px;
  }

  .chart-card .chart-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .chart-actions {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .date-picker-wrap {
    align-items: flex-start;
    flex-direction: column;
  }

  .date-picker-compare {
    min-height: auto;
  }

  .slide-over { width: 100vw; max-width: 100vw; }

  .ticket-expanded dl {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
