:root {
  --navy: #1d2c7c;
  --navy-dark: #131d58;
  --royal: #007cc3;
  --royal-dark: #00588a;
  --orange: #f15d22;
  --orange-dark: #c94716;
  --green: #8dc63f;
  --green-dark: #6ba32a;
  --yellow: #ffc21a;

  --bg: #f5f6fb;
  --surface: rgba(255,255,255,0.72);
  --surface-solid: #ffffff;
  --border: rgba(29,44,124,0.08);
  --text: #1a1d3a;
  --text-dim: #6b7290;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ---- decorative geometric triangles (logo-inspired) ---- */
.tri { position: absolute; width: 0; height: 0; opacity: 0.10; pointer-events: none; }
.tri-navy  { border-style: solid; }
body::before, body::after {
  content: ""; position: fixed; pointer-events: none; z-index: 0;
  width: 0; height: 0;
}
body::before {
  top: -20px; right: 60px;
  border-left: 90px solid transparent;
  border-bottom: 140px solid rgba(29,44,124,0.06);
}
body::after {
  bottom: -30px; right: -10px;
  border-right: 120px solid transparent;
  border-top: 170px solid rgba(241,93,34,0.06);
}

a { color: var(--royal); }

/* ---- Top bar ---- */
.topbar {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 12px rgba(29,44,124,0.06);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand .logo-chip { display: flex; align-items: center; }
.brand .logo-chip img { height: 42px; display: block; }
.brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand .brand-text strong { font-size: 18px; letter-spacing: 0.2px; color: var(--navy); }

/* ---- Layout: sidebar + content ---- */
.layout { display: flex; align-items: flex-start; min-height: calc(100vh - 67px); position: relative; z-index: 1; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 67px;
  height: calc(100vh - 67px);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; }

/* ---- Top bar user profile ---- */
.topbar-profile { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--royal), var(--green));
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
}
.topbar-profile-info { line-height: 1.25; }
.topbar-profile-info .name { color: var(--navy); font-size: 13px; font-weight: 700; }
.topbar-profile-info .role { color: var(--text-dim); font-size: 11px; text-transform: capitalize; }
.topbar-logout {
  flex-shrink: 0; color: var(--text-dim); text-decoration: none; font-size: 16px;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; transition: all 0.15s ease; border: 1px solid var(--border);
}
.topbar-logout:hover { background: var(--navy); color: white; border-color: var(--navy); }
.sidebar::before {
  content: ""; position: absolute; left: -30px; bottom: -40px;
  width: 0; height: 0;
  border-left: 90px solid transparent;
  border-top: 130px solid rgba(141,198,63,0.18);
}
.sidebar::after {
  content: ""; position: absolute; right: -25px; bottom: 10px;
  width: 0; height: 0;
  border-right: 70px solid transparent;
  border-bottom: 100px solid rgba(0,124,195,0.18);
}
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
  position: relative;
  z-index: 1;
}
.side-link:hover { background: rgba(255,255,255,0.10); color: white; }
.side-link.active {
  background: white;
  color: var(--navy);
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}
.side-icon { width: 20px; text-align: center; font-size: 16px; font-weight: 800; }
.side-link.status-open .side-icon { color: var(--orange); }
.side-link.status-resolved .side-icon { color: var(--royal); }
.side-link.status-closed .side-icon { color: var(--green); }
.count-pill {
  margin-left: auto; background: rgba(255,255,255,0.14); padding: 2px 9px;
  border-radius: 10px; font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.85);
}
.side-link.active .count-pill { background: #eef0fb; color: var(--navy); }
.side-divider { height: 1px; background: rgba(255,255,255,0.14); margin: 10px 4px; position: relative; z-index: 1; }
.side-new {
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  color: white; box-shadow: 0 4px 14px rgba(241,93,34,0.4);
}
.side-new:hover { filter: brightness(1.08); color: white; }
.side-admin { background: rgba(255,255,255,0.08); color: white; }
.side-admin:hover { background: rgba(255,255,255,0.16); color: white; }

.content { flex: 1; width: 100%; min-width: 0; padding: 28px 32px; max-width: 1800px; position: relative; z-index: 1; }

h1 { color: var(--navy); margin-top: 0; font-weight: 700; }

.new-ticket-banner {
  display: none;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--royal), var(--navy));
  color: white;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(29,44,124,0.25);
  animation: banner-in 0.2s ease;
}
.new-ticket-banner.show { display: flex; }
@keyframes banner-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Stat tiles ---- */
.stat-row { display: flex; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.stat-tile {
  flex: 1; min-width: 170px; border-radius: 18px; padding: 18px 20px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: 0 4px 18px rgba(29,44,124,0.07);
  position: relative;
  overflow: hidden;
  border-top: 4px solid transparent;
}
.stat-open { border-top-color: var(--orange); }
.stat-resolved { border-top-color: var(--royal); }
.stat-closed { border-top-color: var(--green); }
.stat-tile .num { font-size: 32px; font-weight: 800; line-height: 1; color: var(--navy); }
.stat-tile .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); margin-top: 4px; font-weight: 700; }
.stat-tile .trend { font-size: 12px; font-weight: 700; margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 8px; }
.trend.up { color: #b8380f; background: rgba(241,93,34,0.1); }
.trend.down { color: #4c7a1c; background: rgba(141,198,63,0.15); }
.trend.flat { color: var(--text-dim); background: rgba(107,114,144,0.1); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; border-radius: 18px; box-shadow: 0 4px 18px rgba(29,44,124,0.06); }
table {
  width: 100%; min-width: 640px; border-collapse: collapse;
  background: var(--surface-solid);
  border: 1px solid var(--border);
}
.table-wrap table { border-radius: 0; box-shadow: none; }
th, td { text-align: left; padding: 12px 14px; }
.ticket-table { table-layout: fixed; min-width: 920px; }
.ticket-table .cell-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th { background: var(--navy); font-size: 11px; text-transform: uppercase; color: white; letter-spacing: 0.5px; font-weight: 700; border-bottom: 2px solid var(--navy-dark); }
td { color: var(--text); }
tbody tr { border-left: 3px solid transparent; border-bottom: 2px solid #dfe2f2; transition: background 0.12s ease; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f7f8ff; }
tbody tr.row-open { border-left-color: var(--orange); background: rgba(241,93,34,0.06); }
tbody tr.row-resolved { border-left-color: var(--royal); background: rgba(0,124,195,0.06); }
tbody tr.row-closed { border-left-color: var(--green); background: rgba(141,198,63,0.08); }
tbody tr.row-open:hover { background: rgba(241,93,34,0.13); }
tbody tr.row-resolved:hover { background: rgba(0,124,195,0.13); }
tbody tr.row-closed:hover { background: rgba(141,198,63,0.15); }
tbody tr.row-sla-overdue { border-left-color: #ef4444; background: rgba(239,68,68,0.14); }
tbody tr.row-sla-overdue:hover { background: rgba(239,68,68,0.22); }

.badge { display: inline-block; padding: 4px 12px; border-radius: 12px; font-size: 11px; font-weight: 800; letter-spacing: 0.4px; }
.badge-open { background: rgba(241,93,34,0.12); color: var(--orange-dark); }
.badge-resolved { background: rgba(0,124,195,0.12); color: var(--royal-dark); }
.badge-closed { background: rgba(141,198,63,0.15); color: var(--green-dark); }
.badge-priority-high { background: var(--orange); color: white; }
.badge-priority-normal, .badge-priority-low { background: rgba(107,114,144,0.12); color: var(--text-dim); }
.badge-agent { background: rgba(29,44,124,0.1); color: var(--navy); }
.badge-unclaimed { background: rgba(107,114,144,0.12); color: var(--text-dim); }
.badge-type-incident { background: rgba(241,93,34,0.12); color: var(--orange-dark); }
.badge-type-service { background: rgba(0,124,195,0.12); color: var(--royal-dark); }
.sla-bar-wrap { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sla-bar-track { width: 52px; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.sla-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s ease; }
.sla-fill-green { background: var(--green); }
.sla-fill-yellow { background: #eab308; }
.sla-fill-orange { background: var(--orange); }
.sla-fill-red { background: #ef4444; }
.sla-bar-label { font-size: 11px; color: var(--text-dim); white-space: nowrap; font-weight: 700; }

/* ---- Buttons ---- */
.btn {
  display: inline-block; padding: 10px 18px; color: white;
  background: linear-gradient(135deg, var(--royal), var(--navy));
  border: none; border-radius: 12px; text-decoration: none; cursor: pointer;
  font-size: 14px; font-weight: 700; box-shadow: 0 4px 14px rgba(29,44,124,0.25);
  transition: all 0.15s ease;
}
.btn:hover { filter: brightness(1.08); box-shadow: 0 4px 18px rgba(29,44,124,0.35); }
.btn.btn-primary { background: linear-gradient(135deg, var(--orange), var(--orange-dark)); box-shadow: 0 4px 14px rgba(241,93,34,0.3); }
.btn.btn-admin { background: white; color: var(--navy); border: 1px solid var(--border); box-shadow: none; }
.btn.btn-admin:hover { background: #f2f3fb; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

form.card, .card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  padding: 22px; border-radius: 18px; box-shadow: 0 4px 20px rgba(29,44,124,0.07); margin-bottom: 18px;
}
input[type=text], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid #dde0f0; border-radius: 10px;
  font-size: 14px; margin-bottom: 12px;
  background: #fbfbfe; color: var(--text);
}
input[type=text]::placeholder, textarea::placeholder { color: var(--text-dim); }
input[type=text]:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--royal); box-shadow: 0 0 0 3px rgba(0,124,195,0.14);
}
label { display: block; font-weight: 700; margin-bottom: 4px; font-size: 13px; color: var(--navy); }
.meta { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }
.status-form { display: inline; margin-right: 8px; }

/* ---- Login page ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; background: var(--bg); }
.login-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 22px; padding: 40px 36px; text-align: center; width: 360px;
  box-shadow: 0 20px 50px rgba(29,44,124,0.14);
  border-top: 5px solid var(--orange);
}
.login-card .logo-chip img { height: 64px; margin-bottom: 14px; }
.login-card h1 { font-size: 20px; margin: 6px 0 4px; color: var(--navy); }

/* ---- Responsive: fit both a ~14" laptop window and a wide monitor ---- */
@media (max-width: 1100px) {
  .content { padding: 22px 20px; }
  .stat-tile { min-width: 140px; }
}
@media (max-width: 900px) {
  .sidebar { width: 76px; padding: 18px 10px; }
  .side-link { justify-content: center; padding: 10px; }
  .side-link span:not(.side-icon) { display: none; }
  .side-icon { width: auto; }
  .topbar-profile-info { display: none; }
  .brand .brand-text { display: none; }
}
@media (max-width: 640px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; flex-direction: row; overflow-x: auto; overflow-y: visible; padding: 10px; position: static; }
  .sidebar-nav { flex-direction: row; }
  .stat-row { flex-direction: column; }
}
