:root {
  --bg: #1A1D24;
  --bg-raised: #21252E;
  --bg-inset: #181A20;
  --border: #2E323D;
  --text: #E7E9EE;
  --text-dim: #8B919E;
  --text-faint: #5C616D;
  --amber: #E8A33D;
  --amber-dim: #4A3A20;
  --green: #5FB87C;
  --green-dim: #25342A;
  --red: #E1604F;
  --red-dim: #3A2826;
  --blue: #5B9BD5;
  --radius: 10px;
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--bg-inset);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 24px;
}

.brand-mark {
  width: 30px; height: 30px;
  background: var(--amber);
  color: #1A1D24;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
}

.brand-name {
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: 0.01em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  text-align: left;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover { background: var(--bg-raised); color: var(--text); }
.nav-item.active { background: var(--bg-raised); color: var(--amber); }

.sidebar-foot {
  margin-top: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-live { background: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }

/* Main */
.main { padding: 32px 40px; max-width: 1180px; }

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.18s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-head { margin-bottom: 28px; }
.view-head h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.view-head p { font-size: 13.5px; color: var(--text-dim); margin: 0; }

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px;
}

.stat-card .label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.stat-card .value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
}

.stat-card .value.accent { color: var(--amber); }
.stat-card .value.danger { color: var(--red); }
.stat-card .value.good { color: var(--green); }

/* Panel grid */
.panel-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.panel-head h2 { font-size: 14.5px; font-weight: 600; margin: 0 0 14px; }

.attention-list { display: flex; flex-direction: column; gap: 8px; }

.attention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-inset);
  border-radius: 7px;
  border-left: 3px solid var(--red);
  font-size: 13px;
}

.attention-item .meta { color: var(--text-dim); font-size: 12px; }

.rating-bars { display: flex; flex-direction: column; gap: 10px; }

.rating-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.rating-row .star-label { width: 40px; color: var(--text-dim); font-family: var(--font-mono); flex-shrink: 0; }
.rating-row .bar-track { flex: 1; height: 8px; background: var(--bg-inset); border-radius: 4px; overflow: hidden; }
.rating-row .bar-fill { height: 100%; background: var(--amber); border-radius: 4px; }
.rating-row .count { width: 28px; text-align: right; color: var(--text-dim); font-family: var(--font-mono); font-size: 11.5px; }

/* Table */
.table-wrap {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-inset); }
.data-table .muted { color: var(--text-dim); font-family: var(--font-mono); font-size: 12px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: lowercase;
}
.badge-active, .badge-resolved, .badge-closed { background: var(--green-dim); color: var(--green); }
.badge-flagged, .badge-urgent, .badge-open { background: var(--red-dim); color: var(--red); }
.badge-inactive, .badge-low { background: var(--bg-inset); color: var(--text-dim); }
.badge-in_progress, .badge-normal { background: var(--amber-dim); color: var(--amber); }
.badge-high { background: var(--amber-dim); color: var(--amber); }

select.status-select {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 4px 6px;
  cursor: pointer;
}

/* Filter chips */
.filter-row { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.chip {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.12s;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--amber-dim); color: var(--amber); border-color: transparent; }

/* Review list */
.review-list { display: flex; flex-direction: column; gap: 12px; }

.review-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.review-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.review-customer { font-weight: 600; font-size: 13.5px; }
.review-email { color: var(--text-faint); font-size: 11.5px; font-family: var(--font-mono); }
.review-date { color: var(--text-faint); font-size: 11.5px; font-family: var(--font-mono); }

.star-fill-row { display: flex; gap: 3px; margin-bottom: 8px; }
.star-seg { width: 16px; height: 6px; border-radius: 3px; background: var(--bg-inset); }
.star-seg.lit { background: var(--amber); }

.review-comment { font-size: 13.5px; line-height: 1.5; color: var(--text); margin-bottom: 10px; }

.review-response {
  background: var(--bg-inset);
  border-left: 2px solid var(--amber);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 8px;
}
.review-response strong { color: var(--amber); font-family: var(--font-mono); font-size: 11px; }

.respond-form { display: flex; gap: 8px; margin-top: 10px; }
.respond-form input {
  flex: 1;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 12.5px;
  font-family: var(--font-ui);
}
.respond-form input:focus { outline: none; border-color: var(--amber); }

button.btn {
  background: var(--amber);
  color: #1A1D24;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12.5px;
  padding: 8px 14px;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: opacity 0.12s;
}
button.btn:hover { opacity: 0.88; }
button.btn-ghost {
  background: var(--bg-inset);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

/* Ticket list */
.ticket-list { display: flex; flex-direction: column; gap: 10px; }

.ticket-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.12s;
}
.ticket-card:hover { border-color: var(--amber); }

.ticket-left { display: flex; flex-direction: column; gap: 4px; }
.ticket-subject { font-weight: 600; font-size: 13.5px; }
.ticket-meta { font-size: 11.5px; color: var(--text-faint); font-family: var(--font-mono); }
.ticket-right { display: flex; gap: 8px; align-items: center; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,11,14,0.7);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-backdrop.active { display: flex; }

.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
}

.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.reply-bubble {
  background: var(--bg-inset);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 12.5px;
}
.reply-bubble .author { font-family: var(--font-mono); font-size: 10.5px; color: var(--amber); margin-bottom: 4px; text-transform: uppercase; }
.reply-bubble.customer { border-left: 2px solid var(--blue); }
.reply-bubble.admin { border-left: 2px solid var(--amber); }

.reply-form { display: flex; gap: 8px; margin-top: 14px; }
.reply-form textarea {
  flex: 1;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--font-ui);
  resize: vertical;
  min-height: 60px;
}
.reply-form textarea:focus { outline: none; border-color: var(--amber); }

.empty-state {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 40px 0;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; align-items: center; }
  .nav { flex-direction: row; }
  .sidebar-foot { display: none; }
  .main { padding: 20px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}
