:root {
  color-scheme: light;
  --bg: #f7f5f1;
  --surface: #ffffff;
  --surface-alt: #f0eee8;
  --text: #1f2528;
  --muted: #697277;
  --line: #d9d4ca;
  --accent: #d94b37;
  --accent-dark: #b63a29;
  --ink: #263031;
  --ok: #237c54;
  --error: #aa2e25;
  --shadow: 0 18px 45px rgba(31, 37, 40, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.is-hidden {
  display: none !important;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  align-items: center;
}

.login-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 28px;
  align-items: center;
  padding: 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-block {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
}

.ticket-preview,
.side-ticket {
  width: 100%;
  aspect-ratio: 8.5 / 2.75;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-alt);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 0.96;
}

h2 {
  font-size: 1rem;
}

.lead {
  max-width: 560px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.primary-action,
.ghost-button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 800;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary-action {
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
}

.primary-action:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.72;
  transform: none;
}

.ghost-button {
  padding: 0 14px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost-button:hover {
  border-color: var(--ink);
}

.google-mark {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #4285f4;
  font-weight: 900;
}

.auth-error,
.status-line {
  margin: 0;
  color: var(--error);
  font-weight: 700;
}

.app-view {
  align-self: stretch;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 22px;
}

.topbar {
  min-height: 88px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  font-size: clamp(1.9rem, 3vw, 3rem);
  line-height: 1;
}

.account {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 280px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.account-text {
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: right;
}

.account-text strong,
.account-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-text span {
  color: var(--muted);
  font-size: 0.85rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.ticket-form,
.side-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(31, 37, 40, 0.08);
}

.ticket-form {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.ticket-form label {
  display: grid;
  gap: 8px;
}

.ticket-form label span {
  font-size: 0.86rem;
  color: var(--ink);
  font-weight: 800;
}

.ticket-form input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.ticket-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 75, 55, 0.15);
}

.ticket-form small {
  min-height: 18px;
  color: var(--error);
  font-weight: 700;
}

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

.status-line {
  min-height: 24px;
}

.status-line.is-ok {
  color: var(--ok);
}

.side-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.ticket-preview-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: zoom-in;
}

.ticket-preview-button:focus-visible {
  outline: 3px solid rgba(217, 75, 55, 0.35);
  outline-offset: 3px;
}

.panel-section {
  display: grid;
  gap: 12px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-empty,
.history-item,
.pending-item {
  padding: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.history-empty {
  color: var(--muted);
}

.history-item,
.pending-item {
  display: grid;
  gap: 4px;
}

.history-item strong,
.history-item span,
.pending-item strong,
.pending-item span {
  overflow-wrap: anywhere;
}

.history-item strong,
.pending-item strong {
  color: var(--ink);
}

.history-item span,
.pending-item span {
  color: var(--muted);
  font-size: 0.86rem;
}

.pending-item {
  width: 100%;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.pending-item:hover,
.pending-item.is-selected {
  border-color: var(--accent);
  background: #fff7f4;
}

.pending-item:hover {
  transform: translateY(-1px);
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 56px 20px 24px;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(31, 37, 40, 0.72);
  cursor: zoom-out;
}

.preview-dialog {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100vw - 40px));
  max-height: calc(100vh - 88px);
}

.preview-close {
  position: absolute;
  right: 0;
  top: -46px;
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 50%;
  background: rgba(31, 37, 40, 0.82);
  color: #fff;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
}

.preview-large-ticket {
  display: block;
  width: 100%;
  max-height: calc(100vh - 96px);
  aspect-ratio: 8.5 / 2.75;
  object-fit: contain;
  border-radius: 8px;
  background: var(--surface-alt);
  box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  .preview-modal {
    padding: 54px 12px 16px;
  }

  .preview-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 70px);
  }

  .preview-close {
    right: 0;
    top: -42px;
  }

  .preview-large-ticket {
    max-height: calc(100vh - 86px);
  }
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 24px, 620px);
    padding: 18px 0;
    align-items: start;
  }

  .login-view,
  .brand-block,
  .workspace {
    grid-template-columns: 1fr;
  }

  .login-view {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .account {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
  }

  .account-text {
    text-align: left;
    flex: 1;
  }
}
