/* ============================================================
   Datatech Legal CRM - Main Stylesheet
   Fonts: Syne (headings) + DM Sans (body)
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  /* Brand */
  --brand-primary:   #1e3a5f;
  --brand-secondary: #2d6a4f;
  --brand-accent:    #e9c46a;
  --brand-danger:    #e63946;

  /* Light theme */
  --bg-page:         #f0f4f8;
  --bg-card:         #ffffff;
  --bg-sidebar:      #1e3a5f;
  --bg-topbar:       #ffffff;
  --bg-input:        #f8fafc;
  --bg-hover:        #f0f4f8;
  --bg-code:         #f1f5f9;

  --text-primary:    #1a2332;
  --text-secondary:  #64748b;
  --text-muted:      #94a3b8;
  --text-inverse:    #ffffff;

  --border-color:    #e2e8f0;
  --border-radius:   12px;
  --border-radius-sm:8px;
  --border-radius-lg:20px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:   0 10px 40px rgba(0,0,0,.14);
  --shadow-card: 0 2px 12px rgba(30,58,95,.08);

  --sidebar-width: 260px;
  --topbar-height: 64px;
  --mobile-nav-h:  64px;
  --transition:    .2s ease;

  /* Status colors */
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-danger:  #ef4444;
  --color-info:    #3b82f6;
  --color-purple:  #8b5cf6;
  --color-orange:  #f97316;
  --color-teal:    #14b8a6;
}

[data-theme="dark"] {
  --bg-page:       #0f172a;
  --bg-card:       #1e293b;
  --bg-sidebar:    #0f172a;
  --bg-topbar:     #1e293b;
  --bg-input:      #2d3748;
  --bg-hover:      #2d3748;
  --bg-code:       #2d3748;

  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;

  --border-color:  #334155;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.3);
  --shadow-md:     0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:     0 10px 40px rgba(0,0,0,.5);
  --shadow-card:   0 2px 12px rgba(0,0,0,.3);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: .9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--brand-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-secondary); }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: var(--font-body); }
input, select, textarea { font-family: var(--font-body); }
h1,h2,h3,h4,h5,h6 { font-family: var(--font-head); font-weight: 700; line-height: 1.3; color: var(--text-primary); }

/* ── Layout: App Shell ─────────────────────────────────────── */
.app-body { overflow-x: hidden; }

.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition), width var(--transition);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--brand-accent), #f4a261);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-primary);
  font-size: 18px;
  flex-shrink: 0;
}
.brand-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; }
.brand-name { display: block; font-family: var(--font-head); font-size: 1rem; font-weight: 800; color: #fff; }
.brand-sub  { display: block; font-size: .7rem; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .08em; }

.sidebar-close-btn { display: none; color: rgba(255,255,255,.6); font-size: 18px; padding: 4px; }

.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.user-avatar-wrap { position: relative; flex-shrink: 0; }
.user-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.user-avatar-initials {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-accent), #f4a261);
  color: var(--brand-primary);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-size: .85rem; font-weight: 700;
}
.status-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--bg-sidebar);
}
.status-dot.online { background: var(--color-success); }
.user-name { display: block; font-size: .875rem; font-weight: 600; color: #fff; }
.user-role { display: block; font-size: .72rem; color: rgba(255,255,255,.5); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section { margin-bottom: 4px; }
.nav-section-label {
  display: block;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 10px 20px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,.65);
  font-size: .875rem;
  font-weight: 500;
  position: relative;
  transition: all var(--transition);
  border-radius: 0;
}
.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}
.nav-item.active {
  color: var(--brand-accent);
  background: rgba(233,196,106,.1);
  border-right: 3px solid var(--brand-accent);
}
.nav-item i { width: 18px; text-align: center; font-size: .95rem; }
.nav-badge {
  margin-left: auto;
  background: var(--brand-danger);
  color: #fff;
  font-size: .65rem;
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; gap: 16px;
  flex-shrink: 0;
}
.sidebar-footer-link { font-size: .8rem; color: rgba(255,255,255,.5); transition: color var(--transition); }
.sidebar-footer-link:hover { color: #fff; }
.sidebar-footer-link.text-danger:hover { color: #ff6b6b; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
  backdrop-filter: blur(2px);
}

/* ── Top Bar ───────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0;
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  z-index: 500;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  font-size: .95rem;
  transition: all var(--transition);
}
.topbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.topbar-user-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 10px;
  transition: background var(--transition);
}
.topbar-user-btn:hover { background: var(--bg-hover); }
.topbar-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.topbar-initials {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; font-family: var(--font-head);
}
.topbar-username { font-size: .875rem; font-weight: 600; color: var(--text-primary); }
.topbar-chevron { font-size: .7rem; color: var(--text-muted); }

/* Breadcrumb */
.breadcrumb-nav { display: flex; align-items: center; gap: 6px; font-size: .82rem; }
.breadcrumb-item { color: var(--text-secondary); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 600; }
.breadcrumb-sep { color: var(--text-muted); }

/* ── Notifications ─────────────────────────────────────────── */
.notif-wrap, .user-menu-wrap { position: relative; }
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: 4px; right: 4px;
  width: 17px; height: 17px;
  background: var(--color-danger);
  color: #fff;
  border-radius: 50%;
  font-size: .62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-topbar);
}
.notif-panel, .user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  min-width: 320px;
  overflow: hidden;
  animation: dropIn .15s ease;
}
@keyframes dropIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.notif-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
}
.notif-header h4 { font-size: .9rem; font-weight: 700; }
.mark-all-read { font-size: .78rem; color: var(--brand-primary); font-weight: 600; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
  color: var(--text-primary);
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: rgba(59,130,246,.04); }
.notif-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .8rem; flex-shrink: 0;
}
.notif-content strong { display: block; font-size: .82rem; font-weight: 600; }
.notif-content p { font-size: .78rem; color: var(--text-secondary); margin: 2px 0; }
.notif-content span { font-size: .72rem; color: var(--text-muted); }
.notif-empty { padding: 30px; text-align: center; color: var(--text-muted); }
.notif-empty i { font-size: 2rem; margin-bottom: 8px; }
.notif-footer {
  display: block; text-align: center;
  padding: 10px;
  font-size: .82rem; font-weight: 600;
  color: var(--brand-primary);
  border-top: 1px solid var(--border-color);
}

/* User Dropdown */
.user-dropdown { min-width: 220px; }
.user-dropdown-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}
.user-dropdown-header strong { display: block; font-size: .875rem; font-weight: 700; }
.user-dropdown-header span { font-size: .78rem; color: var(--text-muted); }
.user-dropdown a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  font-size: .875rem;
  color: var(--text-primary);
  transition: background var(--transition);
}
.user-dropdown a:hover { background: var(--bg-hover); }
.user-dropdown a i { width: 16px; color: var(--text-secondary); }
.user-dropdown hr { border: none; border-top: 1px solid var(--border-color); margin: 4px 0; }
.user-dropdown a.text-danger { color: var(--color-danger); }

/* Global Search */
.global-search-wrap { position: relative; }
.global-search-box {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  overflow: hidden;
  animation: dropIn .15s ease;
}
.global-search-box input {
  width: 100%; padding: 14px 16px;
  border: none; border-bottom: 1px solid var(--border-color);
  background: transparent;
  font-size: .9rem;
  color: var(--text-primary);
  outline: none;
}
.search-results { max-height: 300px; overflow-y: auto; }
.search-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
  color: var(--text-primary);
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-item .result-icon { color: var(--text-muted); width: 16px; }
.search-result-item .result-label { font-size: .85rem; font-weight: 500; }
.search-result-item .result-sub { font-size: .75rem; color: var(--text-muted); }

/* ── Flash Messages ─────────────────────────────────────────── */
.flash-container { padding: 12px 24px 0; display: flex; flex-direction: column; gap: 8px; }
.flash-msg {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  font-size: .875rem;
  animation: slideDown .3s ease;
  position: relative;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.flash-success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.flash-error   { background: #fee2e2; color: #7f1d1d; border-left: 4px solid #ef4444; }
.flash-warning { background: #fef3c7; color: #78350f; border-left: 4px solid #f59e0b; }
.flash-info    { background: #dbeafe; color: #1e3a8a; border-left: 4px solid #3b82f6; }
[data-theme="dark"] .flash-success { background: rgba(16,185,129,.15); color: #a7f3d0; }
[data-theme="dark"] .flash-error   { background: rgba(239,68,68,.15); color: #fca5a5; }
[data-theme="dark"] .flash-warning { background: rgba(245,158,11,.15); color: #fde68a; }
[data-theme="dark"] .flash-info    { background: rgba(59,130,246,.15); color: #bfdbfe; }
.flash-msg i { font-size: 1rem; flex-shrink: 0; }
.flash-close { margin-left: auto; opacity: .7; padding: 0 4px; color: inherit; }

/* ── Main Content ───────────────────────────────────────────── */
.main-content { flex: 1; padding: 24px; padding-bottom: 32px; }

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-header-left h1 {
  font-size: 1.5rem; font-weight: 800;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-header-left p { font-size: .85rem; color: var(--text-secondary); margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: .95rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--brand-primary); }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  background: var(--bg-hover);
  border-top: 1px solid var(--border-color);
}

/* ── Stat Cards ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: default;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--accent-color, var(--brand-primary));
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-info { flex: 1; }
.stat-value { font-family: var(--font-head); font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-secondary); margin-top: 4px; }
.stat-change { font-size: .75rem; font-weight: 600; margin-top: 4px; }
.stat-change.up { color: var(--color-success); }
.stat-change.down { color: var(--color-danger); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--border-radius); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table thead { background: var(--bg-hover); }
.data-table thead th {
  padding: 12px 16px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--border-color);
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody td { padding: 12px 16px; vertical-align: middle; }
.data-table tbody tr:last-child { border-bottom: none; }
.table-actions { display: flex; gap: 6px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--border-radius-sm);
  font-size: .875rem; font-weight: 600;
  font-family: var(--font-body);
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer; border: none;
  text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary   { background: var(--brand-primary); color: #fff; }
.btn-primary:hover   { background: #162d4a; box-shadow: 0 4px 12px rgba(30,58,95,.3); color: #fff; }
.btn-secondary { background: var(--brand-secondary); color: #fff; }
.btn-secondary:hover { background: #235c3d; color: #fff; }
.btn-success   { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #16a34a; color: #fff; }
.btn-danger    { background: var(--color-danger); color: #fff; }
.btn-danger:hover  { background: #dc2626; color: #fff; }
.btn-warning   { background: var(--color-warning); color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-info      { background: var(--color-info); color: #fff; }
.btn-info:hover    { background: #2563eb; color: #fff; }
.btn-light {
  background: var(--bg-hover); color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-light:hover { background: var(--border-color); color: var(--text-primary); }
.btn-outline-primary {
  background: transparent; color: var(--brand-primary);
  border: 2px solid var(--brand-primary);
}
.btn-outline-primary:hover { background: var(--brand-primary); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--border-radius-sm); }
.btn-block { width: 100%; }
.btn-loading { position: relative; color: transparent; }
.btn-loading::after {
  content: '';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.form-label .required { color: var(--color-danger); margin-left: 3px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: .9rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(30,58,95,.12); }
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { opacity: .7; cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: .78rem; color: var(--color-danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Input with icon */
.input-group { position: relative; }
.input-group .input-icon {
  position: absolute; top: 50%; left: 14px;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: .9rem; pointer-events: none;
}
.input-group .form-control { padding-left: 40px; }
.input-group .input-icon-right { position: absolute; top: 50%; right: 14px; transform: translateY(-50%); color: var(--text-muted); cursor: pointer; }

/* Checkbox / Radio */
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check-input { width: 17px; height: 17px; accent-color: var(--brand-primary); cursor: pointer; }
.form-check-label { font-size: .875rem; cursor: pointer; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .72rem; font-weight: 700;
  white-space: nowrap; text-transform: capitalize;
}
.badge-success  { background: rgba(34,197,94,.15);  color: #15803d; }
.badge-danger   { background: rgba(239,68,68,.15);  color: #b91c1c; }
.badge-warning  { background: rgba(245,158,11,.15); color: #92400e; }
.badge-info     { background: rgba(59,130,246,.15); color: #1d4ed8; }
.badge-primary  { background: rgba(30,58,95,.15);   color: var(--brand-primary); }
.badge-secondary{ background: var(--bg-hover);      color: var(--text-secondary); border: 1px solid var(--border-color); }
.badge-purple   { background: rgba(139,92,246,.15); color: #6d28d9; }
.badge-orange   { background: rgba(249,115,22,.15); color: #c2410c; }
.badge-dark     { background: rgba(0,0,0,.7);       color: #fff; }
.badge-teal     { background: rgba(20,184,166,.15); color: #0f766e; }
[data-theme="dark"] .badge-success  { background: rgba(34,197,94,.2); color: #86efac; }
[data-theme="dark"] .badge-danger   { background: rgba(239,68,68,.2); color: #fca5a5; }
[data-theme="dark"] .badge-warning  { background: rgba(245,158,11,.2); color: #fde68a; }
[data-theme="dark"] .badge-info     { background: rgba(59,130,246,.2); color: #93c5fd; }
[data-theme="dark"] .badge-primary  { background: rgba(30,58,95,.4); color: #93c5fd; }
[data-theme="dark"] .badge-secondary{ background: var(--bg-hover); color: var(--text-secondary); }

/* ── Color Utilities ────────────────────────────────────────── */
.bg-blue    { background: var(--color-info) !important; }
.bg-green   { background: var(--color-success) !important; }
.bg-red     { background: var(--color-danger) !important; }
.bg-yellow  { background: var(--color-warning) !important; }
.bg-purple  { background: var(--color-purple) !important; }
.bg-orange  { background: var(--color-orange) !important; }
.bg-teal    { background: var(--color-teal) !important; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 7px 12px;
  border-radius: var(--border-radius-sm);
  font-size: .82rem; font-weight: 600;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: all var(--transition);
  min-width: 36px; text-align: center;
}
.pagination a:hover { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.pagination .active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.pagination .disabled { opacity: .4; cursor: not-allowed; }

/* ── Auth Pages ─────────────────────────────────────────────── */
.auth-body { min-height: 100vh; overflow: hidden; }
.auth-wrapper { display: flex; min-height: 100vh; }
.auth-panel-left {
  flex: 0 0 480px;
  background: linear-gradient(160deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
  padding: 48px 40px;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
.auth-panel-left::before {
  content: '';
  position: absolute; top: -100px; right: -100px;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.auth-panel-left::after {
  content: '';
  position: absolute; bottom: -80px; left: -60px;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 48px; position: relative; z-index: 1; }
.auth-brand-icon {
  width: 52px; height: 52px;
  background: rgba(255,255,255,.15);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-accent); font-size: 22px;
  backdrop-filter: blur(8px);
}
.auth-brand-name { font-family: var(--font-head); font-size: 1.3rem; font-weight: 800; color: #fff; }
.auth-brand-sub  { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: rgba(255,255,255,.5); }
.auth-promo { flex: 1; position: relative; z-index: 1; }
.auth-promo h2 { font-size: 2rem; color: #fff; line-height: 1.25; margin-bottom: 16px; }
.auth-promo h2 .highlight { color: var(--brand-accent); }
.auth-promo p { color: rgba(255,255,255,.7); font-size: .9rem; line-height: 1.7; margin-bottom: 28px; }
.auth-features { display: flex; flex-direction: column; gap: 10px; }
.auth-feature { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.85); font-size: .875rem; }
.auth-feature i { color: var(--brand-accent); }
.auth-stats {
  display: flex; gap: 20px;
  padding-top: 32px; border-top: 1px solid rgba(255,255,255,.15);
  position: relative; z-index: 1;
}
.auth-stat { text-align: center; }
.stat-num { display: block; font-family: var(--font-head); font-size: 1.5rem; font-weight: 800; color: #fff; }
.stat-lbl { font-size: .75rem; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .08em; }

.auth-panel-right {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 32px;
  background: var(--bg-page);
  overflow-y: auto;
}
.auth-form-container { width: 100%; max-width: 440px; }
.auth-form-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 6px; }
.auth-form-subtitle { color: var(--text-secondary); font-size: .9rem; margin-bottom: 28px; }
.auth-footer-text { font-size: .78rem; color: var(--text-muted); margin-top: 24px; text-align: center; }

/* OTP Input */
.otp-inputs { display: flex; gap: 10px; justify-content: center; margin: 20px 0; }
.otp-input {
  width: 52px; height: 60px;
  text-align: center; font-size: 1.5rem; font-weight: 700;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}
.otp-input:focus { border-color: var(--brand-primary); }

/* ── Dashboard ──────────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }
.col-8  { grid-column: span 8; }
.col-4  { grid-column: span 4; }
.col-6  { grid-column: span 6; }
.col-12 { grid-column: span 12; }

.chart-container { position: relative; height: 260px; }

/* Quick Stats Row */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}
.quick-stat { text-align: center; padding: 8px; }
.quick-stat-val { font-family: var(--font-head); font-size: 1.4rem; font-weight: 800; color: var(--brand-primary); }
.quick-stat-lbl { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }

/* Timeline */
.timeline { list-style: none; position: relative; padding-left: 0; }
.timeline::before {
  content: '';
  position: absolute; left: 17px; top: 0; bottom: 0;
  width: 2px; background: var(--border-color);
}
.timeline-item { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.timeline-dot {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; color: #fff;
  z-index: 1;
}
.timeline-content { flex: 1; }
.timeline-content strong { display: block; font-size: .85rem; font-weight: 600; }
.timeline-content p { font-size: .8rem; color: var(--text-secondary); margin: 2px 0; }
.timeline-content time { font-size: .75rem; color: var(--text-muted); }

/* ── Mobile Bottom Nav ──────────────────────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--mobile-nav-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  z-index: 800;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}
.mobile-nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  font-size: .68rem; font-weight: 600;
  color: var(--text-muted);
  transition: color var(--transition);
  position: relative;
  text-decoration: none;
}
.mobile-nav-item i { font-size: 1.1rem; }
.mobile-nav-item.active { color: var(--brand-primary); }
.mobile-nav-item.active i { color: var(--brand-primary); }
.mobile-nav-badge {
  position: absolute; top: 6px; right: calc(50% - 14px);
  width: 16px; height: 16px;
  background: var(--color-danger); color: #fff;
  border-radius: 50%; font-size: .6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-card);
}

/* ── PWA Banner ─────────────────────────────────────────────── */
.pwa-banner {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  z-index: 900;
  width: calc(100% - 32px);
  max-width: 400px;
  animation: slideUp .3s ease;
}
@keyframes slideUp { from { opacity:0; transform: translateX(-50%) translateY(20px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }
.pwa-banner-content { display: flex; align-items: center; gap: 12px; }
.pwa-icon { width: 44px; height: 44px; border-radius: 10px; }
.pwa-text { flex: 1; }
.pwa-text strong { display: block; font-size: .875rem; font-weight: 700; }
.pwa-text span { font-size: .78rem; color: var(--text-secondary); }
.btn-install {
  background: var(--brand-primary); color: #fff;
  padding: 7px 14px; border-radius: var(--border-radius-sm);
  font-size: .8rem; font-weight: 700;
  white-space: nowrap;
}
.btn-dismiss { color: var(--text-muted); padding: 4px; font-size: .85rem; }

/* ── Page Loader ─────────────────────────────────────────────── */
.page-loader {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}
.loader-ring {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,.3);
  border-top-color: var(--brand-accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn .2s ease;
}
@keyframes scaleIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
.modal-sm { max-width: 360px; }
.modal-lg { max-width: 720px; }
.modal-header {
  padding: 20px 24px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close { color: var(--text-muted); padding: 4px; font-size: 1.1rem; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 0 24px 20px;
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border-color); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 18px;
  font-size: .875rem; font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  background: none; border-radius: 0;
}
.tab-btn:hover { color: var(--brand-primary); }
.tab-btn.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Search / Filter Bar ────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px; align-items: center;
}
.filter-bar .form-control { max-width: 200px; }
.search-input-wrap { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-input-wrap .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input-wrap input { padding-left: 36px; }

/* ── Dropdown Actions ───────────────────────────────────────── */
.action-dropdown { position: relative; display: inline-block; }
.action-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 200; min-width: 160px;
  overflow: hidden;
  animation: dropIn .15s ease;
}
.action-menu a, .action-menu button {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  font-size: .82rem;
  color: var(--text-primary);
  width: 100%;
  text-align: left;
  transition: background var(--transition);
  font-family: var(--font-body);
}
.action-menu a:hover, .action-menu button:hover { background: var(--bg-hover); }
.action-menu a.danger, .action-menu button.danger { color: var(--color-danger); }
.action-menu i { width: 16px; color: var(--text-muted); font-size: .85rem; }

/* ── Utilities ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--color-danger); }
.text-success{ color: var(--color-success); }
.text-warning{ color: var(--color-warning); }
.text-primary-color { color: var(--brand-primary); }
.fw-bold { font-weight: 700; }
.fw-600  { font-weight: 600; }
.fs-sm   { font-size: .82rem; }
.fs-xs   { font-size: .75rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 24px; }
.p-0 { padding: 0 !important; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.w-100 { width: 100%; }
.rounded-circle { border-radius: 50%; }

/* Empty State */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 12px; opacity: .4; }
.empty-state h4 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: .85rem; }

/* ── Client Portal Specific ─────────────────────────────────── */
.portal-header {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  padding: 32px 24px;
  border-radius: var(--border-radius-lg);
  margin-bottom: 24px;
  color: #fff;
  position: relative; overflow: hidden;
}
.portal-header::before {
  content: '';
  position: absolute; top: -40px; right: -40px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.portal-welcome h2 { font-size: 1.5rem; color: #fff; margin-bottom: 4px; }
.portal-welcome p  { color: rgba(255,255,255,.7); font-size: .9rem; }

/* Renewal card */
.renewal-card {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.renewal-card .countdown {
  font-family: var(--font-head);
  font-size: 2rem; font-weight: 800;
}
.renewal-card .countdown.urgent { color: var(--color-danger); }
.renewal-card .countdown.warning { color: var(--color-warning); }
.renewal-card .countdown.ok { color: var(--color-success); }
.renewal-progress {
  height: 6px; background: var(--bg-hover);
  border-radius: 3px; overflow: hidden; margin: 8px 0;
}
.renewal-progress-bar { height: 100%; border-radius: 3px; transition: width .5s ease; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .col-8, .col-4 { grid-column: span 12; }
}

@media (max-width: 992px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-close-btn { display: flex; }
  .sidebar-overlay.visible { display: block; }
  .main-wrapper { margin-left: 0; }
  .mobile-bottom-nav { display: flex; }
  .main-content { padding-bottom: calc(var(--mobile-nav-h) + 16px); }
  .auth-panel-left { display: none; }
  .auth-panel-right { padding: 32px 20px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .dashboard-grid { display: flex; flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 576px) {
  .main-content { padding: 16px; padding-bottom: calc(var(--mobile-nav-h) + 12px); }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.3rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control { max-width: 100%; }
  .search-input-wrap { max-width: 100%; }
  .data-table { font-size: .8rem; }
  .data-table thead th, .data-table tbody td { padding: 10px 12px; }
  .d-none-mobile { display: none !important; }
  .topbar { padding: 0 16px; }
  .global-search-box { width: calc(100vw - 32px); right: -80px; }
}

/* ── Print Styles ────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .mobile-bottom-nav, .pwa-banner,
  .flash-container, .page-header-actions, .filter-bar { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .main-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
