/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
  --bg:         #f4f6f8;
  --surface:    #ffffff;
  --border:     #e2e8ec;
  --sidebar:    #0d1b26;
  --sidebar-2:  #152130;
  --teal:       #1a7a8a;
  --teal-light: #e6f4f6;
  --teal-dark:  #145f6d;
  --text:       #111827;
  --text-2:     #4b5563;
  --text-3:     #9ca3af;
  --red:        #dc2626;
  --red-light:  #fef2f2;
  --amber:      #d97706;
  --amber-light:#fffbeb;
  --green:      #16a34a;
  --green-light:#f0fdf4;
  --blue:       #2563eb;
  --blue-light: #eff6ff;
  --purple:     #7c3aed;
  --radius:     10px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-lg:  0 10px 40px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.flex    { display: flex; }
.items-center { align-items: center; }
.gap-2   { gap: 8px; }
.gap-3   { gap: 12px; }
.ml-auto { margin-left: auto; }

/* ── Auth screen ─────────────────────────────────────────────────────────── */
.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 480px;
}

.auth-left {
  background: var(--sidebar);
  padding: 60px 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-left::before {
  content: '';
  position: absolute;
  top: -120px; right: -120px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(26,122,138,.25) 0%, transparent 70%);
  pointer-events: none;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 60px;
  color: rgba(255,255,255,.9);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .3px;
}

.brand-mark {
  width: 40px; height: 40px;
  background: var(--teal);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.brand-mark.sm { width: 32px; height: 32px; font-size: 11px; border-radius: 6px; }

.auth-headline {
  font-size: 52px;
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
  margin-bottom: 20px;
  letter-spacing: -1px;
}

.auth-headline em {
  font-style: italic;
  color: var(--teal);
  font-weight: 300;
}

.auth-sub {
  color: rgba(255,255,255,.5);
  font-size: 16px;
  line-height: 1.7;
  max-width: 380px;
  margin-bottom: 48px;
}

.auth-stats {
  display: flex;
  gap: 40px;
}

.a-stat span {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--teal);
  font-family: 'DM Mono', monospace;
  line-height: 1;
}

.a-stat small {
  font-size: 12px;
  color: rgba(255,255,255,.4);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 4px;
  display: block;
}

.auth-right {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 48px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--border);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

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

.field-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .3px;
}

.field-group input,
.field-group select,
.field-group textarea {
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  width: 100%;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26,122,138,.1);
}

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

.form-error {
  background: var(--red-light);
  color: var(--red);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
}

.auth-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-top: -4px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary:hover  { background: var(--teal-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-primary.full   { width: 100%; }

.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-light); }

.btn-danger {
  background: var(--red-light);
  color: var(--red);
  border: 1.5px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.btn-danger:hover { border-color: var(--red); }

.btn-sm { padding: 6px 12px !important; font-size: 12.5px !important; }

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

.sidebar {
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.5);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  user-select: none;
}

.nav-item svg {
  width: 17px; height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.nav-item:hover  { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }
.nav-item.active { background: var(--teal); color: #fff; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.user-avatar {
  width: 34px; height: 34px;
  background: var(--teal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 11px; color: rgba(255,255,255,.4); text-transform: capitalize; }

.logout-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.3);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all .15s;
  flex-shrink: 0;
  display: flex;
}

.logout-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.logout-btn:hover { color: rgba(255,255,255,.8); background: rgba(255,255,255,.08); }

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content { overflow: auto; }

.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 32px 0;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-sub   { font-size: 13px; color: var(--text-3); margin-top: 2px; }

.page-body { padding: 24px 32px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-body  { padding: 20px; }

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent, var(--teal));
}

.stat-card.red    { --accent: var(--red); }
.stat-card.amber  { --accent: var(--amber); }
.stat-card.green  { --accent: var(--green); }
.stat-card.blue   { --accent: var(--blue); }
.stat-card.purple { --accent: var(--purple); }

.stat-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; line-height: 1; color: var(--text); font-family: 'DM Mono', monospace; }

/* ── Dashboard grid ──────────────────────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

/* ── Table ───────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .6px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f2f4;
  font-size: 13.5px;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfc; cursor: pointer; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-open       { background: var(--blue-light);   color: var(--blue); }
.badge-in_progress{ background: var(--amber-light);  color: var(--amber); }
.badge-resolved   { background: var(--green-light);  color: var(--green); }
.badge-closed     { background: #f3f4f6;              color: var(--text-3); }

.badge-low      { background: var(--green-light);   color: var(--green); }
.badge-medium   { background: var(--blue-light);    color: var(--blue); }
.badge-high     { background: var(--amber-light);   color: var(--amber); }
.badge-critical { background: var(--red-light);     color: var(--red); }

/* ── Filters bar ─────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filters-bar select,
.filters-bar input {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}

.filters-bar select:focus,
.filters-bar input:focus { border-color: var(--teal); }

.filters-bar input { width: 200px; }

/* ── Ticket detail ───────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.meta-row:last-child { border-bottom: none; }
.meta-label { color: var(--text-3); font-weight: 500; }
.meta-value { font-weight: 500; }

.ticket-description {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
}

/* ── Comments ────────────────────────────────────────────────────────────── */
.comment {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.comment:last-of-type { border-bottom: none; }

.comment-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--teal-light);
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.comment-meta { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.comment-meta strong { color: var(--text); font-weight: 600; margin-right: 6px; }
.comment-text { font-size: 13.5px; color: var(--text-2); line-height: 1.6; }

/* ── Status select (in detail panel) ────────────────────────────────────── */
.status-select {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  width: 100%;
  cursor: pointer;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--sidebar);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  transition: opacity .3s, transform .3s;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}

.empty-icon { font-size: 40px; margin-bottom: 12px; display: block; }
.empty-state h3 { font-size: 16px; color: var(--text-2); margin-bottom: 6px; }

/* ── Loading ─────────────────────────────────────────────────────────────── */
.loading-row td {
  text-align: center;
  padding: 40px;
  color: var(--text-3);
}

/* ── Category pill ───────────────────────────────────────────────────────── */
.cat-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  background: #f3f4f6;
  color: var(--text-2);
  text-transform: capitalize;
}

/* ── Ticket ID ───────────────────────────────────────────────────────────── */
.ticket-id {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--teal);
  background: var(--teal-light);
  padding: 2px 7px;
  border-radius: 5px;
}

/* ── Back button ─────────────────────────────────────────────────────────── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-3);
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 4px;
  background: none;
  border: none;
  font-family: inherit;
  transition: color .15s;
}

.back-btn:hover { color: var(--teal); }
.back-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* ── Chart bar ───────────────────────────────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }

.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { font-size: 12px; width: 80px; color: var(--text-2); text-transform: capitalize; flex-shrink: 0; }
.bar-track { flex: 1; background: #f0f2f4; border-radius: 4px; height: 8px; overflow: hidden; }
.bar-fill  { height: 100%; background: var(--teal); border-radius: 4px; transition: width .5s ease; }
.bar-count { font-size: 12px; color: var(--text-3); font-family: 'DM Mono', monospace; width: 24px; text-align: right; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .auth-screen   { grid-template-columns: 1fr; }
  .auth-left     { display: none; }
  .app-shell     { grid-template-columns: 1fr; }
  .sidebar       { display: none; }
  .dash-grid,
  .detail-grid   { grid-template-columns: 1fr; }
}
