/* ============================================================
   HELPDESK SYSTEM — Design System & Styles
   Palette: deep navy + electric blue + clean whites + status colors
   ============================================================ */

:root {
  /* Core palette */
  --navy-950: #0a0f1e;
  --navy-900: #0f172a;
  --navy-800: #1e293b;
  --navy-700: #334155;
  --navy-600: #475569;
  --navy-500: #64748b;
  --navy-400: #94a3b8;
  --navy-300: #cbd5e1;
  --navy-200: #e2e8f0;
  --navy-100: #f1f5f9;
  --navy-50:  #f8fafc;

  --blue-600:  #2563eb;
  --blue-500:  #3b82f6;
  --blue-400:  #60a5fa;
  --blue-100:  #dbeafe;
  --blue-50:   #eff6ff;

  --green-600: #16a34a;
  --green-500: #22c55e;
  --green-100: #dcfce7;

  --amber-600: #d97706;
  --amber-500: #f59e0b;
  --amber-100: #fef3c7;

  --red-600:   #dc2626;
  --red-500:   #ef4444;
  --red-100:   #fee2e2;

  --purple-600:#7c3aed;
  --purple-500:#8b5cf6;
  --purple-100:#ede9fe;

  --cyan-500:  #06b6d4;
  --cyan-100:  #cffafe;

  /* Semantic tokens */
  --bg-base:       var(--navy-50);
  --bg-surface:    #ffffff;
  --bg-sidebar:    var(--navy-900);
  --text-primary:  var(--navy-900);
  --text-secondary:var(--navy-500);
  --text-muted:    var(--navy-400);
  --border:        var(--navy-200);
  --border-focus:  var(--blue-500);

  /* Priority */
  --high-bg:    var(--red-100);
  --high-text:  var(--red-600);
  --medium-bg:  var(--amber-100);
  --medium-text:var(--amber-600);
  --low-bg:     var(--green-100);
  --low-text:   var(--green-600);

  /* Status */
  --open-bg:       var(--blue-100);
  --open-text:     var(--blue-600);
  --progress-bg:   var(--purple-100);
  --progress-text: var(--purple-600);
  --resolved-bg:   var(--green-100);
  --resolved-text: var(--green-600);
  --closed-bg:     var(--navy-200);
  --closed-text:   var(--navy-600);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 12px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.08);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg-base);
       color: var(--text-primary); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--blue-500); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }

/* ── AUTH PAGES ── */
.auth-wrapper {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 480px;
}

.auth-brand {
  background: var(--navy-900);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 4rem;
  position: relative;
  overflow: hidden;
}
.auth-brand::before {
  content: '';
  position: absolute;
  top: -120px; right: -120px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(59,130,246,.18) 0%, transparent 70%);
  border-radius: 50%;
}
.auth-brand::after {
  content: '';
  position: absolute;
  bottom: -80px; left: -80px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(139,92,246,.12) 0%, transparent 70%);
  border-radius: 50%;
}

.brand-logo {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 3rem;
}
.brand-logo-icon {
  width: 44px; height: 44px;
  background: var(--blue-500);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.brand-logo-icon svg { color: #fff; }
.brand-logo-name { font-size: 1.25rem; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.brand-logo-sub  { font-size: .8rem; color: var(--navy-400); letter-spacing: .5px; text-transform: uppercase; }

.brand-headline { font-size: 2.6rem; font-weight: 700; color: #fff; line-height: 1.2; margin-bottom: 1rem; }
.brand-headline span { color: var(--blue-400); }
.brand-desc { font-size: 1rem; color: var(--navy-400); max-width: 400px; margin-bottom: 3rem; }

.brand-features { display: flex; flex-direction: column; gap: .875rem; }
.brand-feature { display: flex; align-items: center; gap: .75rem; color: var(--navy-300); font-size: .9rem; }
.brand-feature svg { color: var(--blue-400); flex-shrink: 0; }

.auth-form-panel {
  background: #fff;
  display: flex; flex-direction: column; justify-content: center;
  padding: 3rem 2.5rem;
  overflow-y: auto;
}

.auth-form-header { margin-bottom: 2rem; }
.auth-form-header h2 { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); margin-bottom: .25rem; }
.auth-form-header p  { color: var(--text-secondary); font-size: .9rem; }

.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--navy-700);
              margin-bottom: .4rem; letter-spacing: .3px; text-transform: uppercase; }
.form-control {
  width: 100%; padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--navy-50);
  color: var(--text-primary);
  transition: border-color .15s, box-shadow .15s;
  font-size: .95rem;
}
.form-control:focus { outline: none; border-color: var(--blue-500);
                      box-shadow: 0 0 0 3px rgba(59,130,246,.12); background: #fff; }
.form-control.error { border-color: var(--red-500); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

select.form-control { appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.2rem; }

.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }
.form-error { font-size: .8rem; color: var(--red-600); margin-top: .3rem; display: none; }
.form-error.visible { display: block; }

.section-label {
  font-size: .7rem; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--navy-400);
  margin: 1.5rem 0 .75rem;
  display: flex; align-items: center; gap: .5rem;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: .9rem;
  border: 1.5px solid transparent;
  cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--blue-500); color: #fff; border-color: var(--blue-500); }
.btn-primary:hover { background: var(--blue-600); border-color: var(--blue-600); }
.btn-secondary { background: #fff; color: var(--navy-700); border-color: var(--border); }
.btn-secondary:hover { background: var(--navy-50); }
.btn-danger { background: var(--red-500); color: #fff; border-color: var(--red-500); }
.btn-danger:hover { background: var(--red-600); }
.btn-ghost { background: transparent; color: var(--navy-600); border-color: transparent; }
.btn-ghost:hover { background: var(--navy-100); }
.btn-sm { padding: .4rem .75rem; font-size: .82rem; }
.btn-lg { padding: .8rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.auth-switch { margin-top: 1.5rem; text-align: center; font-size: .88rem; color: var(--text-secondary); }
.auth-switch a { font-weight: 600; }

/* ── ALERT / TOAST ── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 500;
  display: flex; align-items: flex-start; gap: .6rem;
  margin-bottom: 1rem; display: none;
}
.alert.visible { display: flex; }
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-error   { background: var(--red-100);   color: var(--red-600); }
.alert-success { background: var(--green-100); color: var(--green-600); }
.alert-info    { background: var(--blue-100);  color: var(--blue-600); }

/* ── MAIN LAYOUT ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .2s;
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo { display: flex; align-items: center; gap: .6rem; }
.sidebar-logo-icon {
  width: 36px; height: 36px; background: var(--blue-500);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.sidebar-logo-icon svg { color: #fff; }
.sidebar-logo-text { color: #fff; font-weight: 700; font-size: 1rem; line-height: 1.2; }
.sidebar-logo-sub  { font-size: .7rem; color: var(--navy-500); }

.sidebar-nav { flex: 1; padding: 1rem .75rem; overflow-y: auto; }
.nav-section-label {
  font-size: .65rem; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--navy-600);
  padding: .5rem .5rem .25rem;
  margin-top: .5rem;
}
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .75rem; border-radius: var(--radius-sm);
  color: var(--navy-400); font-size: .88rem; font-weight: 500;
  cursor: pointer; transition: all .12s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--navy-200); }
.nav-item.active { background: var(--blue-500); color: #fff; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red-500); color: #fff;
  font-size: .65rem; font-weight: 700;
  padding: 1px 6px; border-radius: 99px;
  min-width: 18px; text-align: center;
  animation: badgePulse 2s infinite;
}
@keyframes badgePulse {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(239,68,68,.6); }
  50%  { transform: scale(1.1);  box-shadow: 0 0 0 5px rgba(239,68,68,0); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

.sidebar-footer {
  padding: 1rem .75rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
  display: flex; align-items: center; gap: .65rem;
  padding: .5rem .5rem;
}
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue-500);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-name  { font-size: .82rem; font-weight: 600; color: var(--navy-200); }
.sidebar-user-role  { font-size: .72rem; color: var(--navy-500); }
.btn-logout {
  width: 100%; margin-top: .5rem;
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; border-radius: var(--radius-sm);
  background: transparent; border: none;
  color: var(--navy-500); font-size: .82rem; font-weight: 500;
  cursor: pointer; transition: all .12s;
}
.btn-logout:hover { background: rgba(255,255,255,.06); color: var(--red-400); }

.main-content { margin-left: 240px; flex: 1; min-width: 0; }

.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.75rem;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.topbar-actions { display: flex; gap: .5rem; align-items: center; }

.page-body { padding: 1.75rem; }

/* ── CARDS ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 1.25rem 1.5rem .75rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.card-body { padding: 1.25rem 1.5rem; }

/* ── STAT CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 46px; height: 46px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue   { background: var(--blue-100);   color: var(--blue-600);   }
.stat-icon.green  { background: var(--green-100);  color: var(--green-600);  }
.stat-icon.amber  { background: var(--amber-100);  color: var(--amber-600);  }
.stat-icon.red    { background: var(--red-100);    color: var(--red-600);    }
.stat-icon.purple { background: var(--purple-100); color: var(--purple-600); }
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-secondary); margin-top: .2rem; font-weight: 500; }

/* ── DEPARTMENT LABELS GRID ── */
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.dept-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: .9rem;
  box-shadow: var(--shadow-sm);
  transition: transform .12s, box-shadow .12s;
}
.dept-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.dept-color-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.dept-icon {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: .9rem;
}
.dept-icon svg { width: 18px; height: 18px; }
.dept-info { flex: 1; min-width: 0; }
.dept-name  { font-size: .88rem; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dept-type  { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.dept-counts { text-align: right; flex-shrink: 0; }
.dept-total  { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.dept-open   { font-size: .7rem; color: var(--blue-500); font-weight: 600; }

/* ── PRIORITY BADGE ── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 99px;
  font-size: .75rem; font-weight: 700;
}
.badge-high     { background: var(--high-bg);    color: var(--high-text);    }
.badge-medium   { background: var(--medium-bg);  color: var(--medium-text);  }
.badge-low      { background: var(--low-bg);     color: var(--low-text);     }
.badge-open     { background: var(--open-bg);    color: var(--open-text);    }
.badge-progress { background: var(--progress-bg);color: var(--progress-text);}
.badge-resolved { background: var(--resolved-bg);color: var(--resolved-text);}
.badge-closed   { background: var(--closed-bg);  color: var(--closed-text);  }
.badge::before  { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--navy-50); padding: .75rem 1rem;
  text-align: left; font-size: .73rem; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-secondary); white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
td {
  padding: .85rem 1rem; border-bottom: 1px solid var(--border);
  font-size: .88rem; color: var(--text-primary);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; cursor: pointer; }
tbody tr:hover { background: var(--navy-50); }

.ticket-num { font-family: 'JetBrains Mono', monospace; font-size: .8rem; color: var(--blue-500); font-weight: 500; }
.ticket-title { font-weight: 600; }
.ticket-title-sub { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

/* ── SEARCH / FILTER BAR ── */
.filter-bar {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
                   color: var(--text-muted); width: 15px; height: 15px; pointer-events: none; }
.search-input {
  width: 100%; padding: .5rem .75rem .5rem 2.2rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--navy-50); font-size: .88rem;
  transition: all .15s;
}
.search-input:focus { outline: none; border-color: var(--blue-500); background: #fff; box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.filter-select {
  padding: .5rem .9rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--navy-50);
  color: var(--text-primary); font-size: .85rem; cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--blue-500); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10,15,30,.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: #fff; border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(20px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: 1.5rem 1.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: transparent; border: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: pointer;
}
.modal-close:hover { background: var(--navy-100); color: var(--text-primary); }
.modal-body { padding: 1.5rem 1.75rem; }
.modal-footer {
  padding: 1rem 1.75rem 1.5rem;
  display: flex; gap: .75rem; justify-content: flex-end;
}

/* ── TICKET DETAIL ── */
.ticket-detail-grid { display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem; }
.ticket-meta-item { margin-bottom: .75rem; }
.ticket-meta-label { font-size: .72rem; font-weight: 700; text-transform: uppercase;
                     letter-spacing: .5px; color: var(--text-muted); margin-bottom: .2rem; }
.ticket-meta-value { font-size: .9rem; color: var(--text-primary); font-weight: 500; }
.ticket-description-box {
  background: var(--navy-50); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  font-size: .9rem; color: var(--text-primary); line-height: 1.7;
  white-space: pre-wrap;
}

.comments-section { margin-top: 1.5rem; }
.comment { display: flex; gap: .75rem; margin-bottom: 1rem; }
.comment-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #fff;
  flex-shrink: 0; margin-top: 2px;
}
.comment-bubble {
  background: var(--navy-50); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem 1rem;
  flex: 1;
}
.comment-bubble.internal { background: var(--amber-100); border-color: var(--amber-500); }
.comment-meta { font-size: .75rem; color: var(--text-muted); margin-bottom: .25rem; }
.comment-text { font-size: .88rem; color: var(--text-primary); white-space: pre-wrap; }

.comment-input-row { display: flex; gap: .5rem; align-items: flex-end; margin-top: .75rem; }
.comment-input-row textarea { flex: 1; min-height: 60px; resize: none; }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4rem 2rem; text-align: center;
}
.empty-state svg { color: var(--navy-300); margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-secondary); margin-bottom: .4rem; }
.empty-state p  { color: var(--text-muted); font-size: .88rem; max-width: 300px; }

/* ── LOADING SPINNER ── */
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--blue-500); border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 3rem; }

/* ── TOAST NOTIFICATION ── */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 1000; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--navy-900); color: #fff;
  padding: .75rem 1.1rem; border-radius: var(--radius);
  font-size: .88rem; font-weight: 500;
  display: flex; align-items: center; gap: .6rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
  min-width: 250px;
}
.toast.success { background: var(--green-600); }
.toast.error   { background: var(--red-600); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── PROGRESS BARS ── */
.progress-bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: .4rem; }
.progress-fill { height: 100%; border-radius: 99px; transition: width .4s ease; }

/* ── SECTION HEADERS ── */
.section-header { margin-bottom: 1.25rem; display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.section-subtitle { font-size: .82rem; color: var(--text-muted); margin-top: .15rem; }

/* ── PRIORITY PILL SELECTOR ── */
.priority-options { display: flex; gap: .5rem; }
.priority-opt {
  flex: 1; padding: .6rem; border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  text-align: center; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all .12s;
}
.priority-opt[data-val="High"]   { color: var(--high-text); }
.priority-opt[data-val="Medium"] { color: var(--medium-text); }
.priority-opt[data-val="Low"]    { color: var(--low-text); }
.priority-opt.selected[data-val="High"]   { background: var(--high-bg);   border-color: var(--high-text);   }
.priority-opt.selected[data-val="Medium"] { background: var(--medium-bg); border-color: var(--medium-text); }
.priority-opt.selected[data-val="Low"]    { background: var(--low-bg);    border-color: var(--low-text);    }

/* ── CHART BARS ── */
.bar-chart { display: flex; flex-direction: column; gap: .6rem; }
.bar-row { display: flex; align-items: center; gap: .75rem; }
.bar-label { font-size: .8rem; color: var(--text-secondary); width: 140px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 99px; transition: width .5s ease; }
.bar-count { font-size: .78rem; font-weight: 700; color: var(--text-secondary); width: 30px; text-align: right; flex-shrink: 0; }

/* ── RESPONSIVE ── */
/* ============================================================
   MOBILE RESPONSIVE — Complete overhaul for phones
   ============================================================ */

/* ── Tablet & small screens (under 900px) ── */
@media (max-width: 900px) {
  /* Auth pages — hide left brand panel, show form only */
  .auth-wrapper { grid-template-columns: 1fr; }
  .auth-brand   { display: none; }
  .auth-form-panel {
    padding: 2rem 1.5rem;
    min-height: 100vh;
    justify-content: center;
  }

  /* Sidebar — hidden off-screen, toggled by menu button */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }

  /* Stats grids */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .ticket-detail-grid { grid-template-columns: 1fr; }
  .dept-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Mobile phones (under 640px) ── */
@media (max-width: 640px) {

  /* ── LOGIN PAGE ── */
  .auth-form-panel {
    padding: 1.5rem 1.25rem;
  }
  .auth-form-panel .auth-form-header h2 { font-size: 1.3rem; }
  /* Logo on login page */
  .auth-form-panel img[alt="Vidullanka PLC"] {
    height: 52px !important;
    margin-bottom: .25rem;
  }
  .auth-form-panel > div:first-child {
    margin-bottom: 1.25rem !important;
    padding-bottom: 1.25rem !important;
  }

  /* ── LAYOUT ── */
  .layout { display: block; }
  .main-content { margin-left: 0 !important; }

  /* ── TOPBAR ── */
  .topbar {
    height: auto;
    min-height: 56px;
    padding: .6rem 1rem !important;
    flex-wrap: wrap;
    gap: .5rem;
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .topbar-title { font-size: .95rem; font-weight: 700; }
  .topbar-actions { display: flex; gap: .4rem; align-items: center; }

  /* Menu toggle button — shows on mobile */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    background: var(--navy-100);
    border: 1px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
  }

  /* Sidebar overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
  }
  .sidebar-overlay.show { display: block; }

  /* Sidebar — full width slide-in panel */
  .sidebar {
    width: 260px !important;
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0) !important; }

  /* ── PAGE BODY ── */
  .page-body { padding: .75rem !important; }

  /* ── STATS GRID — 2 columns on phone ── */
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: .6rem;
  }
  .stat-card  { padding: .85rem .9rem; gap: .6rem; }
  .stat-value { font-size: 1.5rem; }
  .stat-label { font-size: .72rem; }
  .stat-icon  { width: 36px; height: 36px; }
  .stat-icon svg { width: 18px; height: 18px; }

  /* ── DEPT GRID — 1 column ── */
  .dept-grid { grid-template-columns: 1fr !important; }

  /* ── CARDS ── */
  .card-header { padding: .85rem 1rem .6rem; flex-wrap: wrap; gap: .4rem; }
  .card-title  { font-size: .9rem; }
  .card-body   { padding: .85rem 1rem; }

  /* ── FILTER BAR ── */
  .filter-bar {
    padding: .6rem .75rem;
    gap: .4rem;
    flex-wrap: wrap;
  }
  .search-wrap { min-width: 100% !important; order: -1; }
  .filter-select {
    font-size: .8rem;
    padding: .45rem .6rem;
    flex: 1;
    min-width: 0;
  }

  /* ── TABLE — horizontal scroll with key columns only ── */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 0 !important; width: 100%; }
  th, td { padding: .55rem .65rem !important; font-size: .78rem; white-space: nowrap; }

  /* Hide less important columns on mobile */
  .hide-mobile { display: none !important; }

  /* ── MODAL — bottom sheet style ── */
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
    max-height: 92vh !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  .modal-header { padding: 1rem 1.25rem .75rem; }
  .modal-body   { padding: 1rem 1.25rem; }
  .modal-footer { padding: .75rem 1.25rem 1.5rem; }

  /* ── FORMS ── */
  .form-row { grid-template-columns: 1fr !important; gap: 0; }
  .form-control { font-size: 16px !important; } /* prevents iOS zoom */

  /* ── PRIORITY OPTIONS ── */
  .priority-options { gap: .35rem; }
  .priority-opt { padding: .5rem .35rem; font-size: .78rem; }

  /* ── BUTTONS ── */
  .btn { font-size: .85rem; padding: .6rem 1rem; }
  .btn-sm { font-size: .78rem; padding: .38rem .65rem; }

  /* ── TICKET DETAIL GRID ── */
  .ticket-detail-grid { grid-template-columns: 1fr !important; }

  /* ── SECTION HEADER ── */
  .section-header { flex-wrap: wrap; gap: .5rem; }

  /* ── DEPT MANAGEMENT GRID ── */
  .dept-mgmt-grid { grid-template-columns: 1fr !important; }

  /* ── BACKUP GRID ── */
  .backup-grid { grid-template-columns: 1fr !important; }

  /* ── EMAIL GRID ── */
  .email-grid { grid-template-columns: 1fr !important; }
}

/* ── Very small phones (under 380px) ── */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .topbar-actions .btn span { display: none; }
  .stat-card { padding: .7rem .75rem; }
}

/* ── PWA standalone mode ── */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
  .topbar { padding-top: calc(.6rem + env(safe-area-inset-top)); }
}
