/* ================================================
   DEXTRACK CRM – Design System
   ================================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-base: #0b0f1a;
  --bg-surface: #173c641f;
  --bg-card: #173c641f;
  --bg-card-hover: #1e2a40;
  --bg-input: #0f172a;
  --border: rgba(99, 102, 241, 0.15);
  --border-subtle: rgba(255, 255, 255, 0.06);

  --primary: #173c64;
  --secondary: #00ffba;
  --accent: var(--secondary);
  --accent-light: var(--secondary);
  --accent-glow: rgba(0, 255, 186, 0.3);
  --purple: #8b5cf6;
  --teal: #14b8a6;
  --green: #22c55e;
  --yellow: #eab308;
  --orange: #f97316;
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.15);
  --orange-soft: rgba(249, 115, 22, 0.15);
  --green-soft: rgba(34, 197, 94, 0.12);

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

  --sidebar-w: 400px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;

  --font-family: 'Inter', system-ui, sans-serif;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-family);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
}

/* --- Utility --- */
.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.mt-1 {
  margin-top: 4px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.text-sm {
  font-size: 0.85rem;
}

.text-xs {
  font-size: 0.75rem;
}

.text-muted {
  color: var(--text-muted);
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.w-full {
  width: 100%;
}


/* ================================================
   LOGIN PAGE
   ================================================ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg-base);
}

.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(139, 92, 246, 0.12) 0%, transparent 50%);
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  pointer-events: none;
  animation: orbFloat 8s ease-in-out infinite alternate;
}

.orb1 {
  width: 400px;
  height: 400px;
  background: #6366f1;
  top: -100px;
  left: -100px;
  animation-duration: 9s;
}

.orb2 {
  width: 300px;
  height: 300px;
  background: #8b5cf6;
  bottom: -80px;
  right: -60px;
  animation-duration: 11s;
}

.orb3 {
  width: 200px;
  height: 200px;
  background: #14b8a6;
  top: 50%;
  left: 60%;
  animation-duration: 7s;
}

@keyframes orbFloat {
  from {
    transform: translate(0, 0) scale(1);
  }

  to {
    transform: translate(20px, 30px) scale(1.06);
  }
}

.login-card {
  position: relative;
  z-index: 10;
  background: rgba(26, 34, 53, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(99, 102, 241, 0.08);
  animation: fadeSlideUp 0.5s ease;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 36px;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f1f5f9, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  animation: shake 0.4s ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0)
  }

  20% {
    transform: translateX(-6px)
  }

  60% {
    transform: translateX(6px)
  }

  80% {
    transform: translateX(-3px)
  }
}


/* ================================================
   APP SHELL
   ================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-text {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #a5b4fc, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(191, 241, 99, 0.4);
}

.logo-icon-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
  display: none;
}

.sidebar-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  transform: translateX(2px);
}

.nav-item.active {
  background: var(--bg-card);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.nav-item.active .nav-icon {
  color: var(--accent-light);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
}

.user-name {
  font-weight: 600;
  font-size: 0.85rem;
  display: block;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 8px;
  transition: all var(--transition);
}

.logout-btn:hover {
  color: var(--red);
  background: var(--red-soft);
}

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

/* --- Main content --- */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* --- Topbar --- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 8px;
  display: none;
  transition: all var(--transition);
}

.menu-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.topbar-title {
  font-weight: 700;
  font-size: 1.05rem;
  flex: 1;
}

.topbar-date {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* --- Page content --- */
.page-content {
  flex: 1;
  padding: 28px;
  max-width: 1400px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-header {
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 4px;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}


/* ================================================
   STAT CARDS
   ================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
  cursor: default;
}

.stat-card:hover {
  border-color: var(--border);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--card-grad, transparent);
  opacity: 0.06;
  pointer-events: none;
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  background: var(--icon-bg, rgba(99, 102, 241, 0.15));
}

.stat-card-icon svg {
  width: 22px;
  height: 22px;
  color: var(--icon-color, #a5b4fc);
}

.stat-card-value {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.stat-card-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* ================================================
   CARDS & PANELS
   ================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}


/* ================================================
   RENEWAL WIDGET
   ================================================ */
.renewal-list {
  display: flex;
  flex-direction: column;
}

.renewal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}

.renewal-item:last-child {
  border-bottom: none;
}

.renewal-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.renewal-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.renewal-item-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.renewal-item-client {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.renewal-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-red {
  background: var(--red-soft);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-orange {
  background: var(--orange-soft);
  color: #fdba74;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.badge-green {
  background: var(--green-soft);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
}


/* ================================================
   TABLE
   ================================================ */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.search-box input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 12px 9px 38px;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color var(--transition);
  font-family: var(--font);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 15px;
  height: 15px;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  border-bottom: 1px solid var(--border-subtle);
}

thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

tbody td {
  padding: 13px 16px;
  font-size: 0.875rem;
  vertical-align: middle;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pagination-btns {
  display: flex;
  gap: 4px;
}

.pagination-btns button {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all var(--transition);
}

.pagination-btns button:hover:not(:disabled) {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-primary);
}

.pagination-btns button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.pagination-btns button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}


/* ================================================
   BADGES / STATUS
   ================================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-active {
  background: var(--green-soft);
  color: #4ade80;
}

.status-completed {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
}

.status-warning {
  background: var(--orange-soft);
  color: #fdba74;
}

.status-danger {
  background: var(--red-soft);
  color: #fca5a5;
}


/* ================================================
   BUTTONS
   ================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: 1px solid var(--btn-border, rgba(255, 255, 255, 0.1));
  background: var(--btn-bg, rgba(255, 255, 255, 0.05));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--btn-text, #ffffff);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-family);
  white-space: nowrap;
  text-decoration: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.btn-primary {
  background: var(--primary);
  border: 1px solid var(--primary);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  color: #ffffff;
}

.btn-primary:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-full {
  width: 100%;
  padding: 12px 18px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.btn-ghost:hover {
  background: var(--btn-hover-bg, rgba(255, 255, 255, 0.08));
  border: 1px solid var(--btn-border, rgba(255, 255, 255, 0.15));
  color: var(--text-primary);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.65);
  border: 1px solid rgba(239, 68, 68, 0.8);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: white;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.85);
  border-color: #ef4444;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: all var(--transition);
  font-size: 0.75rem;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-icon.danger:hover {
  color: var(--red);
  background: var(--red-soft);
}

.btn-icon.edit:hover {
  color: var(--accent-light);
  background: rgba(99, 102, 241, 0.12);
}

.action-btns {
  display: flex;
  gap: 4px;
  align-items: center;
}


/* ================================================
   FORMS
   ================================================ */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all var(--transition);
  font-family: var(--font);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input.error,
.form-select.error {
  border-color: var(--red);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-select {
  appearance: none;
  cursor: pointer;
}

.form-select option {
  background: var(--bg-card);
}

.form-error {
  font-size: 0.78rem;
  color: #fca5a5;
  margin-top: 5px;
  display: block;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
}


/* ================================================
   MODAL
   ================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeOverlay 0.2s ease;
}

@keyframes fadeOverlay {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 0.25s ease;
}

.modal-sm {
  max-width: 420px;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  transition: all var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.modal-body {
  padding: 24px;
}

.confirm-message {
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}


/* ================================================
   TOAST
   ================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  animation: toastIn 0.3s ease;
}

.toast.success {
  border-left: 3px solid var(--green);
  color: #86efac;
}

.toast.error {
  border-left: 3px solid var(--red);
  color: #fca5a5;
}

.toast.info {
  border-left: 3px solid var(--accent);
  color: #a5b4fc;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateX(24px);
  }
}


/* ================================================
   CLIENT DETAIL VIEW
   ================================================ */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 6px 0;
  margin-bottom: 20px;
  transition: color var(--transition);
}

.back-btn:hover {
  color: var(--accent-light);
}

.client-detail-header {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.client-avatar-lg {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: white;
}

.client-detail-meta h3 {
  font-size: 1.2rem;
  font-weight: 800;
}

.client-detail-meta p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 2px;
}

.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  font-family: var(--font);
}

.tab-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--accent-light);
  font-weight: 600;
}

.days-left {
  font-size: 0.78rem;
  font-weight: 700;
}

.days-critical {
  color: #fca5a5;
}

.days-warning {
  color: #fdba74;
}

.days-ok {
  color: #86efac;
}


/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
  }

  .sidebar-toggle {
    display: flex;
  }

  .menu-toggle {
    display: flex;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .page-content {
    padding: 16px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: 100%;
  }

  .topbar {
    padding: 0 16px;
  }

  .login-card {
    padding: 32px 24px;
  }

  .modal {
    max-width: calc(100vw - 32px);
  }

  /* Responsive Tables */
  .table-wrapper table,
  .table-wrapper thead,
  .table-wrapper tbody,
  .table-wrapper th,
  .table-wrapper td,
  .table-wrapper tr {
    display: block;
  }

  .table-wrapper thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .table-wrapper tr {
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    padding: 8px;
  }

  .table-wrapper td {
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
    padding: 10px 10px 10px 45%;
    text-align: right;
    min-height: 40px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  .table-wrapper td:before {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    width: 40%;
    padding-right: 10px;
    white-space: nowrap;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    content: attr(data-label);
  }

  .table-wrapper td:last-child {
    border-bottom: 0;
  }

  .action-btns {
    width: 100%;
    justify-content: flex-end;
  }
}


/* ================================================
   BAR CHART – Year Comparison
   ================================================ */
.year-selectors {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 160px;
  /* tooltip area 40px + bars 120px */
  overflow-x: none;
  padding-bottom: 4px;
}

.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  flex: 1;
  min-width: 44px;
}

.bar-tooltip {
  min-height: 40px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

.bar-pair {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
}

.bar {
  width: 14px;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.5s cubic-bezier(.4, 0, .2, 1), opacity 0.2s;
  cursor: default;
  position: relative;
}

.bar:hover {
  opacity: 0.75;
}

.bar::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.bar:hover::after {
  opacity: 1;
}

.bar-a {
  background: linear-gradient(180deg, #818cf8, #6366f1);
}

.bar-b {
  background: linear-gradient(180deg, #2dd4bf, #14b8a6);
}

.bar-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.year-totals-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.year-total-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 100px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.year-total-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.year-total-value {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}


/* ================================================
   3-COLUMN GRID (Dashboard)
   ================================================ */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 0;
}

/* ================================================
   MONTH COMPARISON WIDGET
   ================================================ */
.month-compare-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 0 8px;
}

.month-compare-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.month-compare-year {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.month-compare-amount {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.month-compare-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.month-compare-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.month-compare-diff {
  font-size: 0.9rem;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 20px;
}

.diff-up {
  background: var(--green-soft);
  color: #4ade80;
}

.diff-down {
  background: var(--red-soft);
  color: #fca5a5;
}


/* ================================================
   RESPONSIVE – grid-3 & bar chart
   ================================================ */
@media (max-width: 1100px) {
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 750px) {
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .bar-chart {
    gap: 4px;
  }

  .bar {
    width: 10px;
  }

  .year-selectors {
    flex-wrap: wrap;
  }
}

/* ================================================
   INTERACTIVE DASHBOARD ITEMS
   ================================================ */
.hover-edit {
  cursor: pointer;
  transition: all 0.2s ease;
}

.hover-edit:hover {
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  transform: translateX(4px);
}