:root {
  --primary: #0a3d62;
  --primary-light: #1a5276;
  --accent: #e74c3c;
  --accent2: #f39c12;
  --success: #27ae60;
  --info: #2980b9;
  --sidebar-w: 270px;
  --bg: #f0f4f8;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-muted: #7f8c8d;
  --border: #dfe6e9;
  --shadow: 0 4px 24px rgba(10,61,98,0.10);
  --shadow-hover: 0 8px 32px rgba(10,61,98,0.18);
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background: var(--bg); color: var(--text); margin: 0; }

/* AUTH */
#auth-page { min-height: 100vh; background: linear-gradient(135deg, #0a3d62 0%, #1a5276 40%, #154360 100%); display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
#auth-page::before { content: ''; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); }
.auth-card { background: white; border-radius: 20px; padding: 44px; width: 100%; max-width: 430px; box-shadow: 0 32px 80px rgba(0,0,0,0.35); position: relative; z-index: 1; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.logo-icon { width: 68px; height: 68px; background: linear-gradient(135deg, var(--primary), var(--accent)); border-radius: 18px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; font-size: 28px; color: white; box-shadow: 0 8px 24px rgba(10,61,98,0.3); }
.auth-logo h2 { font-size: 21px; font-weight: 800; color: var(--primary); letter-spacing: -0.5px; margin: 0; }
.auth-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.form-label { font-weight: 600; font-size: 13px; color: var(--text); }
.form-control { border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 11px 14px; font-size: 14px; transition: all 0.2s; width: 100%; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10,61,98,0.12); outline: none; }
.input-icon-wrap { position: relative; }
.input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.form-control.with-icon { padding-left: 40px; }
.pass-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; }
.btn-primary-main { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; border: none; border-radius: var(--radius-sm); padding: 13px 24px; font-weight: 700; font-size: 15px; width: 100%; cursor: pointer; transition: all 0.2s; font-family: inherit; letter-spacing: 0.3px; }
.btn-primary-main:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(10,61,98,0.35); }
.auth-footer { text-align: center; margin-top: 20px; font-size: 12px; color: var(--text-muted); }

/* SIDEBAR */
#sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); background: var(--primary); z-index: 1002; overflow-y: auto; transition: transform 0.3s ease; display: flex; flex-direction: column; transform: translateX(0); }
.sidebar-brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.brand-icon { width: 40px; height: 40px; background: white; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--primary); margin-bottom: 10px; font-weight: 900; }
.sidebar-brand h6 { color: white; font-weight: 800; font-size: 14px; margin-bottom: 2px; }
.sidebar-brand p { color: rgba(255,255,255,0.55); font-size: 11px; margin: 0; }
.sidebar-user { padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: white; flex-shrink: 0; }
.user-name { color: white; font-weight: 600; font-size: 13px; }
.user-role { color: rgba(255,255,255,0.55); font-size: 11px; }
#sidebar nav { padding: 14px 12px; flex: 1; }
.nav-group-title { color: rgba(255,255,255,0.4); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; padding: 0 8px 6px; margin-top: 10px; }
.nav-item-link { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,0.75); text-decoration: none; padding: 10px 12px; border-radius: 8px; margin-bottom: 2px; font-size: 13.5px; font-weight: 500; transition: all 0.15s; cursor: pointer; }
.nav-item-link:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-item-link.active { background: white; color: var(--primary); font-weight: 700; }
.nav-icon { width: 18px; text-align: center; font-size: 14px; }
.nav-badge { margin-left: auto; background: var(--accent); color: white; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }

/* TOPBAR */
#topbar { position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: 62px; background: white; z-index: 999; display: flex; align-items: center; padding: 0 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); gap: 14px; }
.topbar-title { font-weight: 700; font-size: 16px; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-btn { width: 36px; height: 36px; border-radius: 8px; border: 1.5px solid var(--border); background: white; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.15s; font-size: 14px; color: var(--text-muted); text-decoration: none; }
.topbar-btn:hover { border-color: var(--primary); color: var(--primary); }

/* MAIN CONTENT */
#main-content { margin-left: var(--sidebar-w); padding-top: 62px; min-height: 100vh; display: flex; flex-direction: column; }
.page-content { padding: 26px; flex: 1; }
.app-footer { padding: 20px; text-align: center; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); }

/* FLASH ALERTS */
.alert-flash { padding: 14px 20px; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; position: relative; }
.alert-flash-success { background: #f0fdf4; border-left: 4px solid var(--success); color: #166534; }
.alert-flash-error { background: #fef2f2; border-left: 4px solid var(--accent); color: #991b1b; }
.alert-close { margin-left: auto; background: none; border: none; font-size: 20px; cursor: pointer; opacity: 0.5; line-height: 1; }
.alert-close:hover { opacity: 1; }

/* CARDS */
.card { background: var(--card-bg); border-radius: var(--radius); border: none; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 0; }
.card-header-custom { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-header-custom h5 { font-weight: 700; font-size: 14.5px; margin: 0; flex: 1; }
.card-body-custom { padding: 20px; }

/* STAT CARDS */
.stat-card { background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); transition: all 0.2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 19px; margin-bottom: 12px; }
.stat-icon.blue { background: #eaf2fb; color: var(--primary); }
.stat-icon.red { background: #fdecea; color: var(--accent); }
.stat-icon.green { background: #eafaf1; color: var(--success); }
.stat-icon.orange { background: #fef9e7; color: var(--accent2); }
.stat-number { font-size: 26px; font-weight: 800; letter-spacing: -1px; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }
.stat-trend { font-size: 12px; font-weight: 600; margin-top: 6px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--accent); }

/* TICKET ITEMS */
.ticket-item { padding: 15px 20px; border-bottom: 1px solid var(--border); transition: background 0.15s; color: var(--text); }
.ticket-item:last-child { border-bottom: none; }
.ticket-item:hover { background: #f8fbff; }
.ticket-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.ticket-id { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-muted); }
.badge-status { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; display: inline-block; }
.badge-open { background: #fdecea; color: var(--accent); }
.badge-process { background: #fef9e7; color: #e67e22; }
.badge-closed { background: #eafaf1; color: var(--success); }
.badge-pending { background: #eaf2fb; color: var(--info); }
.ticket-title { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.ticket-sub { font-size: 12px; color: var(--text-muted); }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.priority-high { background: var(--accent); }
.priority-medium { background: var(--accent2); }
.priority-low { background: var(--success); }

/* KB ITEMS */
.kb-item { padding: 16px 20px; border-bottom: 1px solid var(--border); color: var(--text); }
.kb-item:last-child { border-bottom: none; }
.kb-item:hover { background: #f8fbff; }
.kb-category { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; background: #eaf2fb; color: var(--primary); margin-bottom: 5px; }
.kb-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.kb-preview { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.kb-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.kb-tag { display: inline-block; background: #f0f4f8; color: var(--text-muted); padding: 3px 10px; border-radius: 20px; font-size: 12px; margin-right: 4px; margin-top: 4px; }
.kb-section { background: #f8f9fa; border-radius: 10px; padding: 16px 18px; }
.kb-section.success { background: #f0fdf4; }
.kb-section-title { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 10px; }
.kb-section-title.success { color: var(--success); }
.kb-section-body { font-size: 14px; line-height: 1.8; }

/* SEARCH */
.search-container { position: relative; }
.search-container input { width: 100%; padding: 14px 18px 14px 48px; border: 2px solid var(--border); border-radius: var(--radius); font-size: 15px; transition: all 0.2s; background: white; }
.search-container input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(10,61,98,0.1); outline: none; }
.search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 17px; color: var(--text-muted); }
.search-dropdown { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: white; border-radius: var(--radius); box-shadow: var(--shadow-hover); z-index: 100; max-height: 320px; overflow-y: auto; border: 1px solid var(--border); }
.search-dd-item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); transition: background 0.15s; }
.search-dd-item:hover { background: #f8fbff; }
.search-dd-cat { font-size: 11px; color: var(--primary); font-weight: 700; display: block; margin-bottom: 3px; }
.search-dd-title { font-size: 13.5px; font-weight: 600; }
.search-dd-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* PROGRESS */
.progress-item { margin-bottom: 12px; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.progress-bar-wrap { background: #f0f4f8; border-radius: 20px; height: 7px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 20px; transition: width 1s ease; }

/* CHART */
.chart-bar-wrap { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart-bar { width: 100%; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--primary-light), var(--primary)); min-height: 4px; }
.chart-bar-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.chart-bar-val { font-size: 10px; color: var(--text-muted); }

/* UPLOAD ZONE */
.upload-zone { border: 2.5px dashed var(--border); border-radius: var(--radius); padding: 28px 20px; text-align: center; cursor: pointer; transition: all 0.2s; background: #fafbfc; }
.upload-zone:hover { border-color: var(--primary); background: #eaf2fb; }
.upload-icon { font-size: 32px; color: var(--text-muted); margin-bottom: 8px; }
.upload-zone p { font-size: 13px; color: var(--text-muted); margin: 0; }

/* TABLES */
.table-custom { width: 100%; border-collapse: collapse; }
.table-custom th { background: #f8f9fa; padding: 11px 16px; text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
.table-custom td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.table-custom tr:last-child td { border-bottom: none; }
.table-custom tr:hover td { background: #f8fbff; }

/* TABS */
.tab-nav { display: flex; gap: 4px; background: #f0f4f8; padding: 4px; border-radius: var(--radius-sm); }
.tab-btn { flex: 1; padding: 8px 12px; border: none; background: transparent; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; font-family: inherit; color: var(--text-muted); text-decoration: none; text-align: center; }
.tab-btn.active, .tab-btn:hover { background: white; color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

/* BUTTONS */
.btn-custom { padding: 9px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13.5px; cursor: pointer; border: none; transition: all 0.2s; font-family: inherit; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn-blue { background: var(--primary); color: white; }
.btn-blue:hover { background: var(--primary-light); color: white; }
.btn-green { background: var(--success); color: white; }
.btn-green:hover { filter: brightness(1.1); }
.btn-red { background: var(--accent); color: white; }
.btn-red:hover { filter: brightness(1.1); }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* UTILS */
.text-small { font-size: 12.5px; color: var(--text-muted); margin-bottom: 2px; }
.fw-600 { font-weight: 600; }
.section-title { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 4px; }
.section-sub { font-size: 13.5px; color: var(--text-muted); margin-bottom: 22px; }
.reply-helpdesk { border-left: 3px solid var(--primary); }
.reply-user { border-left: 3px solid var(--accent2); }

/* SIDEBAR OVERLAY */
#sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1001; display: none; }
#sidebar-overlay.show { display: block; }

/* COLLAPSED SIDEBAR (DESKTOP) */
body.sidebar-collapsed { --sidebar-w: 80px; }

body.sidebar-collapsed .sidebar-brand > div:last-child,
body.sidebar-collapsed .user-name,
body.sidebar-collapsed .user-role,
body.sidebar-collapsed .nav-group-title,
body.sidebar-collapsed .nav-badge { display: none; }

body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 20px 0; }
body.sidebar-collapsed .brand-icon { margin: 0; }
body.sidebar-collapsed .sidebar-user { justify-content: center; padding: 14px 0; }
body.sidebar-collapsed .nav-item-link { justify-content: center; padding: 14px 0; font-size: 0; }
body.sidebar-collapsed .nav-icon { margin: 0; font-size: 18px; }
body.sidebar-collapsed .sidebar-user .user-avatar { width: 40px; height: 40px; font-size: 16px; }

/* RESPONSIVE */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #topbar { left: 0; }
  #main-content { margin-left: 0; }
  .page-content { padding: 14px; }
  .tab-nav { overflow-x: auto; }
  .tab-btn { white-space: nowrap; flex: 0 0 auto; }
}
