:root {
  --brand-primary: #91040C;
  --brand-primary-dark: #6e0309;
  --brand-bg: #1a0e08;
  --brand-card: #231208;
  --brand-card2: #2c1710;
  --brand-border: rgba(208,186,152,0.12);
  --brand-text: #f5ebe0;
  --brand-muted: rgba(245,235,224,0.5);
  --brand-accent: #d4a76a;
  --sidebar-w: 256px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--brand-bg); color: var(--brand-text); min-height: 100vh; }

/* Sidebar */
#sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh;
  background: var(--brand-card); border-right: 1px solid var(--brand-border);
  display: flex; flex-direction: column; z-index: 50; overflow-y: auto;
  transition: transform .25s ease;
}
.sidebar-logo { padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid var(--brand-border); }
.sidebar-logo .brand { font-size: 1.5rem; font-weight: 800; color: #fff; letter-spacing: 2px; }
.sidebar-logo .badge-logo {
  display: inline-block; margin-left: 8px; background: var(--brand-primary); color: #fff;
  font-size: 0.6rem; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  letter-spacing: 1px; vertical-align: middle;
}
.sidebar-logo .sub { font-size: 0.7rem; color: var(--brand-muted); margin-top: 2px; }
.nav-section-label {
  padding: 1rem 1rem 0.35rem; font-size: 0.65rem; font-weight: 700;
  color: var(--brand-muted); letter-spacing: 1.5px; text-transform: uppercase;
}
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 0.6rem 1rem;
  font-size: 0.875rem; font-weight: 500; color: var(--brand-muted);
  cursor: pointer; border-radius: 6px; margin: 1px 8px;
  transition: background .15s, color .15s; border: none; background: none;
  width: calc(100% - 16px); text-align: left;
}
.nav-link:hover, .nav-link.active { background: rgba(145,4,12,0.18); color: #fff; }
.nav-link.active { color: #fca5a5; }
.nav-link i { width: 18px; text-align: center; font-size: 0.85rem; }
.sidebar-footer { margin-top: auto; padding: 1rem; border-top: 1px solid var(--brand-border); }
.admin-info { display: flex; align-items: center; gap: 10px; }
.admin-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.admin-name { font-size: 0.8rem; font-weight: 600; color: #fff; }
.admin-role { font-size: 0.68rem; color: var(--brand-accent); }

/* Main */
#main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(26,14,8,0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--brand-border);
  padding: 0.9rem 1.75rem; display: flex; align-items: center; justify-content: space-between;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: #fff; }
.topbar-meta { font-size: 0.75rem; color: var(--brand-muted); }
.content-area { padding: 1.75rem; }

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

/* Stats */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--brand-card2); border: 1px solid var(--brand-border);
  border-radius: 12px; padding: 1.1rem 1.25rem;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 3px; height: 100%; background: var(--accent-color, var(--brand-primary));
}
.stat-label { font-size: 0.72rem; font-weight: 600; color: var(--brand-muted); text-transform: uppercase; letter-spacing: 0.8px; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: #fff; line-height: 1; }
.stat-sub { font-size: 0.7rem; color: var(--brand-muted); }
.stat-icon { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); font-size: 2rem; opacity: 0.07; }

/* Section header */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: .75rem; }
.section-title { font-size: 1rem; font-weight: 700; color: #fff; }

/* Filter bar */
.filter-bar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.search-input {
  background: var(--brand-card2); border: 1px solid var(--brand-border);
  color: var(--brand-text); border-radius: 8px; padding: 0.5rem 0.9rem;
  font-size: 0.82rem; outline: none; min-width: 200px;
}
.search-input:focus { border-color: var(--brand-primary); }
.search-input::placeholder { color: var(--brand-muted); }
select.filter-select {
  background: var(--brand-card2); border: 1px solid var(--brand-border);
  color: var(--brand-text); border-radius: 8px; padding: 0.5rem 0.75rem;
  font-size: 0.82rem; outline: none; cursor: pointer;
}

/* Table */
.table-wrap { background: var(--brand-card2); border: 1px solid var(--brand-border); border-radius: 12px; overflow: hidden; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.data-table thead { background: rgba(145,4,12,0.12); }
.data-table th {
  padding: .65rem 1rem; font-size: 0.7rem; font-weight: 700;
  color: var(--brand-muted); text-transform: uppercase; letter-spacing: 0.8px;
  text-align: left; white-space: nowrap; border-bottom: 1px solid var(--brand-border);
}
.data-table td {
  padding: .7rem 1rem; font-size: 0.82rem; color: var(--brand-text);
  border-bottom: 1px solid rgba(208,186,152,0.06); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.025); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.4px;
}
.badge-green  { background: rgba(16,185,129,.15); color: #34d399; }
.badge-red    { background: rgba(239,68,68,.15);  color: #f87171; }
.badge-blue   { background: rgba(59,130,246,.15); color: #93c5fd; }
.badge-amber  { background: rgba(245,158,11,.15); color: #fcd34d; }
.badge-purple { background: rgba(139,92,246,.15); color: #c4b5fd; }
.badge-gray   { background: rgba(156,163,175,.12);color: #9ca3af; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: .4rem .85rem;
  border-radius: 7px; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; border: none; transition: all .15s;
}
.btn-primary   { background: var(--brand-primary); color: #fff; }
.btn-primary:hover { background: var(--brand-primary-dark); }
.btn-danger    { background: rgba(239,68,68,.15); color: #f87171; border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-success   { background: rgba(16,185,129,.15); color: #34d399; border: 1px solid rgba(16,185,129,.25); }
.btn-success:hover { background: rgba(16,185,129,.25); }
.btn-outline   { background: transparent; color: var(--brand-muted); border: 1px solid var(--brand-border); }
.btn-outline:hover { color: #fff; border-color: rgba(208,186,152,.3); }
.btn-sm { padding: .28rem .6rem; font-size: 0.72rem; }
.btn-icon { padding: .4rem .5rem; }

/* Card */
.card { background: var(--brand-card2); border: 1px solid var(--brand-border); border-radius: 12px; padding: 1.25rem; margin-bottom: 1rem; }
.card-title {
  font-size: 0.9rem; font-weight: 700; color: #fff; margin-bottom: .75rem;
  padding-bottom: .6rem; border-bottom: 1px solid var(--brand-border);
  display: flex; align-items: center; gap: 8px;
}

/* Ticket card */
.ticket-card {
  background: var(--brand-card2); border: 1px solid var(--brand-border);
  border-radius: 10px; padding: 1rem 1.1rem; margin-bottom: .75rem;
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-start;
}
.ticket-card.t-open { border-left: 3px solid #f87171; }
.ticket-card.t-resolved { border-left: 3px solid #34d399; opacity: .7; }
.ticket-card.t-in-progress { border-left: 3px solid #fcd34d; }
.ticket-body { flex: 1; min-width: 200px; }
.ticket-id { font-size: 0.68rem; color: var(--brand-muted); margin-bottom: 3px; }
.ticket-subject { font-size: 0.9rem; font-weight: 600; color: #fff; margin-bottom: 4px; }
.ticket-desc { font-size: 0.78rem; color: var(--brand-muted); line-height: 1.5; }
.ticket-meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; align-items: center; }
.ticket-actions { display: flex; flex-direction: column; gap: .4rem; flex-shrink: 0; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #231208; border: 1px solid var(--brand-border); border-radius: 14px;
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  transform: scale(.95); transition: transform .2s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
  padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--brand-border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; color: #fff; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--brand-border); display: flex; justify-content: flex-end; gap: .6rem; }

/* Form */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--brand-muted); margin-bottom: .35rem; }
.form-control {
  width: 100%; background: rgba(255,255,255,0.04); border: 1px solid var(--brand-border);
  color: var(--brand-text); border-radius: 8px; padding: .55rem .85rem;
  font-size: 0.84rem; outline: none; font-family: 'Inter', sans-serif;
}
.form-control:focus { border-color: var(--brand-primary); }
.form-control::placeholder { color: var(--brand-muted); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Log */
.log-item { display: flex; gap: .75rem; align-items: flex-start; padding: .65rem 0; border-bottom: 1px solid var(--brand-border); }
.log-item:last-child { border-bottom: none; }
.log-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.log-text { font-size: 0.8rem; color: var(--brand-muted); line-height: 1.5; }
.log-time { font-size: 0.7rem; color: var(--brand-muted); margin-top: 2px; }

/* Toast */
#toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: #231208; border: 1px solid var(--brand-border);
  border-radius: 10px; padding: .75rem 1.1rem; font-size: 0.82rem; color: #fff;
  display: flex; align-items: center; gap: 8px; z-index: 1000;
  transform: translateY(80px); opacity: 0; transition: all .3s;
  pointer-events: none; max-width: 320px;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { border-color: rgba(16,185,129,.4); }
#toast.error   { border-color: rgba(239,68,68,.4); }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(208,186,152,0.15); border-radius: 4px; }

/* Login */
#login-screen {
  position: fixed; inset: 0; background: #1a0e08;
  display: flex; align-items: center; justify-content: center; z-index: 500; padding: 1rem;
}
.login-card {
  background: var(--brand-card2); border: 1px solid var(--brand-border);
  border-radius: 16px; padding: 2rem; width: 100%; max-width: 380px;
}
.login-logo { text-align: center; margin-bottom: 1.5rem; }

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  #sidebar { transform: translateX(-256px); width: 256px; }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; }
  .mobile-toggle { display: flex !important; }
}
.mobile-toggle { display: none; }
