/* ============================================================
 * COMAN Support Portal — Material Design 2
 * Brand: #0f3460 (navy), #00b0ea (cyan), #3182ce (accent)
 * Grid: 8px rhythm · Elevation: MD2 shadow system
 * ============================================================ */

/* --- MD2 Design Tokens (CSS Variables) --- */
:root {
  /* Primary palette */
  --md-primary: #0f3460;
  --md-primary-variant: #1a4a8a;
  --md-primary-light: #e8eef6;
  --md-on-primary: #fff;

  /* Secondary palette */
  --md-secondary: #00b0ea;
  --md-secondary-variant: #0090c0;
  --md-on-secondary: #fff;

  /* Accent */
  --md-accent: #3182ce;

  /* Surfaces & backgrounds */
  --md-background: #f5f5f5;
  --md-surface: #fff;
  --md-on-surface: #212121;
  --md-on-surface-medium: #666;
  --md-on-surface-disabled: #9e9e9e;

  /* State layers */
  --md-state-hover: rgba(15, 52, 96, .04);
  --md-state-focus: rgba(15, 52, 96, .08);
  --md-state-pressed: rgba(15, 52, 96, .12);
  --md-state-selected: rgba(15, 52, 96, .08);

  /* Feedback */
  --md-error: #b00020;
  --md-success: #2e7d32;
  --md-warning: #e65100;
  --md-info: #0277bd;

  /* Dividers */
  --md-divider: rgba(0, 0, 0, .12);

  /* Elevation shadows (MD2 spec) */
  --md-elevation-1: 0 1px 1px 0 rgba(0,0,0,.14), 0 2px 1px -1px rgba(0,0,0,.12), 0 1px 3px 0 rgba(0,0,0,.20);
  --md-elevation-2: 0 2px 2px 0 rgba(0,0,0,.14), 0 3px 1px -2px rgba(0,0,0,.12), 0 1px 5px 0 rgba(0,0,0,.20);
  --md-elevation-4: 0 4px 5px 0 rgba(0,0,0,.14), 0 1px 10px 0 rgba(0,0,0,.12), 0 2px 4px -1px rgba(0,0,0,.20);
  --md-elevation-6: 0 6px 10px 0 rgba(0,0,0,.14), 0 1px 18px 0 rgba(0,0,0,.12), 0 3px 5px -1px rgba(0,0,0,.20);
  --md-elevation-8: 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12), 0 5px 5px -3px rgba(0,0,0,.20);
  --md-elevation-16: 0 16px 24px 2px rgba(0,0,0,.14), 0 6px 30px 5px rgba(0,0,0,.12), 0 8px 10px -5px rgba(0,0,0,.20);

  /* Shape */
  --md-shape-sm: 4px;
  --md-shape-md: 8px;
  --md-shape-lg: 12px;

  /* Motion */
  --md-motion-standard: cubic-bezier(.4, 0, .2, 1);
  --md-motion-decel: cubic-bezier(0, 0, .2, 1);
  --md-motion-accel: cubic-bezier(.4, 0, 1, 1);
}

/* --- Reset & Base --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: Roboto, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--md-on-surface);
  background: var(--md-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- MD2 Badges --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--md-on-primary);
}
.badge-blue { background: var(--md-accent); }
.badge-green { background: var(--md-success); }
.badge-orange { background: var(--md-warning); }
.badge-red { background: var(--md-error); }
.badge-gray { background: #757575; }
.prio-high { color: var(--md-error); font-weight: 500; }
.prio-mid { color: var(--md-warning); font-weight: 500; }
.prio-low { color: var(--md-on-surface-disabled); font-weight: 500; }

/* --- MD2 App Bar (Elevation dp4) --- */
.app-header {
  background: var(--md-primary);
  color: var(--md-on-primary);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--md-elevation-4);
}
.app-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: .01em;
}
.app-logo span {
  color: var(--md-secondary);
  font-weight: 400;
  font-size: 14px;
  margin-left: 4px;
}
.app-nav { display: flex; gap: 0; align-items: center; height: 100%; }
.app-nav a {
  color: rgba(255,255,255,.7);
  text-decoration: none;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .02em;
  border-bottom: 2px solid transparent;
  transition: color 200ms var(--md-motion-standard),
              background 200ms var(--md-motion-standard),
              border-color 200ms var(--md-motion-standard);
}
.app-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}
.app-nav a.active {
  color: #fff;
  border-bottom-color: var(--md-secondary);
}
.app-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--md-accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 14px; color: #fff;
  letter-spacing: .02em;
  flex-shrink: 0;
}

/* --- Profile Dropdown --- */
.profile-wrapper { position: relative; }
.profile-trigger {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: #fff;
  cursor: pointer; padding: 4px 8px; border-radius: var(--md-shape-sm);
  transition: background 150ms var(--md-motion-standard);
  font-family: inherit; font-size: 14px;
}
.profile-trigger:hover { background: rgba(255,255,255,.08); }
.profile-trigger.open { background: rgba(255,255,255,.12); }
.profile-trigger-name { color: rgba(255,255,255,.87); font-weight: 400; }
.profile-trigger-arrow {
  opacity: .6;
  transition: transform 200ms var(--md-motion-standard), opacity 200ms;
}
.profile-trigger.open .profile-trigger-arrow { transform: rotate(180deg); opacity: 1; }

.profile-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--md-surface); color: var(--md-on-surface);
  border-radius: var(--md-shape-sm);
  box-shadow: var(--md-elevation-8);
  min-width: 260px;
  opacity: 0; transform: translateY(-8px) scale(.97);
  pointer-events: none;
  transition: opacity 180ms var(--md-motion-standard),
              transform 180ms var(--md-motion-standard);
  z-index: 200;
  overflow: hidden;
}
.profile-menu.open {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: auto;
}
.profile-menu-header {
  display: flex; gap: 12px; align-items: center;
  padding: 16px 20px;
  background: var(--md-primary-light);
}
.profile-menu-header .profile-menu-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--md-accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px; color: #fff;
  flex-shrink: 0;
}
.profile-menu-info { min-width: 0; }
.profile-menu-name { font-weight: 500; font-size: 14px; color: var(--md-on-surface); }
.profile-menu-email { font-size: 12px; color: var(--md-on-surface-medium); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-menu-company { font-size: 11px; color: var(--md-on-surface-disabled); margin-top: 2px; }
.profile-menu-divider { height: 1px; background: var(--md-divider); }
.profile-menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  color: var(--md-on-surface); text-decoration: none;
  font-size: 14px;
  transition: background 120ms var(--md-motion-standard);
}
.profile-menu-item:hover { background: var(--md-state-hover); }
.profile-menu-item svg { color: var(--md-on-surface-medium); flex-shrink: 0; }
.profile-menu-logout { color: var(--md-error); }
.profile-menu-logout svg { color: var(--md-error); }

/* --- Main Content Area --- */
.app-main { padding: 20px 2.5vw 40px; width: 95vw; margin: 0 auto; }

/* --- Page Header --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title {
  font-size: 24px;
  color: var(--md-on-surface);
  font-weight: 400;
  letter-spacing: .01em;
}
.page-subtitle {
  color: var(--md-on-surface-medium);
  font-size: 14px;
  margin-top: 4px;
  font-weight: 400;
}

/* --- MD2 Stat Cards (Elevation dp1 → dp2 on hover) --- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--md-surface);
  border-radius: var(--md-shape-md);
  padding: 20px 24px;
  box-shadow: var(--md-elevation-1);
  border-left: 4px solid var(--md-divider);
  transition: box-shadow 280ms var(--md-motion-standard),
              transform 280ms var(--md-motion-standard);
}
.stat-card.open { border-left-color: var(--md-accent); }
.stat-card.progress { border-left-color: var(--md-warning); }
.stat-card.waiting { border-left-color: #7b1fa2; }
.stat-card.closed { border-left-color: var(--md-success); }
.stat-number {
  font-size: 34px;
  font-weight: 400;
  color: var(--md-on-surface);
  letter-spacing: .01em;
}
.stat-label {
  font-size: 12px;
  color: var(--md-on-surface-medium);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
}
.stat-filter { cursor: pointer; }
.stat-filter:hover {
  transform: translateY(-2px);
  box-shadow: var(--md-elevation-4);
}
.stat-filter.active {
  box-shadow: var(--md-elevation-2);
  outline: 2px solid var(--md-primary);
  outline-offset: -2px;
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* --- MD2 Search Input (Outlined) --- */
.search-input {
  flex: 1; min-width: 240px;
  padding: 12px 16px 12px 40px;
  border: 1px solid rgba(0,0,0,.38);
  border-radius: var(--md-shape-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--md-on-surface);
  background: var(--md-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") 12px center no-repeat;
  transition: border-color 200ms var(--md-motion-standard),
              box-shadow 200ms var(--md-motion-standard);
}
.search-input:hover { border-color: var(--md-on-surface); }
.search-input:focus {
  outline: none;
  border-color: var(--md-primary);
  border-width: 2px;
  padding: 11px 15px 11px 39px;
  box-shadow: none;
}

/* --- MD2 Data Table --- */
.ticket-table-wrap {
  background: var(--md-surface);
  border-radius: var(--md-shape-md);
  box-shadow: var(--md-elevation-1);
  overflow-x: auto;
  overflow-y: auto;
}
.ticket-table-wrap thead th { position: sticky; top: 0; z-index: 3; }
.ticket-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.ticket-table th {
  background: var(--md-primary);
  color: var(--md-on-primary);
  font-weight: 500;
  padding: 14px 16px;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-right: 1px solid rgba(255,255,255,.18);
  position: relative;
  overflow: visible;
}
.ticket-table th:last-child { border-right: none; }
.ticket-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--md-divider);
  vertical-align: top;
}

/* --- Column resize handle --- */
.col-resize-handle {
  position: absolute;
  right: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 5;
  background: transparent;
  transition: background 150ms;
}
.col-resize-handle:hover,
.col-resize-handle.resizing {
  background: rgba(0,176,234,.5);
}
/* Grip dots indicator */
.col-resize-handle::after {
  content: "⋮";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: rgba(255,255,255,.45);
  pointer-events: none;
}
.col-resize-handle:hover::after,
.col-resize-handle.resizing::after {
  color: #fff;
}
.ticket-table tr:hover td {
  background: rgba(15, 52, 96, .08);
}
.ticket-table tbody tr { cursor: pointer; }
.ticket-id { color: var(--md-accent); font-weight: 500; font-size: 13px; }
.ticket-subject {
  font-weight: 500;
  color: var(--md-on-surface);
  margin-bottom: 2px;
  display: block;
}
.ticket-desc {
  color: var(--md-on-surface-medium);
  font-size: 12px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ticket-date { font-size: 13px; color: var(--md-on-surface-medium); white-space: nowrap; }
.ticket-phase { font-size: 13px; color: var(--md-on-surface-medium); }

/* --- MD2 Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 16px;
  height: 36px;
  border-radius: var(--md-shape-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: .02em;
  text-transform: none;
  border: none;
  cursor: pointer;
  transition: box-shadow 280ms var(--md-motion-standard),
              background 280ms var(--md-motion-standard);
  text-decoration: none;
  white-space: nowrap;
}
/* Contained button (primary) */
.btn-primary {
  background: var(--md-primary);
  color: var(--md-on-primary);
  box-shadow: var(--md-elevation-2);
}
.btn-primary:hover {
  background: var(--md-primary-variant);
  box-shadow: var(--md-elevation-4);
}
.btn-primary:active {
  box-shadow: var(--md-elevation-8);
}
/* Outlined button (secondary) */
.btn-secondary {
  background: transparent;
  color: var(--md-primary);
  border: 1px solid rgba(0,0,0,.23);
  box-shadow: none;
}
.btn-secondary:hover {
  background: var(--md-state-hover);
  border-color: var(--md-primary);
}
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

/* --- MD2 Form Elements (Outlined) --- */
.form-card {
  background: var(--md-surface);
  border-radius: var(--md-shape-md);
  padding: 24px;
  box-shadow: var(--md-elevation-1);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.form-row .form-group { margin-bottom: 0; }
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-on-surface-medium);
  margin-bottom: 8px;
  letter-spacing: .02em;
}
.form-label .required { color: var(--md-error); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(0,0,0,.38);
  border-radius: var(--md-shape-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--md-on-surface);
  background: var(--md-surface);
  transition: border-color 200ms var(--md-motion-standard);
}
.form-input:hover, .form-select:hover, .form-textarea:hover {
  border-color: var(--md-on-surface);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--md-primary);
  border-width: 2px;
  padding: 11px 15px;
}
.form-textarea { min-height: 160px; resize: vertical; line-height: 1.6; }
.form-textarea:focus { padding: 11px 15px; }
.form-hint {
  font-size: 12px;
  color: var(--md-on-surface-medium);
  margin-top: 4px;
  letter-spacing: .02em;
}

/* --- Form Feedback --- */
.form-feedback {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--md-shape-sm);
  font-size: 14px;
  line-height: 1.5;
}
.form-feedback-error {
  background: #fce4ec;
  border-left: 4px solid var(--md-error);
  color: #b71c1c;
}
.form-feedback-success {
  background: #e8f5e9;
  border-left: 4px solid var(--md-success);
  color: #1b5e20;
}
.form-feedback-info {
  background: #e3f2fd;
  border-left: 4px solid var(--md-info);
  color: #01579b;
}

/* --- File Upload (MD2 Surface) --- */
.upload-zone {
  border: 2px dashed rgba(0,0,0,.23);
  border-radius: var(--md-shape-md);
  padding: 32px;
  text-align: center;
  transition: border-color 200ms var(--md-motion-standard),
              background 200ms var(--md-motion-standard);
  cursor: pointer;
  background: var(--md-background);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--md-primary);
  background: var(--md-primary-light);
}
.upload-zone-text { color: var(--md-on-surface-medium); font-size: 14px; margin-top: 8px; }
.upload-zone-text strong { color: var(--md-primary); }
.upload-zone-hint { color: var(--md-on-surface-disabled); font-size: 12px; margin-top: 4px; }
.upload-files { margin-top: 8px; }
.upload-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--md-background);
  border-radius: var(--md-shape-sm);
  margin-top: 8px;
  font-size: 13px;
}
.upload-file-name { flex: 1; }
.upload-file-size { color: var(--md-on-surface-disabled); font-size: 12px; }
.upload-file-remove {
  color: var(--md-error);
  cursor: pointer;
  font-size: 18px;
  border: none;
  background: none;
  padding: 0 4px;
  line-height: 1;
  border-radius: 50%;
  transition: background 150ms var(--md-motion-standard);
}
.upload-file-remove:hover { background: rgba(176,0,32,.08); color: #d32f2f; }

/* --- Attachment Grid --- */
.attachment-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.attachment-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  background: var(--md-background);
  border-radius: var(--md-shape-sm);
  text-decoration: none;
  color: var(--md-on-surface);
  transition: background 200ms var(--md-motion-standard),
              box-shadow 200ms var(--md-motion-standard);
  border: 1px solid transparent;
  min-width: 140px;
  max-width: 200px;
}
.attachment-card:hover {
  background: var(--md-primary-light);
  border-color: var(--md-primary);
  box-shadow: var(--md-elevation-1);
}
.attachment-icon {
  flex-shrink: 0;
  color: var(--md-on-surface-medium);
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
}
.attachment-thumb {
  flex-shrink: 0;
  width: 48px; height: 48px;
  border-radius: var(--md-shape-sm);
  overflow: hidden;
  background: #e0e0e0;
}
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attachment-card.has-thumb { padding: 6px 16px 6px 6px; }
.attachment-info {
  display: flex; flex-direction: column;
  align-items: center;
  overflow: hidden;
  width: 100%;
}
.attachment-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  max-width: 100%;
}
.attachment-size { font-size: 12px; color: var(--md-on-surface-disabled); }
.attachment-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  justify-content: center;
  width: 100%;
}
.attachment-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  color: var(--md-primary);
  text-decoration: none;
  border-radius: var(--md-shape-sm);
  background: #fff;
  border: 1.5px solid var(--md-primary);
  line-height: 1;
  box-shadow: var(--md-elevation-1);
  transition: background 150ms var(--md-motion-standard),
              color 150ms var(--md-motion-standard),
              box-shadow 150ms var(--md-motion-standard);
}
.attachment-action-btn:hover {
  background: var(--md-primary);
  color: #fff;
  box-shadow: var(--md-elevation-2);
}
.attachment-action-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

/* --- Submit-Loading-Feedback (siehe static/js/submit-loading.js) --- */
@keyframes btn-spinner-rotate { to { transform: rotate(360deg); } }
.btn-spinner {
  animation: btn-spinner-rotate 0.8s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}
form.js-submit-loading button[disabled] {
  opacity: .7;
  cursor: progress;
}

/* --- Reply Upload Zone --- */
.reply-upload-zone {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px dashed rgba(0,0,0,.23);
  border-radius: var(--md-shape-sm);
  padding: 12px 16px;
  margin: 8px 0;
  cursor: pointer;
  transition: all 200ms var(--md-motion-standard);
  font-size: 13px;
  color: var(--md-on-surface-medium);
  background: var(--md-background);
}
.reply-upload-zone:hover, .reply-upload-zone.dragover {
  border-color: var(--md-primary);
  background: var(--md-primary-light);
  color: var(--md-primary);
}
.reply-upload-zone strong { color: var(--md-primary); }

/* --- Ticket Closed Hint --- */
.ticket-closed-hint {
  background: #e3f2fd;
  border-left: 4px solid var(--md-info);
  border-radius: 0 var(--md-shape-sm) var(--md-shape-sm) 0;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #01579b;
  line-height: 1.5;
}

/* --- Detail View --- */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}
.detail-id {
  font-size: 14px;
  color: var(--md-accent);
  font-weight: 500;
  margin-bottom: 4px;
  letter-spacing: .02em;
}
.detail-title {
  font-size: 24px;
  font-weight: 400;
  color: var(--md-on-surface);
  margin-bottom: 8px;
  letter-spacing: .01em;
}
.detail-meta { display: flex; gap: 24px; flex-wrap: wrap; }
.detail-meta-item { font-size: 14px; color: var(--md-on-surface-medium); }
.detail-meta-item strong { color: var(--md-on-surface); font-weight: 500; }
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }
.detail-main, .detail-sidebar {
  background: var(--md-surface);
  border-radius: var(--md-shape-md);
  box-shadow: var(--md-elevation-1);
}
.detail-main { padding: 24px; }
.detail-sidebar { padding: 24px; height: fit-content; }
.detail-section-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-on-surface);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--md-divider);
  letter-spacing: .02em;
}
.detail-description {
  font-size: 14px;
  line-height: 1.7;
  color: var(--md-on-surface);
  margin-bottom: 24px;
  white-space: pre-line;
}

/* --- Comments (MD2 Card-like) --- */
.comment {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--md-divider);
}
.comment:last-child { border-bottom: none; }
.comment-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 14px; color: #fff; flex-shrink: 0;
  letter-spacing: .02em;
}
.comment-avatar.support { background: var(--md-primary); }
.comment-avatar.customer { background: var(--md-success); }
.comment-body { flex: 1; min-width: 0; }
.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.comment-author { font-weight: 500; font-size: 14px; color: var(--md-on-surface); }
/* Rolle "(Support)"/"(Kunde)" — klar vom Namen abgesetzt, in Rollenfarbe,
   mit kleinem vorangestellten Icon (Headset/Person). */
.comment-role {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .01em;
}
.comment-role.support { color: var(--md-primary); }
.comment-role.customer { color: var(--md-success); }
.comment-time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--md-on-surface-disabled);
}
/* Inline-SVG-Icons in der Comment-Header-Zeile, erben die Textfarbe. */
.comment-icon { width: 13px; height: 13px; flex-shrink: 0; }
.comment-time .comment-icon { width: 12px; height: 12px; }
.comment-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--md-on-surface-medium);
}
.comment-input-area {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--md-divider);
}
.comment-textarea {
  width: 100%; min-height: 80px; padding: 12px 16px;
  border: 1px solid rgba(0,0,0,.38);
  border-radius: var(--md-shape-sm);
  font-family: inherit; font-size: 14px; resize: vertical;
  margin-bottom: 8px;
  transition: border-color 200ms var(--md-motion-standard);
}
.comment-textarea:hover { border-color: var(--md-on-surface); }
.comment-textarea:focus {
  outline: none;
  border-color: var(--md-primary);
  border-width: 2px;
  padding: 11px 15px;
}

/* --- Sidebar --- */
.sidebar-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--md-divider);
}
.sidebar-item:last-child { border-bottom: none; }
.sidebar-label {
  font-size: 11px;
  color: var(--md-on-surface-disabled);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
  margin-bottom: 4px;
}
.sidebar-value {
  font-size: 14px;
  color: var(--md-on-surface);
  font-weight: 400;
}
.sidebar-subline {
  font-size: 11px;
  color: var(--md-on-surface-medium);
  margin-top: 2px;
  word-break: break-all;
}
.sidebar-empty {
  font-size: 12px;
  color: var(--md-on-surface-medium);
  font-style: italic;
  padding: 8px 0 4px;
}

/* --- Beteiligte Kontakte (Sidebar) --- */
.contact-card {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--md-surface-variant, #f5f5f7);
  border-radius: 6px;
  border-left: 3px solid var(--md-divider);
}
.contact-card:last-child { margin-bottom: 0; }
.contact-name {
  font-size: 13px;
  color: var(--md-on-surface);
  font-weight: 500;
  line-height: 1.3;
}
.contact-initials {
  font-size: 11px;
  color: var(--md-on-surface-medium);
  font-weight: 400;
  margin-left: 4px;
}
.contact-email {
  font-size: 11px;
  color: var(--md-on-surface-medium);
  word-break: break-all;
  margin-top: 3px;
}

/* --- Back Link --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--md-on-surface-medium);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 16px;
  padding: 4px 8px 4px 0;
  border-radius: var(--md-shape-sm);
  transition: color 200ms var(--md-motion-standard),
              background 200ms var(--md-motion-standard);
}
.back-link:hover { color: var(--md-primary); background: var(--md-state-hover); }

/* --- Auth Pages (Login) --- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--md-primary);
  background-image:
    radial-gradient(ellipse at 20% 80%, rgba(0,176,234,.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(49,130,206,.1) 0%, transparent 50%);
}
.auth-card {
  background: var(--md-surface);
  border-radius: var(--md-shape-lg);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--md-elevation-16);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo h1 {
  font-size: 20px;
  color: var(--md-on-surface);
  margin-top: 16px;
  font-weight: 500;
}
.auth-logo p {
  color: var(--md-on-surface-medium);
  font-size: 14px;
  margin-top: 8px;
  font-weight: 400;
}
.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 13px;
  color: var(--md-on-surface-medium);
  line-height: 1.6;
}
.auth-footer a {
  color: var(--md-primary);
  text-decoration: none;
  font-weight: 500;
}
.auth-footer a:hover { text-decoration: underline; }

/* Auth Divider */
.auth-divider {
  display: flex; align-items: center; margin: 24px 0; gap: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--md-divider);
}
.auth-divider span {
  font-size: 12px;
  color: var(--md-on-surface-disabled);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
}

/* Microsoft SSO Button */
.btn-microsoft {
  width: 100%;
  justify-content: center;
  position: relative;
  background: var(--md-surface);
  color: var(--md-on-surface);
  border: 1px solid rgba(0,0,0,.23);
  font-weight: 500;
}
.btn-microsoft:hover:not(:disabled) {
  background: var(--md-state-hover);
  border-color: var(--md-on-surface);
}
.btn-microsoft:disabled { opacity: .38; cursor: not-allowed; }
.coming-soon {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 10px;
  background: #7b1fa2;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: .02em;
}

/* --- Flash Messages (MD2 Snackbar-like) --- */
.flash-messages { max-width: 1400px; margin: 0 auto; padding: 16px 32px 0; }
.flash {
  padding: 12px 16px;
  border-radius: var(--md-shape-sm);
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 400;
  box-shadow: var(--md-elevation-1);
}
.flash-error {
  background: #fce4ec;
  color: var(--md-error);
  border-left: 4px solid var(--md-error);
}
.flash-success {
  background: #e8f5e9;
  color: var(--md-success);
  border-left: 4px solid var(--md-success);
}
.flash-info {
  background: #e3f2fd;
  color: var(--md-info);
  border-left: 4px solid var(--md-info);
}

/* --- Search Bar --- */
.search-bar { margin-bottom: 16px; }
.search-input-wrap { position: relative; }
.search-bar-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.search-bar .search-input {
  width: 100%;
  padding: 12px 44px 12px 44px;
  border: 1px solid rgba(0,0,0,.38);
  border-radius: var(--md-shape-sm);
  font-size: 14px;
  background: var(--md-surface);
  transition: border-color 200ms var(--md-motion-standard);
}
.search-bar .search-input:hover { border-color: var(--md-on-surface); }
.search-bar .search-input:focus {
  outline: none;
  border-color: var(--md-primary);
  border-width: 2px;
  padding: 11px 43px 11px 43px;
}
.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--md-on-surface-medium);
  font-size: 18px;
  cursor: pointer;
  transition: background 150ms var(--md-motion-standard);
  padding: 0;
  line-height: 1;
}
.search-clear:hover { background: var(--md-state-hover); }
/* --- Export-Dropdown auf der Ticket-Liste --- */
.export-dropdown { position: relative; display: inline-block; }
.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 280px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  border: 1px solid #e2e8f0;
  z-index: 100;
  overflow: hidden;
}
.export-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--md-on-surface);
  font-family: inherit;
  font-size: 13px;
}
.export-menu-item:hover { background: var(--md-state-hover, #f5f5f7); }
.export-menu-item + .export-menu-item { border-top: 1px solid #f0f1f4; }
.export-menu-item svg { flex: 0 0 auto; }

/* --- Filter-Result-Counter (Pill mit Icon, prominent) --- */
.filter-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 12px;
  background: var(--md-primary);
  color: #fff;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(15, 52, 96, .2);
}
.filter-counter svg { flex: 0 0 auto; }
.filter-counter-empty {
  background: #c62828;
  box-shadow: 0 1px 2px rgba(198, 40, 40, .25);
}

/* --- View Toggle (MD2 Segmented Button) --- */
.view-toggle {
  display: flex;
  border: 1px solid rgba(0,0,0,.23);
  border-radius: var(--md-shape-sm);
  overflow: hidden;
}
.view-toggle-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 16px;
  border: none;
  background: var(--md-surface);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--md-on-surface-medium);
  transition: all 200ms var(--md-motion-standard);
}
.view-toggle-btn:not(:last-child) { border-right: 1px solid rgba(0,0,0,.23); }
.view-toggle-btn:hover { background: var(--md-state-hover); }
.view-toggle-btn.active {
  background: var(--md-primary);
  color: var(--md-on-primary);
}

/* --- Pipeline Label --- */
.ticket-pipeline { font-size: 13px; color: var(--md-on-surface-medium); font-weight: 500; }
.ticket-owner-name { font-size: 13px; color: var(--md-on-surface-medium); }

/* --- Status Badges (MD2 Chips) --- */
.badge-status {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 4px 12px; border-radius: 16px;
  font-weight: 500; white-space: nowrap;
  letter-spacing: .02em;
}
.badge-status-open {
  background: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9;
}
.badge-status-closed {
  background: #e3f2fd; color: #0d47a1; border: 1px solid #bbdefb;
}
.status-icon { font-size: 10px; }
@media (max-width: 1100px) {
  .status-text { display: none; }
  .badge-status { padding: 4px 8px; }
}

/* --- Table layout --- */
.ticket-table { table-layout: fixed; min-width: 100%; width: max-content; }
.ticket-table td, .ticket-table th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-table td.td-content { white-space: normal; overflow: visible; text-overflow: clip; }

/* --- Sortable columns --- */
.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 150ms var(--md-motion-standard);
}
.sortable:hover { background: var(--md-primary-variant); }
.sort-arrow { display: inline-block; margin-left: 4px; font-size: 10px; opacity: .4; transition: opacity .2s; }
.sort-arrow::after { content: "⇅"; }
.sort-arrow.sort-asc { opacity: 1; color: var(--md-secondary); font-weight: 700; }
.sort-arrow.sort-asc::after { content: "↑"; }
.sort-arrow.sort-desc { opacity: 1; color: var(--md-secondary); font-weight: 700; }
.sort-arrow.sort-desc::after { content: "↓"; }
.sortable.sorted { box-shadow: inset 0 -3px 0 var(--md-secondary); }

/* --- Draggable columns --- */
.sortable[draggable="true"] { cursor: grab; }
.sortable[draggable="true"]:active { cursor: grabbing; }
.sortable.dragging { opacity: .38; }
.sortable.drag-over { box-shadow: inset -3px 0 0 var(--md-secondary); }

/* --- MD2 Tooltips --- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(.8);
  background: #616161;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  padding: 6px 12px;
  border-radius: var(--md-shape-sm);
  white-space: normal;
  max-width: 320px;
  width: max-content;
  box-shadow: var(--md-elevation-6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 150ms var(--md-motion-decel),
              transform 150ms var(--md-motion-decel),
              visibility 150ms;
  pointer-events: none;
  z-index: 200;
}
[data-tooltip]::before {
  content: "";
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #616161;
  opacity: 0;
  visibility: hidden;
  transition: opacity 150ms var(--md-motion-decel), visibility 150ms;
  pointer-events: none;
  z-index: 200;
}
[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}
[data-tooltip]:hover::before {
  opacity: 1;
  visibility: visible;
}
/* Last row: tooltip above */
tbody tr:last-child [data-tooltip]::after {
  top: auto;
  bottom: calc(100% + 8px);
}
tbody tr:last-child [data-tooltip]::before {
  top: auto;
  bottom: calc(100% + 2px);
  border-bottom-color: transparent;
  border-top-color: #616161;
}

/* --- Grouping Bar --- */
.group-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px 16px;
  background: var(--md-surface);
  border-radius: var(--md-shape-sm);
  box-shadow: var(--md-elevation-1);
  font-size: 13px;
}
.group-bar-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--md-on-surface-medium);
  font-weight: 500;
  white-space: nowrap;
}
.group-bar-then { color: var(--md-on-surface-disabled); font-size: 12px; }
.group-select {
  padding: 6px 12px;
  border: 1px solid rgba(0,0,0,.23);
  border-radius: var(--md-shape-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--md-surface);
  cursor: pointer;
  min-width: 140px;
  transition: border-color 200ms var(--md-motion-standard);
}
.group-select:hover { border-color: var(--md-on-surface); }
.group-select:focus { outline: none; border-color: var(--md-primary); border-width: 2px; }

/* --- Group Headers --- */
.group-header td {
  background: var(--md-background) !important;
  padding: 10px 16px !important;
  font-size: 13px;
  color: var(--md-on-surface);
  border-bottom: 1px solid var(--md-divider) !important;
  cursor: default;
}
.group-header-1 td {
  background: #eceff1 !important;
  font-size: 14px;
  font-weight: 500;
}
.group-header-2 td {
  padding-left: 32px !important;
  background: var(--md-background) !important;
  font-weight: 400;
}
.group-header:hover td { background: inherit !important; }
.group-toggle {
  display: inline-block;
  width: 20px;
  cursor: pointer;
  font-size: 11px;
  color: var(--md-on-surface-medium);
  user-select: none;
}
.group-toggle:hover { color: var(--md-primary); }

/* --- Kanban Board --- */
.kanban-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.kanban-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid rgba(0,0,0,.23);
  border-radius: var(--md-shape-sm);
  background: var(--md-surface);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--md-on-surface-medium);
  cursor: pointer;
  transition: all 200ms var(--md-motion-standard);
}
.kanban-tab:hover { border-color: var(--md-primary); color: var(--md-primary); }
.kanban-tab.active {
  background: var(--md-primary);
  color: var(--md-on-primary);
  border-color: var(--md-primary);
}
.kanban-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(0,0,0,.08);
}
.kanban-tab.active .kanban-tab-count { background: rgba(255,255,255,.24); }

.kanban-columns, .kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  align-items: flex-start;
}
.kanban-column {
  min-width: 260px;
  max-width: 300px;
  flex-shrink: 0;
  background: #eceff1;
  border-radius: var(--md-shape-md);
  display: flex;
  flex-direction: column;
}
.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 2px solid #cfd8dc;
}
.kanban-column-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--md-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: .02em;
}
.kanban-column-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 500;
  background: #b0bec5;
  color: #fff;
}
.kanban-column-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

/* --- Kanban Card (MD2 Elevation) --- */
.kanban-card {
  background: var(--md-surface);
  border-radius: var(--md-shape-md);
  padding: 12px 16px;
  box-shadow: var(--md-elevation-1);
  cursor: pointer;
  transition: box-shadow 280ms var(--md-motion-standard),
              transform 200ms var(--md-motion-standard);
  border-left: 3px solid transparent;
}
.kanban-card:hover {
  box-shadow: var(--md-elevation-4);
  transform: translateY(-1px);
}
.kanban-card[data-status="open"] { border-left-color: var(--md-success); }
.kanban-card[data-status="closed"] { border-left-color: var(--md-primary); }
.kanban-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.kanban-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-on-surface);
  line-height: 1.4;
  margin-bottom: 4px;
}
.kanban-card-desc {
  font-size: 12px;
  color: var(--md-on-surface-medium);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kanban-card-phase {
  display: inline-block;
  font-size: 11px;
  color: var(--md-primary);
  background: var(--md-primary-light);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
  margin-bottom: 8px;
}
.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--md-on-surface-disabled);
}
.kanban-card-owner { font-weight: 500; color: var(--md-on-surface-medium); }

/* --- Empty State --- */
.empty-state {
  background: var(--md-surface);
  border-radius: var(--md-shape-md);
  padding: 48px;
  text-align: center;
  color: var(--md-on-surface-medium);
  box-shadow: var(--md-elevation-1);
}

/* --- Column Toggle --- */
.col-toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--md-on-surface);
  cursor: pointer;
  user-select: none;
}
.col-toggle-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--md-primary);
  cursor: pointer;
}

/* --- Responsive (MD2 breakpoints) --- */
@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .app-header { padding: 0 16px; }
  .app-main { padding: 16px; width: 100vw; }
  .ticket-table-wrap { border-radius: 0; }
}
@media (max-width: 600px) {
  .stats-row { grid-template-columns: 1fr; }
  .app-nav a { padding: 0 12px; font-size: 13px; }
  .auth-card { padding: 24px; }
  .app-header { height: 56px; }
}

/* --- Info-Card (plakativer Hinweis-Block, z.B. Scoping-Erklaerung) --- */
.info-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 18px;
  margin-bottom: 24px;
  background: #e8f0fe;
  border-left: 4px solid #3182ce;
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  color: #2d3748;
  line-height: 1.55;
}
.info-card svg { flex: 0 0 auto; color: #3182ce; margin-top: 1px; }
.info-card strong { color: #0f3460; display: block; margin-bottom: 4px; }

/* --- Admin-Sektion auf der API-Keys-Seite (klar abgegrenzt vom User-Bereich) --- */
.admin-section {
  margin-top: 32px;
  padding: 20px 24px 24px;
  background: #fff8e1;             /* warmer, sehr heller Warn-Ton */
  border: 1px solid #ffd166;
  border-left: 4px solid #f59e0b;  /* kraeftiger Akzent links */
  border-radius: 8px;
}
.admin-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  color: #92400e;
}
.admin-section-header h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: #92400e;
}
.admin-section-header svg { flex: 0 0 auto; }
.admin-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 10px;
  border-radius: 12px;
  background: #f59e0b;
  color: #fff;
  white-space: nowrap;
}
.admin-section-hint {
  font-size: 12px;
  color: #92400e;
  margin: 0 0 14px;
  opacity: .85;
}
