:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --text: #171717;
  --muted: #6b7280;
  --border: #eadfd8;
  --soft-border: #f2e7df;
  --brand: #f05a28;
  --brand-strong: #d63b21;
  --brand-soft: #fff0e7;
  --accent: #ff9800;
  --accent-soft: #fff3d8;
  --danger: #d62957;
  --danger-soft: #ffe6ed;
  --info: #3b82c4;
  --info-soft: #e7f2ff;
  --button-gradient: linear-gradient(135deg, #ff9a18 0%, #ef3e2f 58%, #c02c68 100%);
  --shadow: 0 16px 40px rgba(32, 36, 44, 0.12);
  --card-shadow: 0 10px 24px rgba(32, 36, 44, 0.11);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15171b;
  --surface: #1d2026;
  --surface-raised: #242832;
  --text: #f0f2f5;
  --muted: #a3abba;
  --border: #363d49;
  --soft-border: #2b303a;
  --brand: #ff8a20;
  --brand-strong: #ffb14a;
  --brand-soft: #432315;
  --accent: #ffb000;
  --accent-soft: #4f3412;
  --danger: #ff5d7d;
  --danger-soft: #4a1e2b;
  --info: #74aef2;
  --info-soft: #1b344f;
  --button-gradient: linear-gradient(135deg, #ff9a18 0%, #f0442f 58%, #c7326f 100%);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  --card-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

[hidden] {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--brand-soft) 58%, transparent), transparent 42%),
    var(--bg);
}

.auth-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

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

.auth-brand {
  justify-content: space-between;
}

.logo {
  width: 148px;
  height: auto;
  max-height: 76px;
  display: block;
  object-fit: contain;
}

.auth-heading {
  margin: 30px 0 22px;
}

.auth-heading h1,
.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.auth-heading p,
.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-form,
.ticket-form,
.comment-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field .field-label-with-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 8px;
}

.modal-status-dot {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  display: inline-block;
  border-radius: 999px;
  background: var(--info);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--info) 16%, transparent);
}

.modal-status-dot[data-status="problem"] {
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 16%, transparent);
}

.modal-status-dot[data-status="inProgress"] {
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.modal-status-dot[data-status="done"] {
  background: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  padding: 11px 12px;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}

.file-picker {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  font-size: 14px;
  font-weight: 800;
}

.file-picker-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0 12px;
}

.file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}

.primary-button {
  background: var(--button-gradient);
  color: #ffffff;
  padding: 0 18px;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--brand) 22%, transparent);
}

.primary-button:hover {
  filter: saturate(1.08) brightness(1.02);
}

.secondary-button {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  padding: 0 16px;
}

.secondary-button:hover,
.icon-button:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
}

.icon-button {
  width: 40px;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar,
.workbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-actions,
.workbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  background: var(--surface);
}

.workbar {
  align-items: stretch;
  flex-wrap: wrap;
  background: var(--bg);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  font-weight: 800;
}

.segmented button.is-active {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.search-input {
  width: min(270px, 48vw);
  min-height: 40px;
}

.overview-panel {
  display: grid;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.overview-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.overview-header h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.overview-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.overview-filter {
  min-width: min(260px, 100%);
  display: grid;
  gap: 6px;
}

.overview-filter span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.ticket-overview {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.overview-table {
  min-width: 900px;
}

.overview-row {
  display: grid;
  grid-template-columns: 120px minmax(220px, 1.6fr) 150px 130px 120px 110px 92px;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 12px;
  border-top: 1px solid var(--soft-border);
  color: var(--text);
  font-size: 13px;
}

.overview-row:first-child {
  border-top: 0;
}

.overview-row.has-unread {
  background: color-mix(in srgb, var(--brand-soft) 58%, transparent);
}

.overview-row-head {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 38px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.overview-row strong {
  overflow-wrap: anywhere;
}

.overview-empty {
  min-height: 96px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
}

.status-chip {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.status-problem {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-inProgress {
  background: var(--accent-soft);
  color: #a35c00;
}

:root[data-theme="dark"] .status-inProgress {
  color: var(--accent);
}

.status-done {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.table-open-button {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--brand-strong);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
}

.table-open-button:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 18px;
  padding: 20px 24px 28px;
  overflow: hidden;
}

.column {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.column-header {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.column-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--info);
}

.column[data-status="problem"] .status-dot {
  background: var(--danger);
}

.column[data-status="inProgress"] .status-dot {
  background: var(--accent);
}

.column[data-status="done"] .status-dot {
  background: var(--brand);
}

.column h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.counter {
  min-width: 30px;
  min-height: 30px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-weight: 800;
  font-size: 13px;
}

.ticket-stack {
  min-height: 280px;
  height: clamp(280px, calc(100vh - 492px), 560px);
  overflow-y: auto;
  padding: 2px 6px 160px 2px;
  scrollbar-width: thin;
}

.ticket-card {
  position: relative;
  min-height: 184px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease,
    margin-bottom 150ms ease;
}

.ticket-card + .ticket-card {
  margin-top: -106px;
}

.ticket-card:hover,
.ticket-card:focus-within {
  transform: translateY(-8px);
  z-index: 5;
  margin-bottom: 98px;
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--brand) 64%, var(--border));
}

.ticket-card.urgency-low {
  border-left-color: var(--muted);
}

.ticket-card.urgency-normal {
  border-left-color: var(--info);
}

.ticket-card.urgency-high {
  border-left-color: var(--accent);
}

.ticket-card.urgency-critical {
  border-left-color: var(--danger);
}

.card-topline,
.card-meta,
.card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-topline {
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.card-title {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.card-desc {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: var(--info-soft);
  color: var(--info);
}

.pill.recipient-tech,
.pill.urgency-low {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.pill.recipient-support,
.pill.urgency-high {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.recipient-management,
.pill.urgency-critical {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill.urgency-normal {
  background: var(--info-soft);
  color: var(--info);
}

.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--button-gradient);
  color: #ffffff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
  font-size: 12px;
  font-weight: 1000;
  vertical-align: middle;
}

.card-footer {
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.card-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.card-open {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--brand-strong);
  font-weight: 900;
}

.empty-column {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 17, 22, 0.58);
  overflow: hidden;
}

.modal {
  width: min(1080px, 100%);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 3px 0 0;
  font-size: 22px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.modal-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr);
  -webkit-overflow-scrolling: touch;
}

.ticket-form,
.comments-panel {
  min-height: 0;
  overflow: auto;
  padding: 22px;
}

.comments-panel {
  border-left: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-raised) 76%, var(--bg));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.comments-header h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.comments-log {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

.comment {
  padding: 11px 12px;
  border: 1px solid var(--soft-border);
  border-radius: var(--radius);
  background: var(--surface);
}

.comment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.comment p {
  margin: 8px 0 0;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-form {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-item {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 13px;
  font-weight: 800;
}

.attachment-item a {
  color: var(--brand-strong);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.attachment-remove {
  border: 0;
  background: transparent;
  color: var(--danger);
  padding: 0 2px;
  font-weight: 900;
}

.form-footer {
  position: sticky;
  bottom: -22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 0 0;
  background: var(--surface);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #ffffff;
  background: #20242c;
  box-shadow: var(--shadow);
  font-weight: 800;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .overview-header {
    align-items: stretch;
    flex-direction: column;
  }

  .overview-filter {
    width: 100%;
  }

  .board {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .ticket-stack {
    height: auto;
    max-height: 560px;
  }

  .modal-grid {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .comments-panel {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .ticket-form,
  .comments-panel {
    overflow: visible;
  }

  .comments-log {
    max-height: 320px;
  }
}

@media (max-width: 720px) {
  .topbar,
  .workbar,
  .overview-panel {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .topbar-actions,
  .workbar-actions {
    flex-wrap: wrap;
  }

  .search-input {
    width: 100%;
  }

  .board {
    padding: 16px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: stretch;
    justify-items: stretch;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .modal {
    width: 100%;
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 8px;
  }

  .modal-header {
    gap: 12px;
    padding: 14px 16px;
  }

  .modal-header h2 {
    font-size: 19px;
  }

  .ticket-form,
  .comments-panel {
    padding: 16px;
  }

  .comments-log {
    min-height: 150px;
    max-height: 240px;
  }

  .form-footer {
    bottom: -16px;
  }
}
