/* ============================================================
   PM-MA Warranty Notification System — Design System
   ============================================================ */

:root {
  /* Color Palette */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;

  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --gray-950: #020617;

  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-400: #f87171;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-700: #b91c1c;

  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-600: #d97706;

  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;

  --violet-50: #f5f3ff;
  --violet-500: #8b5cf6;
  --violet-600: #7c3aed;

  /* Surfaces */
  --bg-primary: #0b1120;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-card-hover: rgba(30, 41, 59, 0.8);
  --bg-sidebar: #0f172a;
  --bg-input: rgba(15, 23, 42, 0.6);

  --border-color: rgba(51, 65, 85, 0.5);
  --border-subtle: rgba(51, 65, 85, 0.3);

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

  /* Spacing */
  --sidebar-width: 260px;
  --header-height: 60px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow-blue: 0 0 20px rgba(59, 130, 246, 0.15);
  --shadow-glow-red: 0 0 20px rgba(239, 68, 68, 0.15);
  --shadow-glow-amber: 0 0 20px rgba(245, 158, 11, 0.15);
  --shadow-glow-green: 0 0 20px rgba(16, 185, 129, 0.15);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-base: 250ms var(--ease-out);
  --transition-slow: 400ms var(--ease-out);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

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

body {
  font-family: 'Inter', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--gray-600);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-base);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary-500), var(--violet-600));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-glow-blue);
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary-400), var(--violet-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

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

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.08);
}

.nav-item.active {
  color: var(--primary-400);
  background: rgba(59, 130, 246, 0.12);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--primary-500);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid var(--border-subtle);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-info:hover {
  background: rgba(255,255,255, 0.04);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-500), var(--violet-600));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   MOBILE HEADER
   ============================================================ */

.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 90;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.menu-toggle:hover {
  background: rgba(255,255,255, 0.06);
}

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

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  min-width: 0;
}

.page {
  display: none;
  padding: 32px 40px;
  animation: pageIn 0.35s var(--ease-out);
}

.page.active {
  display: block;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.date-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ============================================================
   STATS GRID
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
  backdrop-filter: blur(8px);
  cursor: default;
}

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

.stat-card.stat-critical:hover { box-shadow: var(--shadow-glow-red); }
.stat-card.stat-warning:hover { box-shadow: var(--shadow-glow-amber); }
.stat-card.stat-safe:hover { box-shadow: var(--shadow-glow-green); }
.stat-card.stat-total:hover { box-shadow: var(--shadow-glow-blue); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-critical .stat-icon { background: rgba(239, 68, 68, 0.12); color: var(--red-400); }
.stat-warning .stat-icon { background: rgba(245, 158, 11, 0.12); color: var(--amber-400); }
.stat-safe .stat-icon { background: rgba(16, 185, 129, 0.12); color: var(--emerald-400); }
.stat-total .stat-icon { background: rgba(59, 130, 246, 0.12); color: var(--primary-400); }

.stat-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.stat-critical .stat-value { color: var(--red-400); }
.stat-warning .stat-value { color: var(--amber-400); }
.stat-safe .stat-value { color: var(--emerald-400); }
.stat-total .stat-value { color: var(--primary-400); }

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-indicator {
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: 0 0 0 100%;
  opacity: 0.06;
}

.stat-indicator.critical { background: var(--red-500); }
.stat-indicator.warning { background: var(--amber-500); }
.stat-indicator.safe { background: var(--emerald-500); }
.stat-indicator.total { background: var(--primary-500); }

/* ============================================================
   CARD
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
  backdrop-filter: blur(8px);
}

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

.card-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

.card-body {
  padding: 22px;
}

/* ============================================================
   TABLE
   ============================================================ */

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead {
  background: rgba(15, 23, 42, 0.5);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  transition: background var(--transition-fast);
}

.data-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover td {
  background: rgba(59, 130, 246, 0.04);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-critical {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red-400);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber-400);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-safe {
  background: rgba(16, 185, 129, 0.12);
  color: var(--emerald-400);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-expired {
  background: rgba(100, 116, 139, 0.12);
  color: var(--gray-400);
  border: 1px solid rgba(100, 116, 139, 0.2);
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--emerald-400);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-failed {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red-400);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-email {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-400);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-teams {
  background: rgba(139, 92, 246, 0.12);
  color: var(--violet-500);
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.days-remaining {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.days-remaining.critical { color: var(--red-400); }
.days-remaining.warning { color: var(--amber-400); }
.days-remaining.safe { color: var(--emerald-400); }

.badge-line {
  background: rgba(6, 199, 85, 0.12);
  color: #06C755;
  border: 1px solid rgba(6, 199, 85, 0.25);
}

.badge-info {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-400);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ── Schedule Badges (notification timeline) ───────────────── */

.schedule-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 280px;
}

.schedule-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
  cursor: default;
  transition: all var(--transition-fast);
}

.schedule-badge:hover {
  transform: scale(1.05);
}

.schedule-badge small {
  font-size: 0.6rem;
  opacity: 0.7;
  font-weight: 500;
}

.schedule-badge.sent {
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald-400);
  border: 1px solid rgba(16, 185, 129, 0.2);
  opacity: 0.65;
}

.schedule-badge.today {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary-400);
  border: 1px solid rgba(59, 130, 246, 0.3);
  animation: pulseGlow 2s infinite;
}

.schedule-badge.overdue {
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber-400);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.schedule-badge.pending {
  background: rgba(100, 116, 139, 0.1);
  color: var(--gray-400);
  border: 1px solid rgba(100, 116, 139, 0.2);
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
  50% { box-shadow: 0 0 8px 2px rgba(59, 130, 246, 0.2); }
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-400), var(--primary-500));
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--primary-500);
  color: var(--primary-400);
  background: rgba(59, 130, 246, 0.06);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(255,255,255, 0.05);
  color: var(--text-primary);
}

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

.btn-lg {
  padding: 12px 28px;
  font-size: 0.95rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  border-color: var(--primary-500);
  color: var(--primary-400);
  background: rgba(59, 130, 246, 0.08);
}

/* ============================================================
   SEARCH BOX
   ============================================================ */

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  transition: border-color var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-glow-blue);
}

.search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  width: 200px;
  outline: none;
}

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

/* ============================================================
   FILTER TABS
   ============================================================ */

.filter-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-tab:hover {
  border-color: var(--primary-500);
  color: var(--primary-400);
}

.filter-tab.active {
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--primary-500);
  color: var(--primary-400);
}

/* ============================================================
   FORM STYLES
   ============================================================ */

.contract-form {
  max-width: 800px;
}

.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  backdrop-filter: blur(8px);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--primary-400);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group-full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.required {
  color: var(--red-400);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  transition: all var(--transition-fast);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-glow-blue);
}

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-group select option {
  background: var(--gray-800);
  color: var(--text-primary);
}

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

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.duration-preview {
  margin-top: 12px;
  padding: 10px 16px;
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--primary-400);
}

/* Checkbox Cards */
.checkbox-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.checkbox-card {
  position: relative;
  cursor: pointer;
}

.checkbox-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.checkbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 16px 24px;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  min-width: 80px;
}

.checkbox-card input:checked + .checkbox-content {
  border-color: var(--primary-500);
  background: rgba(59, 130, 246, 0.1);
  box-shadow: var(--shadow-glow-blue);
}

.checkbox-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.checkbox-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.checkbox-card:hover .checkbox-content {
  border-color: var(--gray-400);
}

/* ── Custom Alert Days ─────────────────────────────── */

.custom-alert-row {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.custom-alert-row label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.custom-alert-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-alert-input {
  width: 100px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  transition: all var(--transition-fast);
}

.custom-alert-input:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.custom-alert-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary-400);
  color: var(--primary-400);
}

.btn-outline:hover {
  background: rgba(99, 102, 241, 0.1);
}

.custom-alert-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.custom-alert-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--amber-400);
  font-weight: 600;
  animation: tagPop 0.2s ease-out;
}

.custom-alert-tag .tag-remove {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  border: none;
  background: rgba(239, 68, 68, 0.15);
  color: var(--red-400);
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.custom-alert-tag .tag-remove:hover {
  background: rgba(239, 68, 68, 0.3);
}

/* ── Notification Time ─────────────────────────────── */

.notification-time-row {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notification-time-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.time-input {
  width: 140px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.time-input:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.badge-info {
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary-400);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

/* ============================================================
   EMAIL TAG INPUT
   ============================================================ */

.email-tag-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  transition: all var(--transition-fast);
  cursor: text;
}

.email-tag-input:focus-within {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-glow-blue);
}

.email-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.email-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px 4px 10px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--primary-300);
  animation: tagIn 0.25s var(--ease-out);
  max-width: 260px;
  overflow: hidden;
}

@keyframes tagIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.email-tag .tag-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-tag .tag-remove {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  border: none;
  background: rgba(239, 68, 68, 0.15);
  color: var(--red-400);
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  line-height: 1;
  padding: 0;
}

.email-tag .tag-remove:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
  transform: scale(1.1);
}

.email-input-wrap {
  flex: 1;
  min-width: 160px;
  position: relative;
}

.tag-input {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 4px 6px !important;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  width: 100%;
  outline: none;
}

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

/* Autocomplete Dropdown */
.email-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}

.email-dropdown.show {
  display: block;
  animation: dropIn 0.2s var(--ease-out);
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.email-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: 0.82rem;
}

.email-dropdown-item:hover,
.email-dropdown-item.highlighted {
  background: rgba(59, 130, 246, 0.1);
}

.email-dropdown-item .dropdown-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary-400);
  flex-shrink: 0;
  text-transform: uppercase;
}

.email-dropdown-item .dropdown-email {
  color: var(--text-primary);
  font-weight: 500;
}

.email-dropdown-item .dropdown-hint {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Recently Used Emails Section */
.recent-emails-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.recent-emails-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.recent-emails-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.recent-chip:hover {
  border-color: var(--primary-500);
  color: var(--primary-400);
  background: rgba(59, 130, 246, 0.08);
  transform: translateY(-1px);
}

.recent-chip.used {
  opacity: 0.4;
  pointer-events: none;
  text-decoration: line-through;
}

.recent-chip .chip-avatar {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-600), var(--violet-600));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  flex-shrink: 0;
}

.recent-chip .chip-add {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald-400);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.recent-chip:hover .chip-add {
  background: rgba(16, 185, 129, 0.25);
}

/* ============================================================
   FORM ACTIONS
   ============================================================ */

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 8px;
}

/* ============================================================
   NOTIFICATION FEED
   ============================================================ */

.notification-feed {
  padding: 4px 0;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

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

.notif-item:hover {
  background: rgba(59, 130, 246, 0.03);
}

.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.notif-icon.email {
  background: rgba(59, 130, 246, 0.12);
}

.notif-icon.teams {
  background: rgba(139, 92, 246, 0.12);
}

.notif-icon.line {
  background: rgba(6, 199, 85, 0.12);
}

.notif-content {
  flex: 1;
  min-width: 0;
}

.notif-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.notif-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.notif-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================================
   SETTINGS PAGE
   ============================================================ */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.info-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius-md);
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--primary-300);
  line-height: 1.5;
}

.info-box svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.trigger-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0 12px;
  font-weight: 600;
  font-size: 0.9rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--gray-500);
}

.status-dot.active {
  background: var(--emerald-500);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.checklist-item:hover {
  color: var(--primary-400);
}

.checklist-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-500);
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
  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);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red-400);
}

.modal-body {
  padding: 24px;
}

.modal-body .detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  gap: 16px;
}

.modal-body .detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.detail-value {
  font-size: 0.88rem;
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

/* ============================================================
   TOAST
   ============================================================ */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  animation: toastIn 0.4s var(--ease-out), toastOut 0.3s ease-in 2.7s forwards;
  min-width: 280px;
  max-width: 400px;
}

.toast.success {
  border-color: var(--emerald-500);
}

.toast.error {
  border-color: var(--red-500);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding-top: var(--header-height);
  }

  .page {
    padding: 20px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-icon {
    display: none;
  }

  .page-header {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .search-box {
    flex: 1;
  }

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

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

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

  .filter-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
}

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

  html {
    font-size: 14px;
  }
}

/* ============================================================
   THEME TOGGLE & LIGHT MODE
   ============================================================ */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  width: 100%;
  margin-bottom: 12px;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--primary-500);
}

.mobile-header .theme-toggle {
  width: auto;
  margin-bottom: 0;
  padding: 6px;
  border: none;
}

.mobile-header .theme-toggle span {
  display: none;
}

/* Light Theme Variables Overrides */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --bg-sidebar: #ffffff;
  --bg-input: #ffffff;

  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.06);
  --shadow-glow-blue: 0 4px 14px rgba(59, 130, 246, 0.3);
  --shadow-glow-red: 0 4px 14px rgba(239, 68, 68, 0.3);
  --shadow-glow-amber: 0 4px 14px rgba(245, 158, 11, 0.3);
  --shadow-glow-green: 0 4px 14px rgba(16, 185, 129, 0.3);
}

[data-theme="light"] .data-table thead {
  background: #f1f5f9;
}

[data-theme="light"] .nav-item:hover {
  background: #f1f5f9;
}

[data-theme="light"] .user-info:hover {
  background: #f1f5f9;
}

[data-theme="light"] .theme-toggle:hover {
  background: #f1f5f9;
}

[data-theme="light"] .form-group select option {
  background: #ffffff;
  color: #0f172a;
}

/* ============================================================
   ACTION BUTTONS — Edit / Delete in table rows
   ============================================================ */

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

.btn-edit:hover {
  border-color: var(--amber-500) !important;
  color: var(--amber-400) !important;
  background: rgba(245, 158, 11, 0.08) !important;
}

.btn-delete:hover {
  border-color: var(--red-500) !important;
  color: var(--red-400) !important;
  background: rgba(239, 68, 68, 0.08) !important;
}

/* ============================================================
   DANGER BUTTON
   ============================================================ */

.btn-danger {
  background: linear-gradient(135deg, var(--red-500), var(--red-600));
  color: white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: linear-gradient(135deg, var(--red-400), var(--red-500));
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
}

/* ============================================================
   MODAL ACTIONS
   ============================================================ */

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

/* ============================================================
   CONNECTION BADGE
   ============================================================ */

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.connection-badge.demo {
  background: rgba(245, 158, 11, 0.1);
  color: var(--amber-400);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.connection-badge.connected {
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald-400);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.connection-badge.demo .conn-dot {
  background: var(--amber-400);
  box-shadow: 0 0 6px var(--amber-400);
}

.connection-badge.connected .conn-dot {
  background: var(--emerald-400);
  box-shadow: 0 0 6px var(--emerald-400);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   SYNC BUTTON
   ============================================================ */

.btn-sync {
  gap: 6px;
}

.btn-sync:hover svg {
  animation: spin-once 0.5s ease;
}

@keyframes spin-once {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.sync-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-muted);
  border-top-color: var(--primary-400);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   EDIT BANNER
   ============================================================ */

.edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  margin-bottom: 16px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-lg);
  animation: slideDown 0.3s var(--ease-out);
  flex-wrap: wrap;
}

.edit-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--amber-400);
  font-size: 0.88rem;
  font-weight: 500;
}

.edit-banner-content svg {
  flex-shrink: 0;
}

.edit-banner-cancel {
  color: var(--text-muted) !important;
  border-color: var(--border-subtle) !important;
}

.edit-banner-cancel:hover {
  color: var(--red-400) !important;
  border-color: var(--red-500) !important;
  background: rgba(239, 68, 68, 0.08) !important;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   BADGE INFO — for notification days
   ============================================================ */

.badge-info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-400);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

