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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

nav {
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

nav .nav-brand {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
}

nav .nav-links a {
  color: #ccc;
  text-decoration: none;
  margin-left: 1.5rem;
  font-size: 0.9rem;
}

nav .nav-links a:hover {
  color: #fff;
}

main {
  max-width: 960px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

h1 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

h2 {
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
  color: #555;
}

section {
  background: #fff;
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #eee;
}

th {
  font-weight: 600;
  color: #666;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.row-error {
  background: #fff5f5;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-success {
  background: #d4edda;
  color: #155724;
}

.badge-error {
  background: #f8d7da;
  color: #721c24;
}

.badge-sent {
  background: #d4edda;
  color: #155724;
}

.badge-rejected {
  background: #f8d7da;
  color: #721c24;
}

.badge-pending {
  background: #fff3cd;
  color: #856404;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  background: #d4edda;
  color: #155724;
}

.alert-warning {
  background: #fff3cd;
  color: #856404;
}

.alert a {
  color: inherit;
  font-weight: 600;
}

.muted {
  color: #888;
  font-size: 0.85rem;
}

form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Stacked form layout — use class="stacked-form" (or legacy "ai-fix-form")
   on any <form> where you want sections to stack vertically with labels
   above inputs. Overrides the default inline flex layout. */
.stacked-form, form.ai-fix-form {
  display: block;
  align-items: initial;
  gap: 0;
}
.stacked-form section, form.ai-fix-form section { margin-bottom: 1.5rem; }
.stacked-form section h2, form.ai-fix-form section h2 {
  font-size: 1rem; margin-bottom: 0.5rem; color: #1a1a2e;
  border-bottom: 1px solid #eee; padding-bottom: 0.25rem;
}
.stacked-form label, form.ai-fix-form label {
  display: block; margin-bottom: 0.75rem;
  font-size: 0.85rem; font-weight: 500; color: #555;
}
.stacked-form input[type="text"],
.stacked-form input[type="number"],
.stacked-form input[type="email"],
.stacked-form input[type="password"],
.stacked-form input[type="date"],
.stacked-form textarea,
.stacked-form select,
form.ai-fix-form input[type="text"],
form.ai-fix-form input[type="number"],
form.ai-fix-form input[type="email"],
form.ai-fix-form input[type="password"],
form.ai-fix-form textarea,
form.ai-fix-form select {
  display: block; width: 100%; max-width: 500px;
  padding: 0.4rem 0.55rem; margin-top: 0.2rem;
  border: 1px solid #ccc; border-radius: 4px;
  font: inherit; font-size: 0.9rem;
}
.stacked-form textarea, form.ai-fix-form textarea {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.8rem;
}
.stacked-form .form-help, form.ai-fix-form .form-help {
  font-size: 0.75rem; font-weight: 400;
}
.stacked-form .form-actions, form.ai-fix-form .form-actions {
  display: flex; gap: 0.5rem; align-items: center;
  margin-top: 1rem; padding-top: 1rem;
  border-top: 1px solid #eee; flex-wrap: wrap;
}
.stacked-form .form-actions form, form.ai-fix-form .form-actions form { margin: 0; }

select, button {
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 0.9rem;
}

button {
  background: #1a1a2e;
  color: #fff;
  border-color: #1a1a2e;
  cursor: pointer;
}

button:hover {
  background: #16213e;
}

button:disabled {
  background: #aaa;
  border-color: #aaa;
  cursor: not-allowed;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #1a1a2e;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.9rem;
}

.btn:hover {
  background: #16213e;
}

.btn-danger {
  background: #dc3545;
  border-color: #dc3545;
}

.btn-danger:hover {
  background: #c82333;
}

input[type="text"], input[type="email"], input[type="password"] {
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 0.9rem;
  min-width: 250px;
}

.btn-sm {
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 3px;
  border: none;
  color: #fff;
  cursor: pointer;
}

code {
  background: #f0f0f0;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85rem;
}

ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

/* Nav active state + badge */
nav .nav-links a.nav-active {
  color: #fff;
  border-bottom: 2px solid #fff;
  padding-bottom: 0.15rem;
}

.nav-badge {
  display: inline-block;
  background: #dc3545;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  margin-left: 0.25rem;
  vertical-align: top;
}

/* Metric cards grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.metric-card {
  background: #fff;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.metric-card .metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.2;
}

.metric-card .metric-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #888;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.metric-card .metric-detail {
  font-size: 0.8rem;
  color: #888;
  margin-top: 0.25rem;
}

/* Conversations */
.conversations-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.conversations-header h2 {
  margin-bottom: 0;
}

.filter-select {
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 0.8rem;
  background: #fff;
}

.conversation-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background 0.15s;
}

.conversation-row:hover {
  background: #f8f9fa;
}

.conversation-row:last-child {
  border-bottom: none;
}

.conv-main {
  min-width: 0;
}

.conv-client {
  font-weight: 600;
  font-size: 0.9rem;
  color: #333;
}

.conv-subject {
  font-size: 0.85rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-meta {
  font-size: 0.8rem;
  color: #888;
  white-space: nowrap;
  text-align: right;
}

.conv-count {
  font-size: 0.8rem;
  color: #888;
  white-space: nowrap;
}

/* Status badges */
.badge-awaiting-response {
  background: #fff3cd;
  color: #856404;
}

.badge-draft-ready {
  background: #cce5ff;
  color: #004085;
}

.badge-responded {
  background: #d4edda;
  color: #155724;
}

/* Priority badges */
.badge-priority-high {
  background: #f8d7da;
  color: #721c24;
}

.badge-priority-medium {
  background: #fff3cd;
  color: #856404;
}

.badge-priority-low {
  background: #d4edda;
  color: #155724;
}

/* Collapsible sections */
.section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
  background: none;
  border: none;
  color: #555;
  font-size: 1.15rem;
  font-weight: 600;
  padding: 0;
}

.section-toggle:hover {
  color: #333;
  background: none;
}

.section-toggle .chevron {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 0.8rem;
}

.section-collapsible.collapsed .section-body {
  display: none;
}

.section-collapsible.collapsed .chevron {
  transform: rotate(-90deg);
}

/* Thread messages (expanded view) */
.thread-messages {
  padding: 0.5rem 0.75rem;
  background: #fafafa;
  border-bottom: 1px solid #eee;
}

.thread-msg {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
  border-left: 3px solid #ccc;
}

.thread-msg:last-child {
  margin-bottom: 0;
}

.msg-client {
  border-left-color: #4a90d9;
  background: #f0f6ff;
}

.msg-support {
  border-left-color: #1a1a2e;
  background: #f5f5f8;
}

.thread-msg-from {
  font-weight: 600;
  font-size: 0.8rem;
}

.thread-msg-time {
  font-size: 0.75rem;
  color: #888;
  margin-left: 0.5rem;
}

.thread-msg-summary {
  font-size: 0.8rem;
  color: #555;
  margin-top: 0.15rem;
}

/* Approvals page */
.draft-card {
  background: #fff;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.draft-info {
  min-width: 0;
  flex: 1;
}

.draft-from {
  font-weight: 600;
  font-size: 0.9rem;
}

.draft-subject {
  font-size: 0.85rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.draft-time {
  font-size: 0.8rem;
  color: #888;
}

.conv-link {
  font-size: 0.8rem;
  white-space: nowrap;
}

.conv-link a {
  color: #4a90d9;
  text-decoration: none;
}

.conv-link a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (min-width: 480px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .conversation-row {
    grid-template-columns: 1fr auto auto auto auto auto;
  }
}

/* Tier badges */
.badge-tier-1 {
  background: #f8d7da;
  color: #721c24;
}

.badge-tier-2 {
  background: #fff3cd;
  color: #856404;
}

.badge-tier-3 {
  background: #d4edda;
  color: #155724;
}

/* Opportunity type badges */
.badge-upsell {
  background: #d4edda;
  color: #155724;
}

.badge-feature_gap {
  background: #cce5ff;
  color: #004085;
}

.badge-expansion {
  background: #e2d5f1;
  color: #4a235a;
}

.badge-technical_debt {
  background: #fde2e2;
  color: #9b1c1c;
}

/* Change severity badges */
.badge-significant {
  background: #f8d7da;
  color: #721c24;
}

.badge-notable {
  background: #fff3cd;
  color: #856404;
}

.badge-minor {
  background: #e2e8f0;
  color: #4a5568;
}

/* Review/pipeline status badges */
.badge-completed {
  background: #d4edda;
  color: #155724;
}

.badge-qualified {
  background: #cce5ff;
  color: #004085;
}

.badge-converted {
  background: #d4edda;
  color: #155724;
}

.badge-flagged {
  background: #fff3cd;
  color: #856404;
}

.badge-done {
  background: #d4edda;
  color: #155724;
}

.badge-type-new_work_ack {
  background: #e8d5f5;
  color: #6f42c1;
}

/* Opportunity card layout */
.opportunity-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem;
  border-bottom: 1px solid #eee;
}

.opportunity-card:last-child {
  border-bottom: none;
}

.opportunity-info {
  flex: 1;
  min-width: 0;
}

.opportunity-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Change item styling */
.change-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
}

.change-item:last-child {
  border-bottom: none;
}

/* Project status badges */
.badge-project-draft {
  background: #e2e8f0;
  color: #4a5568;
}

.badge-project-active {
  background: #cce5ff;
  color: #004085;
}

.badge-project-on_hold {
  background: #fff3cd;
  color: #856404;
}

.badge-project-completed {
  background: #d4edda;
  color: #155724;
}

.badge-project-cancelled {
  background: #f8d7da;
  color: #721c24;
}

/* Project health badges */
.badge-health-on_track {
  background: #d4edda;
  color: #155724;
}

.badge-health-at_risk {
  background: #fff3cd;
  color: #856404;
}

.badge-health-overdue {
  background: #f8d7da;
  color: #721c24;
}

/* Progress bars */
.progress-bar-container {
  display: inline-block;
  width: 80px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 0.35rem;
}

.progress-bar {
  height: 100%;
  background: #28a745;
  border-radius: 3px;
  transition: width 0.3s;
}

/* Gantt chart */
.gantt-chart {
  overflow-x: auto;
  position: relative;
  padding: 0.5rem 0;
}

.gantt-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #dc3545;
  z-index: 2;
  opacity: 0.6;
}

.gantt-phase-label {
  font-weight: 600;
  font-size: 0.8rem;
  color: #555;
  text-transform: uppercase;
  padding: 0.6rem 0 0.25rem;
  border-top: 1px solid #eee;
}

.gantt-phase-label:first-child {
  border-top: none;
  padding-top: 0;
}

.gantt-row {
  display: flex;
  align-items: center;
  padding: 0.2rem 0;
  min-height: 28px;
}

.gantt-label {
  width: 180px;
  min-width: 180px;
  font-size: 0.8rem;
  color: #555;
  padding-right: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-bar-area {
  flex: 1;
  position: relative;
  height: 18px;
  background: #f8f9fa;
  border-radius: 3px;
}

.gantt-bar {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 3px;
  min-width: 4px;
}

.gantt-pending {
  background: #dee2e6;
}

.gantt-in-progress {
  background: #4a90d9;
}

.gantt-awaiting {
  background: #ffc107;
}

.gantt-completed {
  background: #28a745;
}

.gantt-overdue {
  background: #dc3545;
}

/* Plan review phase styling */
.plan-phase {
  margin-bottom: 1rem;
}

.plan-phase table {
  margin-top: 0.25rem;
}

.badge-approved {
  background: #d4edda;
  color: #155724;
}

.badge-feedback {
  background: #fff3cd;
  color: #856404;
}

@media (max-width: 600px) {
  .conversation-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
  .conv-meta, .conv-count {
    text-align: left;
  }
  .draft-card {
    flex-direction: column;
    align-items: flex-start;
  }
  nav {
    flex-direction: column;
    gap: 0.5rem;
  }
  nav .nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  nav .nav-links a {
    margin-left: 0;
  }
}

/* ===== Tickets ===== */
.tickets-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.tickets-header h1 {
  margin: 0;
}

.ticket-count {
  font-size: 0.85rem;
}

.ticket-filters {
  background: #fff;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.ticket-filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: flex-end;
}

.ticket-search {
  flex: 1 1 200px;
  min-width: 180px;
  padding: 0.45rem 0.65rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.88rem;
}

.ticket-filter {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.75rem;
  color: #666;
}

.ticket-filter span {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.ticket-filter .filter-select {
  padding: 0.4rem 0.55rem;
  font-size: 0.85rem;
  min-width: 120px;
}

.ticket-filters-reset {
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.ticket-filters-reset a {
  color: #4a90d9;
  text-decoration: none;
}

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

@media (max-width: 600px) {
  .ticket-filter,
  .ticket-search {
    flex: 1 1 100%;
  }
  .ticket-filter .filter-select {
    width: 100%;
  }
}

.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ticket-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  text-decoration: none;
  color: inherit;
  border-left: 4px solid #e5e7eb;
  transition: box-shadow 0.15s, transform 0.05s;
}

.ticket-card.priority-high {
  border-left-color: #dc3545;
}

.ticket-card.priority-medium {
  border-left-color: #f59e0b;
}

.ticket-card.priority-low {
  border-left-color: #16a34a;
}

.ticket-card.priority-none {
  border-left-color: #e5e7eb;
}

.ticket-card:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.ticket-card-main {
  flex: 1;
  min-width: 0;
}

.ticket-card-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.ticket-client {
  font-weight: 600;
  font-size: 0.92rem;
  color: #1a1a2e;
}

.ticket-subject {
  font-size: 0.88rem;
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.ticket-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
  font-size: 0.78rem;
  color: #777;
}

.ticket-card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  text-align: right;
  font-size: 0.78rem;
  color: #888;
  white-space: nowrap;
  padding-top: 0.1rem;
  flex-shrink: 0;
}

.ticket-time {
  white-space: nowrap;
  color: #555;
}

.ticket-meta-line {
  white-space: nowrap;
  color: #666;
  font-size: 0.78rem;
}

.ticket-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.75rem;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-size: 0.88rem;
}

.page-link {
  color: #1a1a2e;
  text-decoration: none;
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  transition: background 0.15s;
}

.page-link:hover {
  background: #f1f3f5;
}

.page-link.disabled {
  color: #ccc;
  cursor: default;
}

.page-link.disabled:hover {
  background: transparent;
}

.page-indicator {
  color: #555;
  font-weight: 500;
}

/* ===== Ticket detail ===== */
.ticket-detail-back {
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.ticket-detail-back a {
  color: #555;
  text-decoration: none;
}

.ticket-detail-back a:hover {
  color: #1a1a2e;
}

.ticket-detail-header {
  background: #fff;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.ticket-detail-title h1 {
  font-size: 1.25rem;
  margin: 0 0 0.4rem;
  line-height: 1.3;
}

.ticket-detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.btn-secondary {
  background: #fff;
  color: #1a1a2e;
  border: 1px solid #1a1a2e;
  text-decoration: none;
  white-space: nowrap;
}

.btn-secondary:hover {
  background: #1a1a2e;
  color: #fff;
}

.ticket-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .ticket-detail-grid {
    grid-template-columns: 1fr 260px;
  }
  .ticket-detail-grid .ticket-sidebar {
    order: 2;
  }
  .ticket-detail-grid .ticket-timeline {
    order: 1;
  }
}

.ticket-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ticket-sidebar-block {
  background: #fff;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-size: 0.85rem;
}

.sidebar-block-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 0.2rem;
}

.sidebar-block-value {
  font-weight: 600;
  color: #1a1a2e;
}

.sidebar-draft {
  border-left: 3px solid #4a90d9;
}

.ticket-timeline {
  background: #fff;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.timeline-item {
  padding: 0.65rem 0.85rem;
  border-radius: 4px;
  border-left: 3px solid #ccc;
  background: #fafafa;
}

.timeline-email.timeline-client {
  border-left-color: #4a90d9;
  background: #f0f6ff;
}

.timeline-email.timeline-support {
  border-left-color: #1a1a2e;
  background: #f5f5f8;
}

.timeline-comment {
  border-left-color: #28a745;
  background: #f5fbf7;
}

.timeline-item-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.timeline-item-author {
  font-weight: 600;
  color: #1a1a2e;
}

.timeline-item-kind {
  color: #666;
  font-size: 0.78rem;
}

.timeline-item-time {
  color: #888;
  font-size: 0.78rem;
  margin-left: auto;
}

.timeline-item-body {
  font-size: 0.88rem;
  color: #333;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dashboard-header h1 {
  margin: 0;
}

/* ===== Ticket detail Phase 2: actions, notes, drafts, composer ===== */
.ticket-detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.ticket-main {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Internal note timeline item — distinct from green TW comment */
.timeline-item.timeline-note {
  border-left-color: #f59e0b;
  background: #fffaf0;
}

/* Pending draft banner */
.pending-draft {
  background: #fff;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border-left: 4px solid #4a90d9;
}

.pending-draft-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.pending-draft-label {
  font-weight: 600;
  color: #1a1a2e;
  font-size: 0.95rem;
}

.pending-draft-source {
  background: #f8f9fa;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  border-left: 2px solid #ccc;
}

.pending-draft-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pending-draft-textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.pending-draft-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Composer */
.composer {
  background: #fff;
  border-radius: 6px;
  padding: 0.75rem 1rem 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.composer-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid #eee;
  margin-bottom: 0.75rem;
}

.composer-tab {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  position: relative;
  padding: 0.4rem 0.75rem 0.6rem;
  font-size: 0.88rem;
  color: #777;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.1s, border-color 0.1s;
}

.composer-tab input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.composer-tab:has(input[type="radio"]:checked) {
  color: #1a1a2e;
  border-bottom-color: #1a1a2e;
  font-weight: 600;
}

.composer-tab:hover {
  color: #333;
}

.composer-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.composer-textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.composer-hint {
  font-size: 0.8rem;
}

.ticket-sidebar-danger {
  text-align: center;
  background: transparent;
  box-shadow: none;
  padding: 0.25rem;
}

.btn-link-danger {
  background: none;
  border: none;
  color: #dc3545;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  text-decoration: underline;
}

.btn-link-danger:hover {
  color: #a71d2a;
}

.attachment-list {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.attachment-list li {
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
}

.attachment-list a {
  color: #4a90d9;
  text-decoration: none;
  word-break: break-all;
}

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

.attachment-size {
  font-size: 0.75rem;
  white-space: nowrap;
}
