:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --border: #e4e6ef;
  --text: #1d2130;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --sidebar-w: 250px;
  --topbar-h: 64px;
}

[data-theme="dark"] {
  --bg: #10121a;
  --surface: #171a26;
  --surface-2: #1e2130;
  --border: #2a2e40;
  --text: #e7e9f2;
  --text-muted: #9298ab;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-soft: #1f2140;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background .2s ease, color .2s ease;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 40;
  transition: transform .2s ease;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 1.05rem;
}
.sidebar .brand .logo-dot {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: .85rem;
}
.sidebar nav { padding: 12px; }
.sidebar .nav-section-title {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); padding: 14px 12px 6px;
}
.sidebar .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--text); font-size: .9rem; font-weight: 500;
  margin-bottom: 2px;
}
.sidebar .nav-link:hover { background: var(--surface-2); color: var(--text); }
.sidebar .nav-link.active { background: var(--primary-soft); color: var(--primary); }
.sidebar .nav-link .badge-count {
  margin-left: auto; background: var(--primary); color: #fff;
  font-size: .7rem; padding: 1px 7px; border-radius: 999px;
}

.main-area { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 30;
}
.topbar .search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border-radius: 8px;
  padding: 8px 12px; width: 320px; max-width: 40vw;
}
.topbar .search-box input {
  border: none; background: transparent; outline: none; color: var(--text);
  width: 100%; font-size: .88rem;
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: none; cursor: pointer; color: var(--text);
  position: relative;
}
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 999px; background: var(--danger);
}
.avatar {
  width: 36px; height: 36px; border-radius: 999px; object-fit: cover;
  background: var(--primary-soft);
}

.content { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* ---------- Cards / tables / common ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-body { padding: 20px; }
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px; margin-bottom: 22px;
}
.stat-card { padding: 18px 20px; }
.stat-card .stat-label { color: var(--text-muted); font-size: .8rem; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; }

table.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data-table th {
  text-align: left; padding: 10px 14px; color: var(--text-muted);
  border-bottom: 1px solid var(--border); font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .04em;
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
table.data-table tr:last-child td { border-bottom: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-weight: 600; font-size: .88rem;
  border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.badge-open { background: #dbeafe; color: #1d4ed8; }
.badge-assigned { background: #fef3c7; color: #b45309; }
.badge-in_progress { background: #fde68a; color: #92400e; }
.badge-resolved { background: #dcfce7; color: #15803d; }
.badge-closed { background: #e5e7eb; color: #4b5563; }
.badge-low { background: #e5e7eb; color: #374151; }
.badge-medium { background: #dbeafe; color: #1d4ed8; }
.badge-high { background: #fed7aa; color: #c2410c; }
.badge-urgent { background: #fecaca; color: #b91c1c; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: .9rem; outline: none;
}
.form-control:focus { border-color: var(--primary); background: var(--surface); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-error { color: var(--danger); font-size: .82rem; margin-top: 4px; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .88rem; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-info { background: var(--primary-soft); color: var(--primary-dark); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}
.auth-card { width: 100%; max-width: 460px; padding: 32px; }
.auth-logo { text-align: center; margin-bottom: 18px; font-weight: 800; font-size: 1.3rem; }

/* ---------- Public / homepage ---------- */
.public-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 5%; border-bottom: 1px solid var(--border); background: var(--surface);
}
.hero {
  padding: 80px 5% 60px; text-align: center;
  background: linear-gradient(180deg, var(--primary-soft), var(--bg));
}
.hero h1 { font-size: 2.4rem; margin-bottom: 10px; }
.hero p.tagline { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 26px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.section { padding: 50px 5%; max-width: 1200px; margin: 0 auto; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .topbar .search-box { display: none; }
}
