/* ═══════════════════════════════════════════════
   DSWOPS R8 — Peshawar Zoo Design System
   Matching the Diary & Dispatch Management UI
═══════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg:      #0f1924;
  --sidebar-hover:   #1a2840;
  --sidebar-active:  #009688;
  --sidebar-text:    #94a3b8;
  --sidebar-text-act:#ffffff;
  --sidebar-width:   250px;

  --topbar-bg:       #ffffff;
  --topbar-h:        64px;
  --topbar-border:   #e2e8f0;

  --main-bg:         #f0f4f8;
  --card-bg:         #ffffff;
  --card-radius:     12px;
  --card-shadow:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);

  --primary:         #009688;
  --primary-dark:    #00796b;
  --primary-light:   #e0f2f1;
  --accent:          #00897b;

  --text-main:       #1e293b;
  --text-muted:      #64748b;
  --text-light:      #94a3b8;
  --border:          #e2e8f0;
  --border-focus:    #009688;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-main);
  background: var(--main-bg);
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════
   LOGIN SCREEN
══════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1924 0%, #1a2e3b 50%, #0f1924 100%);
}
.login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-logo-wrap { display: flex; justify-content: center; margin-bottom: 12px; }
.login-brand h1 { font-size: 22px; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }
.login-brand p { font-size: 13px; color: var(--text-muted); }
.login-org { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.login-footer { text-align: center; font-size: 11px; color: var(--text-light); margin-top: 24px; }
.login-error { background: #fef2f2; color: #dc2626; border-radius: var(--radius); padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }

/* ══════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════ */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #1e3a4a transparent;
  flex-shrink: 0;
  z-index: 100;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #1e3a4a; border-radius: 4px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo { flex-shrink: 0; }
.sidebar-brand-text { flex: 1; min-width: 0; }
.sidebar-brand-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-brand-sub {
  display: block;
  font-size: 10px;
  color: var(--sidebar-text);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  user-select: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: #ffffff; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-act); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.15);
}
.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--sidebar-active);
  color: #fff;
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 12px; font-weight: 600; color: #ffffff; }
.sidebar-user-role { font-size: 11px; color: var(--sidebar-text); text-transform: capitalize; }

/* ══════════════════════════════════════
   MAIN CONTAINER
══════════════════════════════════════ */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ══════════════════════════════════════
   TOPBAR
══════════════════════════════════════ */
.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}
.topbar-search {
  flex: 1;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  border-radius: 24px;
  padding: 8px 16px;
}
.topbar-search input {
  border: none; background: transparent; outline: none;
  font-size: 13px; color: var(--text-main); width: 100%;
  font-family: var(--font);
}
.topbar-search input::placeholder { color: var(--text-light); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar-icon-btn {
  width: 36px; height: 36px;
  border: none; background: transparent; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background 0.15s;
  position: relative;
}
.topbar-icon-btn:hover { background: #f1f5f9; color: var(--text-main); }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  background: #ef4444; color: #fff;
  font-size: 9px; font-weight: 700;
  border-radius: 50%; width: 15px; height: 15px;
  display: flex; align-items: center; justify-content: center;
}
.topbar-user {
  display: flex; align-items: center; gap: 4px;
  cursor: pointer; padding: 4px 6px;
  border-radius: var(--radius); transition: background 0.15s;
}
.topbar-user:hover { background: #f1f5f9; }
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

.notif-panel {
  position: absolute; top: calc(var(--topbar-h) - 4px); right: 80px;
  width: 320px; background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  border: 1px solid var(--border); z-index: 200; overflow: hidden;
}
.notif-panel-header {
  padding: 14px 16px; font-weight: 600; font-size: 13px;
  border-bottom: 1px solid var(--border); color: var(--text-main);
}
.notif-item { padding: 12px 16px; border-bottom: 1px solid #f8fafc; cursor: pointer; }
.notif-item:hover { background: #f8fafc; }
.notif-title { font-size: 13px; font-weight: 500; color: var(--text-main); }
.notif-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.user-menu {
  position: absolute; top: calc(var(--topbar-h) - 4px); right: 16px;
  width: 200px; background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  border: 1px solid var(--border); z-index: 200; overflow: hidden;
}
.user-menu-header { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.user-menu-name { font-size: 13px; font-weight: 600; color: var(--text-main); }
.user-menu-role { font-size: 11px; color: var(--text-muted); margin-top: 2px; text-transform: capitalize; }
.user-menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 16px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--text-muted);
  font-family: var(--font); transition: background 0.12s;
}
.user-menu-item:hover { background: #f8fafc; }
.user-menu-item.sign-out { color: #ef4444; }
.user-menu-item.sign-out:hover { background: #fef2f2; }

/* ══════════════════════════════════════
   PAGE CONTENT
══════════════════════════════════════ */
.page-content {
  flex: 1; overflow-y: auto;
  padding: 28px; scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.page-content::-webkit-scrollbar { width: 6px; }
.page-content::-webkit-scrollbar-track { background: transparent; }
.page-content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

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

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text-main); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.page-date { font-size: 13px; color: var(--text-muted); align-self: flex-start; padding-top: 4px; }
.page-header-actions { display: flex; gap: 10px; align-items: center; }

/* ══════════════════════════════════════
   CARDS
══════════════════════════════════════ */
.card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 20px;
  border: 1px solid rgba(0,0,0,0.04);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text-main); margin-bottom: 16px; }
.card-section-title { font-size: 14px; font-weight: 600; color: var(--text-main); }
.card-section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.view-all-link {
  font-size: 12px; color: var(--primary); cursor: pointer;
  font-weight: 500; text-decoration: none;
}
.view-all-link:hover { text-decoration: underline; }
.table-card { padding: 0; overflow: hidden; }

/* ══════════════════════════════════════
   STATS GRID
══════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg); border-radius: var(--card-radius);
  box-shadow: var(--card-shadow); padding: 20px;
  border: 1px solid rgba(0,0,0,0.04);
}
.stat-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.stat-trend { font-size: 12px; font-weight: 500; }
.stat-trend.up { color: #10b981; }
.stat-trend.down { color: #ef4444; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-main); line-height: 1; margin-bottom: 6px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ══════════════════════════════════════
   CHARTS
══════════════════════════════════════ */
.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.chart-period-select {
  font-size: 12px; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text-muted); cursor: pointer;
  outline: none; font-family: var(--font);
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ══════════════════════════════════════
   RECENT DIARY LIST
══════════════════════════════════════ */
.recent-diary-list { display: flex; flex-direction: column; }
.diary-entry {
  display: flex; align-items: flex-start; padding: 10px 0;
  border-bottom: 1px solid #f8fafc; gap: 10px; cursor: pointer;
}
.diary-entry:last-child { border-bottom: none; }
.diary-entry:hover { background: #f8fafc; margin: 0 -8px; padding: 10px 8px; border-radius: var(--radius-sm); }
.diary-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.diary-entry-body { flex: 1; min-width: 0; }
.diary-entry-subject { font-size: 13px; font-weight: 500; color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diary-entry-sender { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.diary-entry-no { font-size: 11px; font-weight: 600; color: var(--text-light); white-space: nowrap; }

/* ══════════════════════════════════════
   ACTIVITY LIST
══════════════════════════════════════ */
.activity-list { display: flex; flex-direction: column; gap: 2px; }
.activity-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 8px; border-radius: var(--radius-sm);
}
.activity-item:hover { background: #f8fafc; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; flex-shrink: 0; margin-top: 4px; }
.activity-body { flex: 1; }
.activity-action { font-size: 13px; font-weight: 500; color: var(--text-main); }
.activity-meta { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ══════════════════════════════════════
   TABLES
══════════════════════════════════════ */
.table-filters {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.search-bar-sm {
  display: flex; align-items: center; gap: 8px;
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 24px; padding: 7px 14px; min-width: 240px;
}
.search-bar-sm input {
  border: none; background: transparent; outline: none;
  font-size: 13px; color: var(--text-main); width: 100%; font-family: var(--font);
}
.search-bar-sm input::placeholder { color: var(--text-light); }
.filter-sel {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); background: #fff;
  color: var(--text-muted); font-size: 13px; cursor: pointer;
  outline: none; font-family: var(--font);
}
.filter-sel:focus { border-color: var(--primary); }
.table-info { padding: 8px 16px; font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  background: #f8fafc; padding: 10px 14px; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table tbody td {
  padding: 12px 14px; border-bottom: 1px solid #f8fafc;
  color: var(--text-main); vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f8fafc; }
.empty-row { text-align: center; color: var(--text-muted); padding: 40px 14px !important; }

.cell-primary { color: var(--primary); font-weight: 500; }
.cell-muted { color: var(--text-muted); }
.table-actions { display: flex; align-items: center; gap: 6px; }
.tbl-btn {
  width: 30px; height: 30px; border: none; background: none;
  border-radius: var(--radius-sm); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background 0.12s, color 0.12s;
}
.tbl-btn:hover { background: #f1f5f9; color: var(--text-main); }
.tbl-btn-edit:hover { color: var(--primary); background: var(--primary-light); }
.tbl-btn-del:hover { color: #ef4444; background: #fef2f2; }
.tbl-btn-view:hover { color: #6366f1; background: #ede9fe; }
.tbl-btn-share:hover { color: #0ea5e9; background: #e0f2fe; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-urgent { background: #fee2e2; color: #dc2626; }
.badge-high   { background: #fef3c7; color: #d97706; }
.badge-medium { background: #dbeafe; color: #2563eb; }
.badge-low    { background: #dcfce7; color: #16a34a; }

.status-badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
}
.status-pending    { background: #fef9c3; color: #ca8a04; border: 1px solid #fde047; }
.status-completed  { background: #dcfce7; color: #16a34a; border: 1px solid #86efac; }
.status-failed     { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.status-processing { background: #dbeafe; color: #2563eb; border: 1px solid #93c5fd; }

/* ══════════════════════════════════════
   PAGINATION
══════════════════════════════════════ */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 12px 16px; border-top: 1px solid var(--border);
}
.page-btn {
  min-width: 32px; height: 32px; padding: 0 10px;
  border: 1px solid var(--border); background: #fff;
  border-radius: var(--radius-sm); font-size: 13px;
  cursor: pointer; font-family: var(--font); color: var(--text-muted);
  transition: all 0.12s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ══════════════════════════════════════
   UPLOAD STEPS
══════════════════════════════════════ */
.step-indicator-wrap {
  display: flex; align-items: center;
  background: #fff; border-radius: var(--card-radius);
  padding: 20px 24px; margin-bottom: 20px;
  box-shadow: var(--card-shadow); border: 1px solid rgba(0,0,0,0.04);
}
.step-ind {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-light); font-size: 13px; font-weight: 500;
}
.step-ind.active { color: var(--primary); }
.step-ind.done   { color: #10b981; }
.step-circle {
  width: 28px; height: 28px; border-radius: 50%;
  background: #e2e8f0; color: var(--text-muted);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.step-ind.active .step-circle { background: var(--primary); color: #fff; }
.step-ind.done .step-circle   { background: #10b981; color: #fff; }
.step-line-h { flex: 1; height: 1px; background: var(--border); margin: 0 12px; }

.drop-zone {
  border: 2px dashed #cbd5e1; border-radius: var(--radius-lg);
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #fafcff; margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }
.drop-icon-wrap {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary-light); margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
}
.drop-text { font-size: 14px; font-weight: 500; color: var(--text-main); margin-bottom: 4px; }
.drop-hint { font-size: 12px; color: var(--primary); }
.uploaded-file-info {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: #f0fdf4; border-radius: var(--radius);
  margin-bottom: 12px; font-size: 13px; color: #16a34a;
}
.upload-progress-wrap {
  height: 4px; background: #e2e8f0; border-radius: 4px;
  margin-bottom: 12px; overflow: hidden;
}
.upload-progress-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; width: 0%; }

.toggle-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.toggle-btn {
  padding: 7px 14px; border: 1.5px solid var(--border);
  background: #fff; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  color: var(--text-muted); transition: all 0.12s; font-family: var(--font);
}
.toggle-btn:hover { border-color: var(--primary); color: var(--primary); }
.toggle-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }

.role-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.role-chip {
  padding: 6px 14px; border: 1.5px solid var(--border);
  background: #fff; border-radius: 20px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--text-muted); transition: all 0.12s;
}
.role-chip:hover { border-color: var(--primary); color: var(--primary); }
.role-chip.active { border-color: var(--primary); background: var(--primary); color: #fff; }

.ocr-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.ocr-fields { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.ocr-field-row { display: flex; flex-direction: column; gap: 5px; }
.ocr-field-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.input-clear-wrap { display: flex; align-items: flex-start; gap: 6px; }
.input-clear-wrap input,
.input-clear-wrap textarea {
  flex: 1; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; font-family: var(--font);
  color: var(--text-main); outline: none; transition: border-color 0.12s; background: #fff;
}
.input-clear-wrap input:focus,
.input-clear-wrap textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,150,136,0.08); }
.input-clear-wrap textarea { min-height: 64px; resize: vertical; }
.clear-field-btn {
  width: 30px; height: 36px; border: 1px solid var(--border);
  background: #fff; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 16px; color: var(--text-muted); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: all 0.12s;
}
.clear-field-btn:hover { border-color: #ef4444; color: #ef4444; background: #fef2f2; }
.ocr-confidence {
  font-size: 12px; color: var(--text-muted); padding: 10px 0;
  border-top: 1px solid var(--border); margin-top: 4px;
}
.save-actions { justify-content: flex-end; }
.ocr-queue { min-height: 200px; }

/* ══════════════════════════════════════
   DEPARTMENT FOLDERS
══════════════════════════════════════ */
.folders-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px;
}
.folder-card {
  background: #fff; border-radius: var(--card-radius);
  border: 1px solid var(--border); padding: 20px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: all 0.15s; box-shadow: var(--card-shadow);
}
.folder-card:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(0,150,136,0.1); transform: translateY(-1px); }
.folder-icon-wrap {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.folder-info { flex: 1; min-width: 0; }
.folder-name { font-size: 14px; font-weight: 600; color: var(--text-main); }
.folder-count { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ══════════════════════════════════════
   SETTINGS
══════════════════════════════════════ */
.settings-list { display: flex; flex-direction: column; gap: 10px; }
.settings-card {
  background: #fff; border-radius: var(--card-radius);
  border: 1px solid var(--border); padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
  cursor: pointer; transition: all 0.12s; box-shadow: var(--card-shadow);
}
.settings-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,150,136,0.1); }
.settings-card-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.settings-card-body { flex: 1; }
.settings-card-title { font-size: 14px; font-weight: 600; color: var(--text-main); }
.settings-card-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.settings-panel { margin-top: 8px; }

/* ══════════════════════════════════════
   FORMS
══════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.form-group input,
.form-group textarea,
.form-group select,
.form-select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: var(--font); color: var(--text-main);
  background: #fff; outline: none; transition: border-color 0.12s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,150,136,0.1); }
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-light); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 20px; }
.form-error { color: #dc2626; font-size: 13px; background: #fef2f2; padding: 8px 12px; border-radius: var(--radius); margin-top: 8px; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type="color"] { width: 38px; height: 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; padding: 2px; }
.color-row input[type="text"] { flex: 1; }
.hint { font-size: 11px; color: var(--text-light); font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; font-family: var(--font); transition: all 0.12s;
  white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary-teal { background: #00695c; color: #fff; }
.btn-primary-teal:hover { background: #004d40; }
.btn-outline { background: #fff; color: var(--text-main); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-outline-danger { background: #fff; color: #ef4444; border: 1px solid #fca5a5; }
.btn-outline-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid transparent; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

.icon-toggle-btn {
  width: 34px; height: 34px; border: 1px solid var(--border);
  background: #fff; border-radius: var(--radius-sm); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all 0.12s;
}
.icon-toggle-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.icon-toggle-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* ══════════════════════════════════════
   MODALS
══════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--card-radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%; max-width: 460px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-wide { max-width: 680px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 30px; height: 30px; border: none; background: none;
  cursor: pointer; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background 0.12s;
}
.modal-close:hover { background: #f1f5f9; color: var(--text-main); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}
.record-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-label { font-size: 11px; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 3px; }
.detail-value { font-size: 13px; color: var(--text-main); word-break: break-word; }
.detail-full { grid-column: 1/-1; }

/* ══════════════════════════════════════
   USERS
══════════════════════════════════════ */
.role-badge-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500;
  background: var(--primary-light); color: var(--primary);
  border: 1px solid rgba(0,150,136,0.2);
}

/* ══════════════════════════════════════
   TOAST
══════════════════════════════════════ */
.toast {
  position: fixed; bottom: 28px; right: 28px;
  background: #1e293b; color: #fff;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  z-index: 9999; max-width: 360px;
  animation: slideUp 0.2s ease;
}
.toast-success { background: #10b981; }
.toast-error   { background: #ef4444; }
.toast-info    { background: #3b82f6; }
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.help-btn {
  position: fixed; bottom: 24px; right: 24px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff;
  border: none; cursor: pointer; font-size: 16px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,150,136,0.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; transition: background 0.12s;
}
.help-btn:hover { background: var(--primary-dark); }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; gap: 12px; color: var(--text-muted); text-align: center; font-size: 13px;
}

/* ══════════════════════════════════════
   DARK MODE
══════════════════════════════════════ */
body.dark {
  --main-bg: #0f172a; --card-bg: #1e293b;
  --topbar-bg: #1e293b; --topbar-border: #334155;
  --border: #334155; --text-main: #f1f5f9;
  --text-muted: #94a3b8; --text-light: #64748b;
  --card-shadow: 0 1px 3px rgba(0,0,0,.2);
}
body.dark .data-table thead th { background: #0f172a; }
body.dark .data-table tbody tr:hover td { background: #0f172a; }
body.dark .topbar-search { background: #0f172a; }
body.dark .filter-sel,
body.dark .form-group select,
body.dark .form-group input,
body.dark .form-group textarea,
body.dark .form-select,
body.dark .input-clear-wrap input,
body.dark .input-clear-wrap textarea { background: #0f172a; color: #f1f5f9; border-color: #334155; }
body.dark .btn-outline { background: #1e293b; color: #f1f5f9; border-color: #334155; }
body.dark .modal { background: #1e293b; }
body.dark .settings-card { background: #1e293b; border-color: #334155; }
body.dark .folder-card { background: #1e293b; border-color: #334155; }
body.dark .drop-zone { background: #1e293b; border-color: #334155; }
body.dark .clear-field-btn { background: #1e293b; border-color: #334155; color: #94a3b8; }

/* ══════════════════════════════════════
   ALL RECORDS FILTER PANEL
══════════════════════════════════════ */
.records-filter-panel {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(0,0,0,0.04);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rec-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.rec-search { flex: 1; min-width: 260px; }
.rec-filter-chips {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.rec-filter-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.rec-filter-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-left: 2px;
}
.rec-filter-group .filter-sel { min-width: 130px; }
.rec-filter-group input[type="date"].filter-sel { min-width: 140px; }

/* Direction badges */
.dir-badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
}
.dir-incoming { background: #e0f2f1; color: #00695c; border: 1px solid #b2dfdb; }
.dir-outgoing { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* Active filter tags */
.rec-active-tags {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 4px;
}
.rec-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--primary-light); color: var(--primary);
  border: 1px solid rgba(0,150,136,0.25);
  border-radius: 20px; padding: 2px 8px 2px 10px;
  font-size: 11px; font-weight: 600; cursor: pointer;
}
.rec-tag:hover { background: #b2dfdb; }

@media (max-width: 900px) {
  .charts-row { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .page-content { padding: 16px; }
  .sidebar { display: none; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════
   D&D — COMPOSE / RICH TEXT EDITOR
══════════════════════════════════════ */
.compose-layout { max-width: 900px; }
.compose-main { padding: 24px; }

.to-picker { display: flex; gap: 8px; align-items: center; }
.to-picker .form-select { flex: 1; }
.check-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-top: 6px; cursor: pointer; }

.rte-toolbar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #f8fafc; padding: 6px 8px;
}
.rte-toolbar button {
  min-width: 30px; height: 28px; padding: 0 8px;
  border: 1px solid transparent; background: none; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; color: var(--text-main); font-family: var(--font);
}
.rte-toolbar button:hover { background: #e2e8f0; }
.rte-toolbar select {
  height: 28px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px; background: #fff; color: var(--text-muted); font-family: var(--font); outline: none;
}
.rte-sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }

.rte-editor {
  min-height: 220px; max-height: 480px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  padding: 14px 16px; font-size: 14px; line-height: 1.7; background: #fff;
  outline: none; color: var(--text-main);
}
.rte-editor:focus { border-color: var(--primary); }
.rte-editor table, .rte-table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.rte-editor td, .rte-editor th { border: 1px solid #64748b; padding: 6px 10px; min-width: 40px; }

.cc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-light); color: var(--primary-dark);
  border: 1px solid rgba(0,150,136,0.25); border-radius: 20px;
  padding: 4px 10px; font-size: 12px; font-weight: 500;
}
.cc-chip b { cursor: pointer; font-weight: 700; opacity: 0.7; }
.cc-chip b:hover { opacity: 1; color: #ef4444; }
.manual-cc-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.manual-cc-row input {
  flex: 1; min-width: 140px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: var(--font); outline: none;
}

.sig-preview {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 14px 16px; background: #fafcff;
}
.sig-line { width: 180px; border-bottom: 1.5px solid #334155; height: 34px; margin-bottom: 6px; }
.sig-name { font-weight: 700; font-size: 13px; }
.sig-desig { font-size: 12px; color: var(--text-muted); }

/* box tabs (Inbox / Sent / Drafts) */
.box-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.box-tab {
  padding: 8px 18px; border: 1.5px solid var(--border); background: var(--card-bg);
  border-radius: 20px; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--text-muted); font-family: var(--font); transition: all 0.12s;
}
.box-tab:hover { border-color: var(--primary); color: var(--primary); }
.box-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.nav-count {
  margin-left: auto; background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 10px; padding: 1px 7px;
}
.notif-unread { background: var(--primary-light); }
.notif-panel-header { display: flex; align-items: center; justify-content: space-between; }

/* ══════════════════════════════════════
   D&D — DOCUMENT SHEET (official template)
══════════════════════════════════════ */
.doc-modal { max-width: 820px; }
.doc-modal-body { background: #e8edf2; padding: 24px; }
.doc-sheet {
  background: #fff; color: #111; font-family: 'Times New Roman', Georgia, serif;
  padding: 48px 56px; box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  font-size: 14px; line-height: 1.65; max-width: 720px; margin: 0 auto;
}
.sheet-letterhead { text-align: center; border-bottom: 2.5px solid #111; padding-bottom: 10px; margin-bottom: 14px; }
.sheet-lh-main { font-weight: 700; font-size: 17px; letter-spacing: 0.5px; text-transform: uppercase; }
.sheet-lh-sub { font-size: 12px; margin-top: 2px; }
.sheet-no-date { display: flex; justify-content: space-between; margin-bottom: 16px; font-size: 14px; }
.sheet-to { margin-bottom: 14px; font-weight: 600; }
.sheet-to-body { font-weight: 400; margin-left: 32px; white-space: pre-line; }
.sheet-subject { font-weight: 700; margin-bottom: 10px; }
.sheet-ref { margin-bottom: 10px; font-size: 13px; }
.sheet-body { text-align: justify; margin-bottom: 28px; min-height: 60px; }
.sheet-body table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.sheet-body td, .sheet-body th { border: 1px solid #111; padding: 5px 9px; }
.sheet-sig { text-align: right; margin: 22px 0 8px; page-break-inside: avoid; }
.sheet-sig-img { height: 48px; display: inline-block; }
.sheet-sig-line { width: 190px; border-bottom: 1.5px solid #111; height: 40px; margin-left: auto; }
.sheet-sig-name { font-weight: 700; margin-top: 4px; }
.sheet-sig-desig { font-size: 13px; }
.sheet-ccno { margin-top: 18px; border-top: 1px solid #cbd5e1; padding-top: 14px; }
.sheet-cc { margin-top: 6px; }
.sheet-cc-title { text-decoration: underline; margin-bottom: 4px; }
.sheet-cc ol { margin-left: 24px; }

.thread-title { font-weight: 600; font-size: 13px; margin: 18px 0 8px; color: var(--text-main); }
.thread-item {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 6px; cursor: pointer; font-size: 13px;
}
.thread-item:hover { border-color: var(--primary); }

.spinner {
  width: 34px; height: 34px; border: 3px solid var(--primary-light);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

body.dark .rte-toolbar { background: #0f172a; }
body.dark .rte-toolbar button { color: #f1f5f9; }
body.dark .rte-toolbar button:hover { background: #334155; }
body.dark .rte-editor { background: #0f172a; color: #f1f5f9; }
body.dark .sig-preview { background: #0f172a; }
body.dark .manual-cc-row input { background: #0f172a; color: #f1f5f9; border-color: #334155; }
body.dark .box-tab { background: #1e293b; }
body.dark .doc-modal-body { background: #0f172a; }

/* ══════════════════════════════════════
   D&D — LETTERHEAD BOX (per office samples)
══════════════════════════════════════ */
.sheet-lh-box { border: 2px solid #111; margin-bottom: 18px; }
.sheet-lh-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px 8px; }
.sheet-lh-titles { flex: 1; text-align: center; }
.sheet-lh-logo { width: 58px; height: 58px; object-fit: contain; flex-shrink: 0; }
.sheet-lh-main { font-weight: 700; font-size: 15.5px; letter-spacing: 0.4px; text-transform: uppercase; line-height: 1.3; }
.sheet-lh-sub { font-size: 12px; margin-top: 1px; }
.sheet-lh-strip {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 2px solid #111; padding: 6px 14px; font-size: 14px;
}
.sheet-lh-noval { display: inline-block; min-width: 90px; border-bottom: 1px solid #111; padding: 0 6px; font-weight: 600; }
.sheet-oo-heading {
  text-align: center; font-weight: 700; font-size: 15px;
  text-transform: uppercase; line-height: 1.7; margin-bottom: 16px;
}
.sheet-subject-label { font-weight: 700; }
.sheet-to { font-weight: 400; }
.sheet-to-body { margin-left: 40px; font-weight: 600; }

/* notification pop-up (with sound) */
.notif-popup {
  position: fixed; top: 76px; right: 24px;
  display: flex; gap: 10px; align-items: flex-start;
  background: #fff; border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg); padding: 14px 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  z-index: 9999; max-width: 340px; cursor: pointer;
  animation: popIn 0.25s ease;
}
.notif-popup:hover { background: #f8fafc; }
.notif-popup-icon { font-size: 20px; }
@keyframes popIn {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
body.dark .notif-popup { background: #1e293b; }
body.dark .notif-popup:hover { background: #0f172a; }

/* ══════════════════════════════════════
   PRINT — only the document sheet
══════════════════════════════════════ */
#printArea { display: none; }
@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea {
    display: block; position: absolute; inset: 0; width: 100%;
  }
  #printArea .doc-sheet {
    box-shadow: none; max-width: 100%; padding: 24px 32px; margin: 0;
  }
}
