:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --primary-dark: #0ea5e9;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

.hidden { display: none !important; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar .brand {
  font-weight: 700;
  font-size: 18px;
  padding: 0 8px 20px;
  color: var(--primary);
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

.nav-link:hover { background: var(--panel-2); color: var(--text); }
.nav-link.active { background: var(--panel-2); color: var(--text); }

.main { flex: 1; padding: 28px 32px; overflow-x: auto; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.topbar h1 { font-size: 22px; margin: 0; }

.btn {
  background: var(--primary-dark);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}

.btn:hover { background: var(--primary); }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: #b91c1c; }
.btn.small { padding: 5px 10px; font-size: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

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

.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 6px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.received, .badge.classified { background: #1e3a8a; color: #bfdbfe; }
.badge.assigned, .badge.in_progress { background: #7c2d12; color: #fed7aa; }
.badge.on_hold { background: #713f12; color: #fde68a; }
.badge.resolved, .badge.closed { background: #064e3b; color: #a7f3d0; }
.badge.rejected { background: #7f1d1d; color: #fecaca; }
.badge.public { background: #064e3b; color: #a7f3d0; }
.badge.internal { background: #1e3a8a; color: #bfdbfe; }
.badge.private { background: #7f1d1d; color: #fecaca; }

input, select, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-dark); }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }

.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.login-card h1 { font-size: 20px; margin: 0 0 20px; text-align: center; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  width: 640px;
  max-width: 92vw;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.modal h2 { margin: 0 0 16px; font-size: 18px; }

.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .name { width: 130px; color: var(--muted); flex-shrink: 0; }
.bar-row .track { flex: 1; background: var(--panel-2); border-radius: 6px; height: 22px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--primary-dark); }
.bar-row .count { width: 48px; text-align: right; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 12px 18px;
  border-radius: 8px;
  z-index: 100;
  animation: slideIn 0.25s ease;
}

.toast.error { border-left-color: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.muted { color: var(--muted); }
.section-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.field-group { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 12px; }

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.attachment-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  color: var(--text);
  overflow: hidden;
}

.attachment-item:hover { border-color: var(--primary); }

.attachment-thumb {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
}

.attachment-file {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 90px;
  font-size: 12px;
  word-break: break-all;
  color: var(--muted);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: zoom-out;
}

.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
}
