:root {
  color-scheme: dark;
  --bg-base: #0d0d0d;
  --bg-deep: #050505;
  --ink: #f3f3f3;
  --ink-strong: #ffffff;
  --muted: #9ca3af;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.18);
  --panel: rgba(18, 18, 18, 0.78);
  --panel-strong: rgba(26, 26, 26, 0.92);
  --panel-soft: rgba(14, 14, 14, 0.55);
  --field: rgba(0, 0, 0, 0.55);
  --field-focus: rgba(0, 0, 0, 0.78);
  --brand: #dc2626;
  --brand-strong: #ef4444;
  --brand-deep: #991b1b;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #f87171;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 14%, rgba(220, 38, 38, 0.14), transparent 40%),
    radial-gradient(circle at 88% 6%, rgba(220, 38, 38, 0.08), transparent 36%),
    radial-gradient(circle at 50% 110%, rgba(220, 38, 38, 0.07), transparent 45%),
    linear-gradient(160deg, var(--bg-deep) 0%, var(--bg-base) 55%, #080808 100%);
  background-attachment: fixed;
}

button,
input,
select,
textarea {
  font: inherit;
  color: var(--ink);
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

a {
  color: var(--brand-strong);
  text-decoration: none;
}

a:hover {
  color: var(--brand);
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1500px;
  margin: 0 auto 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  height: 56px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.45));
}

.brand-text {
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--brand);
  padding-left: 18px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
  color: var(--ink-strong);
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.85rem, 2.6vw, 2.85rem);
  line-height: 1;
  letter-spacing: -0.01em;
}

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

.identity {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  backdrop-filter: blur(14px);
}

.identity-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.identity-name {
  color: var(--ink-strong);
  font-weight: 800;
  font-size: 0.92rem;
}

.identity-meta {
  color: var(--muted);
  font-size: 0.74rem;
}

.identity-logout {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.82rem;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: rgba(139, 151, 173, 0.7);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  background: var(--field-focus);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.22);
}

select option {
  background: var(--bg-base);
  color: var(--ink);
}

.primary-button,
.ghost-button,
.icon-button,
.assistant-strip button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  box-shadow: 0 14px 30px rgba(220, 38, 38, 0.32);
}

.primary-button:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, var(--brand-strong) 0%, var(--brand) 100%);
  box-shadow: 0 18px 36px rgba(220, 38, 38, 0.4);
}

.ghost-button,
.icon-button,
.assistant-strip button {
  color: var(--ink);
  background: rgba(26, 26, 26, 0.78);
  border-color: var(--line-strong);
}

.ghost-button:hover,
.icon-button:hover,
.assistant-strip button:hover:not(:disabled) {
  background: rgba(40, 40, 40, 0.92);
  border-color: rgba(220, 38, 38, 0.45);
  color: var(--ink-strong);
}

.workspace {
  max-width: 1500px;
  margin: 0 auto;
}

.toolbar,
.assistant-strip,
.ticket-list-panel,
.detail-panel,
dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 150px 190px auto auto;
  gap: 12px;
  align-items: end;
  border-radius: 18px;
  padding: 14px;
}

.search-field {
  min-width: 0;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.toggle-field input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--brand);
}

.assistant-strip {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
  border-radius: 14px;
  padding: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.ticket-list-panel,
.detail-panel {
  min-height: 560px;
  border-radius: 18px;
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.1rem;
}

#ticketCount {
  display: inline-grid;
  min-width: 34px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  background: var(--brand);
  font-weight: 800;
}

.ticket-list {
  display: grid;
  gap: 10px;
}

.ticket-card {
  display: grid;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
  padding: 14px;
  text-align: left;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.ticket-card:hover,
.ticket-card.active {
  border-color: rgba(220, 38, 38, 0.55);
  box-shadow: 0 12px 26px rgba(220, 38, 38, 0.2);
  transform: translateY(-1px);
}

.ticket-card h3 {
  margin: 0;
  font-size: 1rem;
}

.ticket-card small {
  color: var(--muted);
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 10px;
  background: rgba(231, 238, 249, 0.08);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pill.open {
  color: var(--green);
  background: rgba(74, 210, 149, 0.16);
}

.pill.on_hold {
  color: var(--amber);
  background: rgba(240, 177, 74, 0.16);
}

.pill.closed {
  color: var(--muted);
  background: rgba(139, 151, 173, 0.18);
}

.pill.urgent {
  color: #ffffff;
  background: var(--brand);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.detail-panel h2 {
  margin-bottom: 8px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.detail-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 10px 12px;
}

.detail-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-item span {
  color: var(--ink);
}

.detail-item.wide {
  grid-column: 1 / -1;
}

.note-box {
  margin-top: 16px;
}

.note-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.note {
  border-left: 3px solid var(--brand);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 10px 12px;
}

.note strong {
  color: var(--ink-strong);
}

.note p {
  margin: 6px 0 0;
  color: var(--ink);
}

.empty-state,
.loading-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.empty-state h2,
.loading-state h2 {
  color: var(--ink-strong);
}

.splash {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 160px);
  max-width: 1500px;
  margin: 0 auto;
}

.splash[hidden] {
  display: none;
}

.splash-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  padding: 32px;
  text-align: center;
}

.splash-card h2 {
  margin-bottom: 12px;
  font-size: 1.4rem;
}

.splash-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.splash-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

dialog {
  width: min(880px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(3, 7, 14, 0.7);
  backdrop-filter: blur(8px);
}

#ticketForm {
  padding: 18px;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.dialog-heading h2 {
  margin: 0;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.5rem;
}

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

.wide {
  grid-column: 1 / -1;
}

.inline-toggle {
  align-self: end;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 12px;
  color: #ffffff;
  background: var(--brand);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: 100%;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  padding: 32px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.login-brand .brand-logo {
  height: 48px;
  max-width: 200px;
}

.login-brand h1 {
  font-size: 1.4rem;
  margin: 0;
}

.login-brand .brand-text {
  border-left: 2px solid var(--brand);
  padding-left: 14px;
}

.login-lede {
  margin: 0 0 22px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(220, 38, 38, 0.18);
  border: 1px solid rgba(220, 38, 38, 0.45);
  color: #ffd6d6;
  font-size: 0.88rem;
}

.login-submit {
  width: 100%;
  margin-top: 4px;
}

.login-fineprint {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(139, 151, 173, 0.3);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 151, 173, 0.5);
}

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

  .toolbar,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel,
  .ticket-list-panel {
    min-height: auto;
  }

  .identity {
    justify-content: space-between;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 14px;
  }

  .form-grid,
  .detail-grid,
  .assistant-strip {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  .brand-logo {
    height: 44px;
    max-width: 180px;
  }

  .brand-text {
    border-left: none;
    padding-left: 0;
  }
}
