:root {
  --bg: #f5f3ef;
  --ink: #1c1c1c;
  --muted: #6c6c6c;
  --card: #ffffff;
  --accent: #ff7a00;
  --accent-2: #1f7a8c;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  --radius: 18px;
  --font-sans: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: linear-gradient(160deg, #fff7e6 0%, #f5f3ef 35%, #eef3f6 100%);
  color: var(--ink);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--accent) 0%, #ffb800 100%);
  box-shadow: var(--shadow);
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--muted);
}

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

.page {
  padding: 18px 16px 40px;
  max-width: 960px;
  margin: 0 auto;
  overflow-x: hidden;
}

.hero {
  padding: 12px 2px 18px;
}

.hero h1 {
  font-size: 24px;
  margin: 0 0 6px;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.cards {
  display: grid;
  gap: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
}

.issue-card {
  gap: 12px;
  border: 1px solid #ebe7de;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.issue-card:hover {
  transform: translateY(-2px);
  border-color: #d9d2c4;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.1);
}

.issue-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.card-head {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.card-title {
  font-weight: 700;
  font-size: 18px;
  line-height: 1.35;
}

.issue-created-at {
  flex-shrink: 0;
  font-size: 11px;
  color: #7a7a7a;
  background: #f6f4ef;
  border: 1px solid #ece7dd;
  border-radius: 999px;
  padding: 4px 8px;
}

.issue-code {
  font-size: 12px;
  color: #667085;
}

.issue-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f9f7f3;
  border: 1px solid #ece7dd;
}

.issue-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

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

.issue-label {
  font-size: 11px;
  color: #8b8b8b;
}

.issue-value {
  font-size: 13px;
  color: #303030;
  word-break: break-word;
}

.issue-card-bottom {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px dashed #e3ded3;
  color: #646464;
  font-size: 12px;
}

.issue-badge-overdue {
  background: #ffe6e6;
  color: #9a2a2a;
}

.card-meta {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

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

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #f0f0f0;
}

.status-new {
  background: #ffe9d6;
  color: #b24b00;
}

.status-in_progress {
  background: #d9f2ff;
  color: #006b99;
}

.status-pending_verify {
  background: #e8e0ff;
  color: #5a3b9c;
}

.status-closed {
  background: #e0f7e9;
  color: #1a6e42;
}

.status-rejected {
  background: #ffe1e1;
  color: #a03c3c;
}

.severity-S1 {
  background: #ffdad4;
  color: #a02b1e;
}

.severity-S2 {
  background: #fff0c7;
  color: #8a5a00;
}

.severity-S3 {
  background: #e6f4ff;
  color: #2464a3;
}

.severity-S4 {
  background: #eef1f4;
  color: #4a4a4a;
}

.form {
  display: grid;
  gap: 14px;
  background: var(--card);
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.inline-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.field input,
.field select,
.field textarea {
  border-radius: 12px;
  border: 1px solid #e0e0e0;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font-sans);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  background: #fff;
  border-color: #e6e6e6;
  color: #333;
}

.panel {
  background: var(--card);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-form {
  display: grid;
  gap: 12px;
}

.issues-filter-shell {
  position: sticky;
  top: 76px;
  z-index: 6;
}

.issues-filter-form {
  gap: 10px;
}

.issues-filter-quick {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.issues-filter-advanced {
  border: 1px solid #ece5d9;
  border-radius: 12px;
  background: #faf8f4;
}

.issues-filter-advanced > summary {
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  font-weight: 600;
  color: #594f42;
  padding: 10px 12px;
}

.issues-filter-advanced > summary::-webkit-details-marker {
  display: none;
}

.issues-filter-advanced-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0 12px 12px;
}

.issues-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.panel-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.panel-label {
  color: var(--muted);
  font-size: 13px;
}

.panel-value {
  font-weight: 600;
  font-size: 14px;
}

.actions {
  margin-top: 18px;
}

.empty {
  background: var(--card);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.empty-title {
  font-size: 18px;
  font-weight: 700;
}

.empty-desc {
  color: var(--muted);
  margin: 6px 0 12px;
}

.section-title {
  font-weight: 700;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  background: #f7f6f3;
  padding: 12px;
  border-radius: 12px;
}

.timeline-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.timeline-content {
  font-size: 14px;
}

.arrival-map-embed {
  width: 100%;
  height: 260px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  margin-bottom: 10px;
}

/* Optional wrapper for any wide table */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  min-width: 720px;
}

.issues-table-wrap table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  background: #fff;
  table-layout: fixed;
}

.issues-table .col-no {
  width: 56px;
}

.issues-table .col-time {
  width: 138px;
}

.issues-table .col-customer {
  width: 150px;
}

.issues-table .col-assignee {
  width: 120px;
}

.issues-table .col-progress {
  width: 140px;
}

.issues-table .col-closed {
  width: 100px;
}

.issues-table th {
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: #4d4d4d;
  background: #f4f1eb;
  border-bottom: 1px solid #e8e2d7;
  padding: 10px 12px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.issues-table td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid #f0ebe1;
  vertical-align: middle;
}

.issues-table th:nth-child(1),
.issues-table th:nth-child(6),
.issues-table th:nth-child(7),
.issues-table td:nth-child(1),
.issues-table td:nth-child(6),
.issues-table td:nth-child(7) {
  text-align: center;
}

.cell-center {
  text-align: center;
}

.cell-nowrap {
  white-space: nowrap;
}

.cell-ellipsis {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.issue-row {
  cursor: pointer;
  height: 82px;
}

.issue-row:hover {
  background: #fffaf1;
}

.issue-problem-main {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.issue-problem-sub {
  margin-top: 2px;
  font-size: 12px;
  color: #7a7a7a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.issue-problem-tags {
  margin-top: 5px;
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.issue-problem-cell .badge {
  white-space: nowrap;
}

.progress-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  min-height: 28px;
  min-width: 94px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.progress-new {
  background: #eef1f4;
  color: #5d6570;
}

.progress-in_progress {
  background: #e5f2fb;
  color: #1e5f8c;
}

.progress-pending_verify {
  background: #fff4dc;
  color: #8a5a00;
}

.progress-closed {
  background: #e4f6ea;
  color: #1d7a45;
}

.progress-rejected {
  background: #fbe8e8;
  color: #a03c3c;
}

.closed-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
}

.closed-yes {
  background: #dff3e6;
  color: #1d7a45;
}

.closed-no {
  background: #eef1f4;
  color: #5f6772;
}

@media (max-width: 768px) {
  .tools {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-top: 10px;
    padding-bottom: 2px;
  }

  .tools::-webkit-scrollbar {
    display: none;
  }

  .tools .btn,
  .tools form .btn {
    min-height: 36px;
    font-size: 14px;
    padding: 8px 10px;
    flex: 0 0 auto;
    width: auto;
    line-height: 1.2;
  }

  .actions.tools {
    display: flex;
    grid-template-columns: none;
  }

  .actions.tools .btn {
    width: auto;
  }

  .issues-tools {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-top: 10px;
    padding-bottom: 2px;
  }

  .issues-tools::-webkit-scrollbar {
    display: none;
  }

  .issues-tools .btn {
    min-height: 36px;
    font-size: 14px;
    padding: 8px 10px;
    flex: 0 0 auto;
    width: auto;
    line-height: 1.2;
  }

  .actions.issues-tools {
    display: flex;
    grid-template-columns: none;
    gap: 8px;
  }

  .actions.issues-tools .btn {
    width: auto;
  }

  .issues-table th,
  .issues-table td {
    padding: 9px 8px;
  }

  .issues-filter-shell {
    position: static;
  }

  .issues-filter-quick {
    grid-template-columns: 1fr;
  }

  .issues-filter-advanced-grid {
    grid-template-columns: 1fr;
  }

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

  .top-actions {
    width: 100%;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .top-actions::-webkit-scrollbar {
    display: none;
  }

  .top-actions .btn,
  .top-actions form {
    width: auto;
    flex: 0 0 auto;
  }

  .top-actions form .btn {
    width: auto;
    flex: 0 0 auto;
    min-height: 36px;
    font-size: 14px;
    line-height: 1.2;
    padding: 8px 10px;
  }

  .top-actions .btn {
    min-height: 36px;
    font-size: 14px;
    line-height: 1.2;
    padding: 8px 10px;
  }

  .top-actions .btn[aria-current="page"] {
    border-color: var(--accent);
    color: var(--accent);
    background: #fff5eb;
  }

  .page {
    padding: 12px;
  }

  .hero {
    padding: 8px 0 14px;
  }

  .hero h1 {
    font-size: 22px;
  }

  .panel,
  .card,
  .form {
    padding: 12px;
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
  }

  .field {
    gap: 8px;
  }

  .form .field input,
  .form .field select,
  .form .field textarea,
  .form .btn,
  .form button,
  .form input[type="submit"],
  .top-actions button {
    min-height: 44px;
    font-size: 16px;
  }

  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
  }

  .inline-form .btn,
  .inline-form button,
  .inline-form select,
  .inline-form input {
    width: 100%;
  }

  .form .btn-primary,
  .form button[type="submit"] {
    width: 100%;
  }

  .actions {
    margin-top: 14px;
    display: grid;
    gap: 10px;
  }

  .actions .btn {
    width: 100%;
  }

  .btn-sm {
    min-height: 36px;
    font-size: 14px;
    padding: 8px 12px;
  }

  .inline-form .btn-sm,
  .actions .btn-sm {
    width: auto;
  }

  .panel-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .signature-canvas {
    width: 100%;
    height: 200px;
  }

  .upload-progress-wrap {
    width: 100%;
  }

  .upload-progress-text {
    font-size: 16px;
    line-height: 1.4;
  }
}

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

.attachment-grid {
  display: grid;
  gap: 12px;
}

.attachment-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f6f6f6;
}

.attachment-name {
  font-weight: 600;
  font-size: 14px;
}

.attachment-image,
.attachment-video {
  width: 100%;
  border-radius: 12px;
  margin-top: 8px;
}

img,
video,
canvas {
  max-width: 100%;
}

.attachment-link {
  display: inline-block;
  margin-top: 8px;
  color: #1f7a8c;
  text-decoration: none;
  font-weight: 600;
}

.attachment-meta {
  font-size: 12px;
  color: var(--muted);
}

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

.error {
  color: #a03c3c;
  font-size: 13px;
}

@media (min-width: 720px) {
  .hero h1 {
    font-size: 28px;
  }

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

  .topbar {
    padding: 18px 32px;
  }
}

@media (max-width: 560px) {
  .issue-card-top {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .issue-card-bottom {
    flex-direction: column;
    gap: 4px;
  }
}

@media (min-width: 1024px) {
  .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.trace-stats {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.trace-stat-card {
  background: #fff;
  border: 1px solid #ece6db;
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.trace-stat-label {
  color: #6f6f6f;
  font-size: 12px;
}

.trace-stat-value {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 700;
}

.trace-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
}

.trace-table th {
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: #4d4d4d;
  background: #f4f1eb;
  border-bottom: 1px solid #e8e2d7;
  padding: 10px 12px;
}

.trace-table td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid #f0ebe1;
  vertical-align: middle;
}

@media (min-width: 720px) {
  .trace-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

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

.trace-panel-success {
  border: 1px solid #2e7d32;
  background: #e8f5e9;
}

.trace-panel-warning {
  border: 1px solid #ef6c00;
  background: #fff3e0;
}

.trace-panel-error {
  border: 1px solid #c62828;
  background: #ffebee;
}

.trace-scan-panel {
  padding-bottom: 18px;
}

.trace-scan-input-wrap span {
  font-weight: 700;
}

.trace-scan-input {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 2px solid #f2b26f;
  background: #fffaf4;
}

.trace-node-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.trace-node-item {
  display: block;
}

.trace-node-item input {
  display: none;
}

.trace-node-item span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid #e6dccb;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
}

.trace-node-item small {
  font-size: 11px;
  color: #7b7b7b;
  font-weight: 500;
}

.trace-node-item input:checked + span {
  border-color: var(--accent);
  background: #fff4e9;
  color: #7f3e00;
}

.trace-scan-actions {
  display: grid;
  gap: 8px;
  position: sticky;
  bottom: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding-top: 6px;
}

.trace-submit-btn {
  min-height: 50px;
  font-size: 18px;
}

@media (max-width: 768px) {
  .trace-filter-grid {
    grid-template-columns: 1fr;
  }

  .trace-node-grid {
    grid-template-columns: 1fr 1fr;
  }

  .trace-scan-hero {
    padding-bottom: 8px;
  }

  .trace-scan-input {
    font-size: 28px;
    min-height: 56px;
  }

  .trace-scan-actions {
    position: sticky;
    bottom: 0;
    margin: 0 -4px;
    padding: 8px 4px 0;
  }
}

.trace-node-suggested span {
  border-color: #2e7d32;
  box-shadow: inset 0 0 0 1px #2e7d32;
}

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

.trace-recent-item {
  border: 1px solid #ebe3d4;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fffaf2;
}

.trace-recent-main {
  font-weight: 700;
  font-size: 14px;
}

.trace-recent-meta {
  margin-top: 2px;
  color: #6f6f6f;
  font-size: 12px;
}

.trace-recent-note {
  margin-top: 4px;
  font-size: 13px;
}

.trace-timeline {
  display: grid;
  gap: 8px;
}

.trace-timeline-item {
  border: 1px solid #e8e0d3;
  border-radius: 10px;
  padding: 10px;
  background: #f6f6f6;
}

.trace-timeline-node {
  font-weight: 700;
  font-size: 14px;
}

.trace-timeline-meta {
  margin-top: 2px;
  font-size: 12px;
  color: #6e6e6e;
}

.trace-timeline-done {
  background: #edf9f0;
  border-color: #b8e0c3;
}

.trace-timeline-current {
  border-left: 4px solid var(--accent);
}
