:root {
  --bg: #ECEEF0;
  --panel: #FFFFFF;
  --panel-2: #F5F6F7;
  --ink: #1B1E22;
  --ink-soft: #5B6169;
  --ink-faint: #8B929B;
  --line: #DBDFE3;
  --line-strong: #C3C9CF;

  --brand: #1F6F73;
  --brand-dark: #124F52;
  --brand-tint: #E3EFEE;

  --copper: #C97C3D;
  --copper-tint: #F7EBE0;

  --led-pending: #F0A63A;
  --led-progress: #3A8FE0;
  --led-parts: #9B6BD6;
  --led-done: #2FAE66;
  --led-picked: #6B7280;
  --led-cannot: #E15353;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 24, 28, 0.06), 0 4px 16px rgba(20, 24, 28, 0.06);
  --shadow-lift: 0 6px 24px rgba(20, 24, 28, 0.12);

  --font-display: 'IBM Plex Mono', ui-monospace, monospace;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--brand-dark);
  color: #EAF3F2;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  letter-spacing: 0.08em;
}
.brand-mark { color: var(--copper); font-size: 20px; }
.brand-name { font-weight: 600; font-size: 15px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: #C9DEDC;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.12); color: #fff; }

.btn-new {
  background: var(--copper);
  color: #241005;
  border: none;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.1s ease, background 0.15s ease;
}
.btn-new:hover { background: #DC8A47; }
.btn-new:active { transform: scale(0.98); }

.sidebar-foot {
  margin-top: auto;
  font-size: 11px;
  color: #8FB2AF;
  line-height: 1.5;
}

.main {
  padding: 32px 40px 60px;
  max-width: 1180px;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 14px 16px;
    gap: 16px;
  }
  .nav { flex-direction: row; }
  .sidebar-foot { display: none; }
  .btn-new { margin-left: auto; padding: 8px 12px; font-size: 13px; }
  .main { padding: 20px; }
}

/* ---------- Page header ---------- */
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 600; margin: 0; }
.page-sub { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.eyebrow {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--brand);
  text-transform: uppercase;
  margin: 0 0 4px;
}

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
}
.stat-label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}
.stat-card.accent .stat-value { color: var(--copper); }

/* ---------- Section ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 32px 0 14px;
}
.section-title { font-size: 15px; font-weight: 600; margin: 0; }

/* ---------- Filters / search ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.search-input, .select-input {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--ink);
}
.search-input { flex: 1; min-width: 180px; }
.status-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.status-pill {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status-pill.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- LED dot ---------- */
.led {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.03);
}
.led-pending { background: var(--led-pending); }
.led-in_progress { background: var(--led-progress); }
.led-waiting_parts { background: var(--led-parts); }
.led-completed { background: var(--led-done); }
.led-picked_up { background: var(--led-picked); }
.led-cannot_repair { background: var(--led-cannot); }

.status-text-pending { color: #9A6413; }
.status-text-in_progress { color: #1E5F91; }
.status-text-waiting_parts { color: #6A4795; }
.status-text-completed { color: #1D7A48; }
.status-text-picked_up { color: #4B5157; }
.status-text-cannot_repair { color: #A62F2F; }

/* ---------- Ticket tag card (signature element) ---------- */
.tag-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 16px 28px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}
.tag-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.tag-card::before {
  /* die-cut hole */
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line-strong);
}
.tag-card::after {
  /* perforation line */
  content: '';
  position: absolute;
  left: 24px;
  top: 0;
  bottom: 0;
  border-left: 1px dashed var(--line-strong);
}
.tag-main { min-width: 0; }
.tag-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.tag-number {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.tag-urgent {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--led-cannot);
  border: 1px solid var(--led-cannot);
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 0.04em;
}
.tag-device { font-weight: 600; font-size: 15px; }
.tag-issue {
  color: var(--ink-soft);
  font-size: 13px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-customer { font-size: 12.5px; color: var(--ink-faint); margin-top: 6px; }
.tag-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; justify-content: center; }
.tag-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.tag-cost { font-family: var(--font-display); font-size: 13px; color: var(--ink-soft); }

/* ---------- Table (customers) ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th, .table td {
  text-align: left;
  padding: 12px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--line);
}
.table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  background: var(--panel-2);
  font-weight: 600;
}
.table tr:last-child td { border-bottom: none; }
.table tr.clickable:hover { background: var(--panel-2); cursor: pointer; }

/* ---------- Empty state ---------- */
.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--panel);
}
.empty-title { font-weight: 600; color: var(--ink); margin-bottom: 4px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 24, 28, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--panel);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lift);
  padding: 26px 28px 28px;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 18px;
}
.modal-title { font-size: 17px; font-weight: 600; margin: 0; }
.modal-close {
  background: none; border: none; color: var(--ink-faint);
  font-size: 20px; line-height: 1; padding: 4px;
}
.modal-close:hover { color: var(--ink); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.full, .field.full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--panel);
  color: var(--ink);
  width: 100%;
}
.field textarea { resize: vertical; min-height: 64px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.btn-primary, .btn-secondary {
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border: none;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-strong); }
.btn-secondary:hover { background: var(--line); }

/* ---------- Ticket detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 760px) { .detail-grid { grid-template-columns: 1fr; } }

.panel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.panel-card h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 16px 20px;
  border-left: 2px solid var(--line);
  font-size: 13px;
  margin-left: 4px;
}
.timeline li:last-child { border-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: '';
  position: absolute;
  left: -5px; top: 2px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand);
}
.timeline time { display: block; color: var(--ink-faint); font-size: 11.5px; margin-top: 2px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 8px;
  font-size: 13.5px; box-shadow: var(--shadow-lift);
  z-index: 100;
}
.toast[hidden] { display: none; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-soft); margin-bottom: 16px; font-weight: 500;
}
.back-link:hover { color: var(--ink); }

.badge-count {
  font-family: var(--font-display);
  font-size: 11px;
  background: var(--brand-tint);
  color: var(--brand-dark);
  padding: 1px 7px;
  border-radius: 999px;
}
