:root {
  color-scheme: dark;
  --bg: #111317;
  --panel: #191c22;
  --panel-2: #20242c;
  --line: #303642;
  --text: #f3f5f7;
  --muted: #9aa4b2;
  --blue: #78a8ff;
  --green: #65d887;
  --yellow: #f6c65b;
  --red: #ff746d;
  --chip: #2a303a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: #151820;
  border-bottom: 1px solid var(--line);
  min-height: 68px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, #78a8ff, #65d887);
  color: #071016;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 16px;
}

.brand h1 {
  font-size: 18px;
  margin: 0;
}

.brand p,
.muted {
  color: var(--muted);
  font-size: 11px;
  margin: 2px 0 0;
}

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

.tab,
.primary-button,
.secondary-button,
.icon-button {
  min-height: 36px;
  border-radius: 7px;
  color: var(--text);
}

.tab {
  text-align: center;
  background: transparent;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
}

.tab.active {
  background: var(--panel-2);
  color: var(--blue);
}

.sync-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.muted-status-text {
  font-size: 12px;
  color: var(--muted);
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Account Dropdown & Menu Settings Popup */
.account-menu-container {
  position: relative;
}

.icon-circle-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-circle-button:hover {
  background: var(--line);
  color: var(--blue);
  box-shadow: 0 0 10px rgba(120, 168, 255, 0.2);
}

.account-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 48px;
  width: 280px;
  background: #1a1e26;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  z-index: 1000;
}

.account-dropdown.active {
  display: block;
  animation: slideDown 0.15s ease-out;
}

.dropdown-header h4 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--blue);
}

.dropdown-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.forget-btn {
  width: 100%;
  margin-top: 4px;
}

.view-header {
  display: none;
}

.view-header h2 {
  margin: 0;
}

.view-header p {
  color: var(--muted);
  margin: 4px 0 0;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101319;
  color: var(--text);
  padding: 0 10px;
}

textarea {
  padding: 10px;
  min-height: 100px;
  resize: vertical;
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px;
  gap: 8px;
}

.primary-button {
  background: var(--blue);
  color: #071016;
  font-weight: 750;
  padding: 0 14px;
}

.secondary-button,
.icon-button {
  background: var(--panel-2);
  color: var(--text);
  padding: 0 14px;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.status-pill,
.risk-pill,
.chip {
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.filters,
.summary-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) repeat(3, auto) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

/* Group filter buttons layout */
.checkbox-label {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 1px;
}

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

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.content-grid {
  display: flex;
  position: relative;
  gap: 0;
  align-items: stretch;
  min-height: 480px;
}

.issue-list-container {
  min-width: 300px;
  max-width: 800px;
}

.resize-handle {
  width: 8px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s ease;
  z-index: 100;
  margin: 0 4px;
}

.resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 2px;
  background: var(--line);
  transition: background 0.15s ease;
}

.resize-handle:hover::after,
.resize-handle.resizing::after {
  background: var(--blue);
  width: 4px;
  left: 2px;
}

.issue-list,
.detail-panel,
.summary-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 420px;
}

.issue-card {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid transparent;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  background: transparent;
  width: 100%;
  color: var(--text);
  text-align: left;
  transition: all 0.15s ease-in-out;
}

.issue-card:hover {
  background: #1c1f26;
}

.issue-card.active {
  background: #20252e;
  border-left: 4px solid var(--blue);
}

.issue-card.active:has(.risk-high) {
  border-left-color: var(--red);
}

.issue-card.active:has(.risk-medium) {
  border-left-color: var(--yellow);
}

.issue-card.active:has(.risk-low) {
  border-left-color: var(--green);
}

.issue-card-select {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 4px;
}

.eval-select-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.issue-card-content {
  display: grid;
  gap: 9px;
  cursor: pointer;
  min-width: 0;
}

.issue-header,
.issue-meta,
.detail-header,
.detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.issue-title {
  font-weight: 780;
  overflow-wrap: anywhere;
}

.issue-summary,
.message-content {
  color: #d4d9e1;
  line-height: 1.45;
}

.issue-meta,
.detail-meta {
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}

.failure-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.risk-high {
  background: rgba(255, 116, 109, 0.17);
  color: var(--red);
}

.risk-medium {
  background: rgba(246, 198, 91, 0.16);
  color: var(--yellow);
}

.risk-low {
  background: rgba(101, 216, 135, 0.15);
  color: var(--green);
}

.detail-panel {
  padding: 18px;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.empty-state,
.loading,
.error {
  color: var(--muted);
  padding: 24px;
}

.error {
  color: var(--red);
}

.detail-panel h3,
.detail-panel h4,
.summary-content h3 {
  margin: 0 0 10px;
}

.detail-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.message {
  border: 1px solid var(--line);
  background: #141820;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.message-role {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.summary-content {
  padding: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #141820;
}

.metric strong {
  display: block;
  font-size: 28px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .filters,
  .summary-controls,
  .content-grid {
    grid-template-columns: 1fr;
  }
}

.gemini-button {
  background: linear-gradient(135deg, #78a8ff, #65d887);
  color: #071016;
  font-weight: 750;
  padding: 0 14px;
  min-height: 38px;
  border-radius: 7px;
  white-space: nowrap;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 2px 8px rgba(120, 168, 255, 0.15);
}

.gemini-button:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 4px 15px rgba(120, 168, 255, 0.35);
  transform: translateY(-1px);
}

.gemini-button:active:not(:disabled) {
  transform: translateY(1px);
}

.gemini-button:disabled {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.65;
}

/* Timeline switcher and matrix layout improvements */
.issue-list-container {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 420px;
}

.issue-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.feed-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.view-switch-container {
  display: flex;
  gap: 4px;
  background: #101319;
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.icon-toggle-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  transition: all 0.15s ease;
  min-height: auto;
}

.icon-toggle-btn.active {
  background: var(--panel-2);
  color: var(--blue);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.issue-list {
  border: 0 !important;
  border-radius: 0 !important;
  min-height: 360px;
  overflow-y: auto;
}

/* Card Timeline (Detail Card Mode) */
.card-timeline {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 4px 0 2px 0;
  flex-wrap: wrap;
  background: rgba(16, 19, 25, 0.4);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(48, 54, 66, 0.4);
}

/* Dots and Tooltips */
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  position: relative;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.timeline-dot:hover {
  transform: scale(1.35);
  box-shadow: 0 0 8px currentColor;
  z-index: 10;
}

.dot-user { background-color: var(--blue); color: var(--blue); }
.dot-asmi { background-color: var(--green); color: var(--green); }
.dot-frustration { background-color: var(--red); color: var(--red); box-shadow: 0 0 4px var(--red); }
.dot-stale { background-color: var(--yellow); color: var(--yellow); box-shadow: 0 0 4px var(--yellow); }

/* Premium CSS Tooltip */
.timeline-dot::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-6px) scale(0.9);
  background: rgba(15, 18, 24, 0.96);
  backdrop-filter: blur(4px);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 500;
  white-space: normal;
  width: 200px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.15s cubic-bezier(0.165, 0.84, 0.44, 1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  line-height: 1.4;
  overflow-wrap: break-word;
  z-index: 999;
}

.timeline-dot:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px) scale(1);
}

/* Timeline Matrix View Layout */
.matrix-row {
  display: grid;
  grid-template-columns: auto 120px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid transparent;
  background: transparent;
  transition: all 0.15s ease-in-out;
}

.matrix-row:hover {
  background: #1c1f26;
}

.matrix-row.active {
  background: #20252e;
  border-left-color: var(--blue);
}

.matrix-row.active:has(.risk-high) { border-left-color: var(--red); }
.matrix-row.active:has(.risk-medium) { border-left-color: var(--yellow); }
.matrix-row.active:has(.risk-low) { border-left-color: var(--green); }

.matrix-user-info {
  min-width: 0;
  cursor: pointer;
}

.matrix-name {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-timeline-container {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 19, 25, 0.4);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(48, 54, 66, 0.3);
  min-height: 28px;
  overflow-x: auto;
}

/* Target Message Deep-link Highlights */
.message.target-highlight {
  border-color: var(--blue) !important;
  box-shadow: 0 0 12px rgba(120, 168, 255, 0.3);
  animation: flashHighlight 1.5s ease-out;
}

.message.target-highlight-frustration {
  border-color: var(--red) !important;
  box-shadow: 0 0 12px rgba(255, 116, 109, 0.3);
  animation: flashFrustration 1.5s ease-out;
}

@keyframes flashHighlight {
  0% { background-color: rgba(120, 168, 255, 0.25); }
  100% { background-color: #141820; }
}

@keyframes flashFrustration {
  0% { background-color: rgba(255, 116, 109, 0.25); }
  100% { background-color: #141820; }
}
