:root {
  --mythos-bg: #0A0A0A;
  --mythos-surface: #141414;
  --mythos-border: #262626;
  --mythos-text: #F5F1EA;
  --mythos-muted: #8A857E;
  --mythos-accent: #C9B88A;
  --mythos-accent-dark: #8F7E58;
  --success: #8EB68E;
  --danger: #D16F5D;
  --warning: #E0B35F;
  --font-serif: "Cormorant Garamond", Georgia, serif;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--mythos-bg);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--mythos-bg);
  color: var(--mythos-text);
  font-family: var(--font-sans);
  letter-spacing: 0;
  font-feature-settings: "kern" 1, "liga" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

body[data-restricted="true"] .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body[data-restricted="true"] .sidebar {
  display: none;
}

body[data-restricted="true"] .topbar-actions {
  display: none;
}

body[data-restricted="true"] .topbar {
  position: static;
}

body[data-restricted="true"] .view-panel {
  min-height: calc(100vh - 96px);
}

body[data-route-view="staff-mobile"] .topbar,
body[data-route-view="staff-laptop"] .topbar {
  min-height: 78px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  border-right: 1px solid var(--mythos-border);
  background: var(--mythos-bg);
  overflow: auto;
}

.brand {
  display: block;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--mythos-border);
}

.brand img {
  display: block;
  width: min(168px, 100%);
  height: auto;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.nav-link, .secondary-action, .ghost-button, .danger-button, .primary-button {
  min-height: 42px;
  border: 1px solid var(--mythos-border);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--mythos-text);
  text-decoration: none;
  background: transparent;
  text-align: left;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}

.nav-link:hover, .nav-link.active, .ghost-button:hover {
  border-color: var(--mythos-accent-dark);
  background: var(--mythos-surface);
  color: var(--mythos-accent);
}

.sidebar-panel {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--mythos-border);
  border-radius: 8px;
  background: var(--mythos-surface);
}

.panel-label, .panel-note {
  display: block;
  color: var(--mythos-muted);
  font-size: 12px;
}

.sidebar-panel strong {
  display: block;
  margin-top: 6px;
  font-family: var(--font-serif);
  font-size: 44px;
  line-height: .9;
  color: var(--mythos-accent);
}

.panel-note {
  margin-top: 8px;
  line-height: 1.45;
}

.secondary-action {
  width: 100%;
  margin-top: 12px;
  text-align: center;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--mythos-border);
  background: rgba(10, 10, 10, .92);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--mythos-accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(38px, 5vw, 62px);
  line-height: .9;
}

h2 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: .95;
}

h3 {
  font-size: 27px;
  line-height: 1;
}

.topbar-actions, .form-actions, .ticket-actions, .filters {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.primary-button {
  background: var(--mythos-accent);
  color: #14100A;
  border-color: var(--mythos-accent);
  font-weight: 700;
  text-align: center;
}

.primary-button:hover {
  background: #D9C99A;
}

.ghost-button {
  text-align: center;
}

.danger-button {
  color: #F0B3A7;
  text-align: center;
}

.danger-button:hover {
  border-color: var(--danger);
  background: rgba(209, 111, 93, .1);
}

.view-panel {
  display: none;
  padding: 28px;
  border-bottom: 1px solid var(--mythos-border);
}

.view-panel.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 18px;
}

.section-heading.compact {
  align-items: center;
}

.section-copy {
  max-width: 420px;
  margin: 0;
  color: var(--mythos-muted);
  line-height: 1.5;
}

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

.ticket-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mobile-form {
  max-width: 560px;
}

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

label {
  display: grid;
  gap: 7px;
}

label span, .note-field span {
  color: var(--mythos-muted);
  font-size: 13px;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--mythos-border);
  border-radius: 7px;
  background: var(--mythos-surface);
  color: var(--mythos-text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--mythos-accent-dark);
  box-shadow: 0 0 0 3px rgba(201, 184, 138, .1);
}

input::placeholder, textarea::placeholder {
  color: #66615A;
}

.full-width {
  grid-column: 1 / -1;
}

.submit-wide {
  width: 100%;
  min-height: 50px;
}

.photo-drop {
  min-height: 118px;
  align-content: center;
  justify-items: center;
  border: 1px dashed var(--mythos-accent-dark);
  border-radius: 8px;
  padding: 18px;
  background: var(--mythos-surface);
  text-align: center;
}

.photo-drop input {
  max-width: 320px;
  border: 0;
  padding: 8px;
  background: transparent;
}

.photo-drop strong {
  color: var(--mythos-accent);
}

.photo-preview, .photo-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preview-item {
  width: 120px;
  border: 1px solid var(--mythos-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--mythos-surface);
}

.preview-item img, .photo-strip img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.preview-item button {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--mythos-border);
  padding: 8px;
  background: transparent;
  color: #F0B3A7;
}

.photo-strip {
  margin: 12px 0;
}

.photo-strip a {
  display: block;
  width: 86px;
  border: 1px solid var(--mythos-border);
  border-radius: 8px;
  overflow: hidden;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  min-height: 110px;
  padding: 17px;
  border: 1px solid var(--mythos-border);
  border-radius: 8px;
  background: var(--mythos-surface);
}

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

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-family: var(--font-serif);
  font-size: 48px;
  line-height: .9;
  color: var(--mythos-text);
}

.filters {
  justify-content: flex-end;
}

.filters input {
  width: min(260px, 100%);
}

.filters select {
  width: 180px;
}

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

.ticket-card, .admin-panel {
  padding: 16px;
  border: 1px solid var(--mythos-border);
  border-radius: 8px;
  background: var(--mythos-surface);
}

.ticket-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.ticket-meta {
  margin-bottom: 7px;
  color: var(--mythos-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.ticket-description {
  margin: 12px 0;
  color: var(--mythos-text);
  line-height: 1.55;
}

.priority-pill {
  flex: 0 0 auto;
  min-width: 76px;
  border: 1px solid var(--mythos-border);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--mythos-accent);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.priority-pill.urgent {
  border-color: var(--warning);
  color: var(--warning);
}

.priority-pill.low {
  color: var(--success);
}

.ticket-details {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.ticket-details div {
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--mythos-border);
  border-radius: 7px;
  background: #0F0F0F;
}

.ticket-details dt {
  color: var(--mythos-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.ticket-details dd {
  margin: 6px 0 0;
  color: var(--mythos-text);
  overflow-wrap: anywhere;
}

.note-field {
  margin-bottom: 12px;
}

.status-select, .supplier-status-select {
  width: 190px;
}

.supplier-input {
  width: 220px;
}

.empty-state {
  padding: 34px 18px;
  border: 1px dashed var(--mythos-border);
  border-radius: 8px;
  color: var(--mythos-muted);
  text-align: center;
}

.admin-section {
  margin-bottom: 36px;
}

.admin-section-title {
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--mythos-border);
  color: var(--mythos-accent);
  font-size: 18px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 12px;
}

.overview-card {
  padding: 18px;
  border: 1px solid var(--mythos-border);
  border-radius: 8px;
  background: var(--mythos-surface);
}

.overview-card strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 44px;
  line-height: .9;
  color: var(--mythos-text);
}

.overview-card span {
  display: block;
  margin-top: 10px;
  color: var(--mythos-muted);
  font-size: 13px;
  font-weight: 600;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}

.admin-table thead th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mythos-muted);
  border-bottom: 1px solid var(--mythos-border);
}

.admin-table tbody tr {
  border-bottom: 1px solid var(--mythos-border);
}

.admin-table tbody tr:last-child {
  border-bottom: none;
}

.admin-table tbody td {
  padding: 10px 12px;
  font-size: 14px;
  color: var(--mythos-text);
  vertical-align: middle;
}

.admin-table-empty {
  padding: 24px 12px;
  color: var(--mythos-muted);
  font-size: 14px;
}

.admin-table-actions {
  text-align: right;
  white-space: nowrap;
}

.admin-table-actions button {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
  margin-left: 6px;
}

.admin-table input {
  padding: 7px 10px;
  font-size: 13px;
}

.admin-add-form {
  margin-top: 4px;
}

.admin-add-form summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--mythos-accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  user-select: none;
}

.admin-add-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--mythos-border);
  border-radius: 8px;
  background: var(--mythos-surface);
}

.admin-add-fields button {
  align-self: end;
}

.role-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--mythos-border);
  color: var(--mythos-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.role-pill.role-admin { border-color: var(--warning); color: var(--warning); }
.role-pill.role-manager { border-color: var(--mythos-accent); color: var(--mythos-accent); }
.role-pill.role-supplier { border-color: var(--success); color: var(--success); }

.admin-export-row {
  padding: 22px;
  border: 1px solid var(--mythos-border);
  border-radius: 8px;
  background: var(--mythos-surface);
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--mythos-border);
  }

  .nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-link {
    text-align: center;
  }

  .ticket-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ticket-details, .stats-grid, .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar, .section-heading, .section-heading.compact {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions, .filters, .form-actions, .ticket-actions {
    width: 100%;
  }

  .topbar-actions > *, .filters > *, .form-actions > *, .ticket-actions > * {
    flex: 1 1 100%;
  }

  .view-panel, .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .ticket-form, .ticket-details, .stats-grid, .overview-grid, .nav, .two-column {
    grid-template-columns: 1fr;
  }

  .ticket-header {
    flex-direction: column;
  }

  .priority-pill, .supplier-input, .status-select, .supplier-status-select {
    width: 100%;
  }

  .mobile-report {
    padding-bottom: 96px;
  }
}

/* ─── Priority radio pills (form) ─────────────────────────────────────────── */
.prio-radio { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }

.priority-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.priority-pill-label {
  cursor: pointer;
  border: 1.5px solid var(--mythos-border);
  border-radius: 999px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--mythos-muted);
  background: transparent;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  user-select: none;
}
.priority-pill-label:hover { border-color: var(--mythos-accent); color: var(--mythos-accent); }

.prio-radio[value="Low"]:checked ~ label[for^="prio-low"],
label.priority-pill-label.selected-low {
  border-color: var(--success);
  color: var(--success);
  background: rgba(80,200,120,0.08);
}
.prio-radio[value="Normal"]:checked ~ label[for^="prio-normal"],
label.priority-pill-label.selected-normal {
  border-color: var(--mythos-accent);
  color: var(--mythos-accent);
  background: rgba(201,184,138,0.1);
}
.prio-radio[value="Urgent"]:checked ~ label[for^="prio-urgent"],
label.priority-pill-label.selected-urgent {
  border-color: var(--warning);
  color: var(--warning);
  background: rgba(255,160,60,0.1);
}

/* Sibling selector trick — labels come AFTER the inputs in DOM */
#prio-low-m:checked + label,
#prio-low-d:checked + label { border-color: var(--success); color: var(--success); background: rgba(80,200,120,0.08); }
#prio-normal-m:checked + label,
#prio-normal-d:checked + label { border-color: var(--mythos-accent); color: var(--mythos-accent); background: rgba(201,184,138,0.1); }
#prio-urgent-m:checked + label,
#prio-urgent-d:checked + label { border-color: var(--warning); color: var(--warning); background: rgba(255,160,60,0.1); }

/* ─── Photo buttons ────────────────────────────────────────────────────────── */
.photo-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.photo-btn-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: 1.5px solid var(--mythos-border);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mythos-muted);
  background: var(--mythos-surface);
  transition: border-color 0.15s, color 0.15s;
}
.photo-btn-label:hover { border-color: var(--mythos-accent); color: var(--mythos-accent); }
.photo-btn-label svg { flex: 0 0 auto; }

/* ─── Field helpers ────────────────────────────────────────────────────────── */
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mythos-muted);
  margin-bottom: 6px;
}

.field-optional {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--mythos-muted);
  opacity: 0.6;
  margin-left: 4px;
}

.field-group { display: flex; flex-direction: column; }

/* ─── Notify info box ──────────────────────────────────────────────────────── */
.notify-info {
  font-size: 12px;
  color: var(--mythos-muted);
  background: rgba(201,184,138,0.07);
  border: 1px solid rgba(201,184,138,0.18);
  border-radius: 8px;
  padding: 10px 14px;
  line-height: 1.5;
}

/* ─── Supplier card sections ───────────────────────────────────────────────── */
.supplier-section {
  border: 1px solid var(--mythos-border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-top: 16px;
  background: var(--mythos-surface);
}

.supplier-section-title {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mythos-accent);
}

.supplier-section-done {
  margin: 10px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--success);
  letter-spacing: 0.04em;
}

.supplier-section-lock {
  font-size: 12px;
  color: var(--mythos-muted);
  margin: 0 0 12px;
  font-style: italic;
}

/* ─── Outcome pills ────────────────────────────────────────────────────────── */
.outcome-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.outcome-pill-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: 1.5px solid var(--mythos-border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--mythos-muted);
  background: transparent;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  user-select: none;
}
.outcome-pill-label input[type="radio"] { display: none; }
.outcome-pill-label:has(input:checked) {
  border-color: var(--mythos-accent);
  color: var(--mythos-accent);
  background: rgba(201,184,138,0.08);
}
.outcome-pill-label.outcome-pill-danger:has(input:checked) {
  border-color: var(--warning);
  color: var(--warning);
  background: rgba(255,100,60,0.08);
}
.outcome-pill-label:hover { border-color: var(--mythos-accent); color: var(--mythos-accent); }

/* ─── Supplier job update (manager view) ──────────────────────────────────── */
.supplier-job-update {
  border: 1px solid var(--mythos-accent);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 14px;
  background: rgba(201,184,138,0.05);
}
.supplier-update-details {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 12px;
}
.supplier-update-details dt { color: var(--mythos-muted); font-size: 12px; }
.supplier-update-details dd { color: var(--mythos-text); font-size: 13px; margin: 0; }
