:root {
  color-scheme: light;
  --bg: #f4efe6;
  --panel: rgba(255, 252, 247, 0.88);
  --panel-strong: #fffaf2;
  --ink: #1f2933;
  --muted: #52606d;
  --line: rgba(31, 41, 51, 0.12);
  --accent: #cb6b43;
  --accent-dark: #8f4223;
  --shadow: 0 24px 60px rgba(74, 52, 33, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(203, 107, 67, 0.18), transparent 30%),
    linear-gradient(180deg, #f9f4ea 0%, var(--bg) 100%);
}

body.portal-mode {
  background:
    radial-gradient(circle at top right, rgba(17, 94, 89, 0.18), transparent 28%),
    linear-gradient(180deg, #eef5f3 0%, #dfeceb 100%);
}

.layout {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

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

.topbar > *,
.workspace > *,
.ticket-section > *,
.dashboard-grid > * {
  min-width: 0;
}

.brand-copy {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

.ghost-button,
.secondary-button {
  width: auto;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.ghost-button:hover:enabled,
.secondary-button:hover:enabled {
  background: rgba(255, 255, 255, 0.75);
}

.user-badge {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
}

.app-view[hidden] {
  display: none;
}

[hidden] {
  display: none !important;
}

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 720px;
  font-size: clamp(2.3rem, 5vw, 4.5rem);
  line-height: 0.96;
  overflow-wrap: anywhere;
}

.intro {
  max-width: 700px;
  margin: 16px 0 0;
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

.ticket-section {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
  margin-top: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
}

.dashboard-hero h1,
body.portal-mode .brand-copy {
  max-width: 820px;
}

#map,
.panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#map {
  min-height: 68vh;
  background:
    linear-gradient(135deg, rgba(203, 107, 67, 0.16), rgba(255, 255, 255, 0.8)),
    #f2eadf;
}

.panel {
  padding: 24px;
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.quick-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.quick-panel-header h2 {
  margin: 0;
}

.selected-coords-inline {
  margin: 8px 0 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-dark);
  overflow-wrap: anywhere;
}

.ticket-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  background: var(--panel);
  backdrop-filter: blur(10px);
}

body.portal-mode .ticket-card,
body.portal-mode .panel {
  background: rgba(248, 253, 252, 0.88);
  box-shadow: 0 24px 60px rgba(20, 70, 66, 0.12);
}

.auth-card {
  width: min(560px, 100%);
  margin: 48px auto 0;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.auth-title {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.auth-form {
  margin-top: 28px;
}

.auth-actions {
  display: flex;
  justify-content: flex-start;
}

.panel h2,
.log-header h3 {
  margin: 0;
}

.ticket-heading h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.05;
}

.ticket-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

strong {
  font-size: 1.1rem;
}

button {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, opacity 180ms ease;
}

button:hover:enabled {
  transform: translateY(-1px);
  background: var(--accent-dark);
}

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

.setup-note {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px dashed rgba(203, 107, 67, 0.45);
  border-radius: 16px;
  background: rgba(203, 107, 67, 0.08);
  color: var(--accent-dark);
  line-height: 1.5;
}

.log-wrap {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
}

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

.log-header > * {
  min-width: 0;
}

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

.ticket-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

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

.field span {
  font-size: 0.95rem;
  font-weight: 800;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-strong);
  color: var(--ink);
  font: inherit;
  padding: 14px 16px;
}

.field textarea {
  resize: vertical;
  min-height: 120px;
}

.field input[type="file"] {
  padding: 12px;
}

.field small {
  color: var(--muted);
  line-height: 1.5;
}

.form-actions {
  margin-top: 4px;
}

.file-list {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.file-list li {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

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

.file-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.file-size {
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.92rem;
}

.draft-preview {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
}

.ticket-preview {
  margin: 14px 0 0;
  padding: 16px;
  border-radius: 18px;
  background: #1f2933;
  color: #f5f7fa;
  overflow: auto;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.portal-textarea,
.portal-file-input {
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-strong);
  color: var(--ink);
  font: inherit;
  padding: 14px 16px;
}

.portal-textarea {
  resize: vertical;
  min-height: 120px;
}

.portal-file-input {
  padding: 12px;
}

.portal-actions {
  margin-top: 14px;
}

.manager-list {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.manager-item {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  cursor: pointer;
  transition: border-color 180ms ease, transform 180ms ease, background 180ms ease;
}

.manager-item:hover,
.manager-item.is-active {
  transform: translateY(-1px);
  border-color: rgba(203, 107, 67, 0.5);
  background: rgba(203, 107, 67, 0.08);
}

.manager-title {
  margin: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.manager-meta,
.detail-copy {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.manager-empty {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px dashed var(--line);
  color: var(--muted);
}

.detail-block + .detail-block {
  margin-top: 22px;
}

.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(82, 96, 109, 0.12);
  color: var(--muted);
}

.status-pill.status-new {
  background: rgba(203, 107, 67, 0.12);
  color: var(--accent-dark);
}

.status-pill.status-in-review {
  background: rgba(31, 111, 235, 0.12);
  color: #1251b8;
}

.status-pill.status-researching {
  background: rgba(184, 134, 11, 0.14);
  color: #8a6504;
}

.status-pill.status-complete {
  background: rgba(22, 163, 74, 0.14);
  color: #146c36;
}

@media (max-width: 920px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 22px;
  }

  .topbar-actions {
    width: 100%;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .ticket-section {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  #map {
    min-height: 50vh;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .layout {
    width: min(100% - 20px, 1180px);
    padding: 20px 0 28px;
  }

  .topbar {
    gap: 14px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .topbar-actions > button,
  .user-badge,
  .user-badge .ghost-button {
    width: 100%;
  }

  .user-badge {
    grid-column: 1 / -1;
    justify-content: space-between;
    border-radius: 20px;
  }

  h1,
  .auth-title {
    font-size: clamp(1.9rem, 10vw, 2.8rem);
    line-height: 1;
  }

  .intro,
  .ticket-copy,
  .panel-copy,
  .detail-copy {
    font-size: 0.96rem;
    line-height: 1.6;
  }

  .panel,
  .ticket-card,
  .auth-card {
    padding: 18px;
    border-radius: 22px;
  }

  .quick-panel,
  .file-list li,
  .manager-item {
    padding: 12px;
    border-radius: 14px;
  }

  #map {
    min-height: 42vh;
    border-radius: 22px;
  }

  .log-wrap,
  .draft-preview,
  .manager-empty {
    padding: 14px;
    border-radius: 18px;
  }

  .ticket-form,
  .file-list,
  .manager-list {
    gap: 12px;
  }

  .field input,
  .field textarea,
  .portal-textarea,
  .portal-file-input {
    padding: 13px 14px;
    border-radius: 14px;
    font-size: 16px;
  }

  button,
  .ghost-button,
  .secondary-button {
    min-height: 48px;
    border-radius: 16px;
  }

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

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

  .file-size {
    white-space: normal;
  }

  .status-actions,
  .portal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .manager-sidebar {
    order: 2;
  }

  .manager-detail {
    order: 1;
  }
}
