/* ============================================
   B2B Contract Management — Design System
   Dark Theme • Glassmorphism • Premium SaaS
   ============================================ */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* Background layers */
  --bg-body: #0b1120;
  --bg-surface: #111827;
  --bg-card: #1e293b;
  --bg-card-hover: #263348;
  --bg-elevated: #334155;
  --bg-input: #0f172a;

  /* Glass effect */
  --glass-bg: rgba(30, 41, 59, 0.65);
  --glass-border: rgba(71, 85, 105, 0.45);
  --glass-blur: 16px;

  /* Brand colors */
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --accent: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.2);

  /* Semantic colors */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.12);
  --orange: #f97316;
  --orange-bg: rgba(249, 115, 22, 0.12);

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

  /* Borders */
  --border: #1e293b;
  --border-light: #334155;
  --border-focus: #6366f1;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px var(--primary-glow);

  /* Sizing */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

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

/* Subtle background gradient */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background:
    radial-gradient(ellipse 800px 600px at 20% 10%, rgba(99,102,241,0.07), transparent),
    radial-gradient(ellipse 600px 500px at 80% 80%, rgba(6,182,212,0.05), transparent);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================
   LAYOUT
   ============================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-slow);
  z-index: 100;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  color: white;
  font-weight: 700;
}

.sidebar-brand .brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition-base);
}

.sidebar.collapsed .brand-text {
  opacity: 0;
  pointer-events: none;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 12px 8px;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition-base);
}

.sidebar.collapsed .nav-section-label {
  opacity: 0;
  height: 0;
  padding: 0;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
  margin-bottom: 2px;
}

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

.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary-hover);
}

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

.nav-item i,
.nav-item svg {
  width: 22px; height: 22px;
  flex-shrink: 0;
}

.nav-item .nav-label {
  opacity: 1;
  transition: opacity var(--transition-base);
}

.sidebar.collapsed .nav-item .nav-label {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

.sidebar.collapsed .nav-item .nav-badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 16px;
  padding: 1px 4px;
  font-size: 0.6rem;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

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

.sidebar-user:hover {
  background: var(--bg-card);
}

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

.sidebar-user .user-info {
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--transition-base);
}

.sidebar.collapsed .sidebar-user .user-info {
  opacity: 0;
  pointer-events: none;
}

.sidebar-user .user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

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

/* ── Main Content Area ── */
.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed ~ .main-area {
  margin-left: var(--sidebar-collapsed);
}

/* ── Top Bar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-toggle {
  width: 36px; height: 36px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.topbar-toggle:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.topbar-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-title p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: -2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-search {
  position: relative;
}

.topbar-search input {
  width: 260px;
  padding: 8px 12px 8px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.topbar-search i,
.topbar-search svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px; height: 18px;
  pointer-events: none;
}

.topbar-btn {
  width: 38px; height: 38px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--transition-fast);
}
.topbar-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.topbar-btn .notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  animation: pulse-dot 2s infinite;
}

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

/* ── Page Content ── */
.page-content {
  flex: 1;
  padding: 28px;
}

.page-section {
  display: none;
  animation: fadeIn 0.35s ease;
}

.page-section.active {
  display: block;
}

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

/* ============================================
   COMPONENTS
   ============================================ */

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.kpi-total::before { background: linear-gradient(90deg, var(--primary), var(--accent)); }
.kpi-card.kpi-active::before { background: linear-gradient(90deg, var(--success), #34d399); }
.kpi-card.kpi-expiring::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.kpi-card.kpi-value::before { background: linear-gradient(90deg, var(--accent), #22d3ee); }

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-light);
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-total .kpi-icon { background: var(--primary-glow); color: var(--primary); }
.kpi-active .kpi-icon { background: var(--success-bg); color: var(--success); }
.kpi-expiring .kpi-icon { background: var(--warning-bg); color: var(--warning); }
.kpi-value .kpi-icon { background: var(--accent-glow); color: var(--accent); }

.kpi-number {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.kpi-change.up { color: var(--success); background: var(--success-bg); }
.kpi-change.down { color: var(--danger); background: var(--danger-bg); }

/* ── Cards / Panels ── */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px 24px;
}

.card-body.no-padding {
  padding: 0;
}

/* ── Grid Layouts ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

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

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

.badge-draft { background: rgba(107,114,128,0.15); color: #9ca3af; }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-expiring { background: var(--orange-bg); color: var(--orange); animation: pulse-badge 2s infinite; }
.badge-expired { background: var(--danger-bg); color: var(--danger); }
.badge-liquidated { background: var(--info-bg); color: var(--info); }
.badge-cancelled { background: rgba(153,27,27,0.15); color: #fca5a5; }

@keyframes pulse-badge {
  0%, 100% { box-shadow: 0 0 0 0 var(--orange-bg); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

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

.badge-draft .badge-dot { background: #9ca3af; }
.badge-pending .badge-dot { background: var(--warning); }
.badge-active .badge-dot { background: var(--success); }
.badge-expiring .badge-dot { background: var(--orange); }
.badge-expired .badge-dot { background: var(--danger); }
.badge-liquidated .badge-dot { background: var(--info); }

/* ── Data Table ── */
.data-table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table thead th {
  background: var(--bg-surface);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

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

.data-table tbody tr:hover {
  background: rgba(99,102,241,0.04);
}

.data-table tbody td {
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table .col-id {
  font-weight: 600;
  color: var(--primary-hover);
  cursor: pointer;
}

.data-table .col-id:hover {
  text-decoration: underline;
}

.data-table .col-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.data-table .col-muted {
  color: var(--text-secondary);
  font-size: 0.82rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-glow);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
  background: var(--bg-card);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #059669; }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-sm {
  padding: 5px 12px;
  font-size: 0.78rem;
}

.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  justify-content: center;
}

/* ── Filters Bar ── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-select,
.filter-input {
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color var(--transition-fast);
}

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

.filter-select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.filter-select {
  padding-right: 36px;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.filter-input {
  width: 220px;
}

/* Date inputs — make calendar icon visible on dark bg */
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
  color-scheme: dark;
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 12px 22px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--primary-hover);
  border-bottom-color: var(--primary);
}

.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease;
}

.tab-panel.active {
  display: block;
}

/* ── Kanban Board ── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  min-height: 500px;
}

.kanban-column {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-light);
}

.kanban-col-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-col-count {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.kanban-col-pending .kanban-col-header { border-bottom-color: var(--warning); }
.kanban-col-reviewing .kanban-col-header { border-bottom-color: var(--info); }
.kanban-col-approved .kanban-col-header { border-bottom-color: var(--success); }
.kanban-col-rejected .kanban-col-header { border-bottom-color: var(--danger); }

.kanban-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.kanban-card-id {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-hover);
  margin-bottom: 6px;
}

.kanban-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.3;
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.kanban-card-priority {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.priority-high { background: var(--danger-bg); color: var(--danger); }
.priority-medium { background: var(--warning-bg); color: var(--warning); }
.priority-low { background: var(--success-bg); color: var(--success); }

/* ── Calendar ── */
.calendar-wrapper {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}

.calendar-grid {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.calendar-month {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.calendar-nav {
  display: flex;
  gap: 8px;
}

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

.calendar-table th {
  padding: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.calendar-table td {
  padding: 4px;
  text-align: center;
  vertical-align: top;
  height: 80px;
}

.calendar-day {
  width: 100%;
  height: 100%;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
}

.calendar-day:hover {
  background: var(--bg-card);
}

.calendar-day.today {
  background: var(--primary-glow);
  border: 1px solid var(--primary);
}

.calendar-day.other-month {
  opacity: 0.3;
}

.calendar-day-num {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
  margin-bottom: 4px;
}

.calendar-event {
  font-size: 0.65rem;
  padding: 2px 4px;
  border-radius: 3px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.cal-evt-sign { background: rgba(99,102,241,0.2); color: var(--primary-hover); }
.cal-evt-start { background: var(--success-bg); color: var(--success); }
.cal-evt-end { background: var(--danger-bg); color: var(--danger); }
.cal-evt-payment { background: var(--warning-bg); color: var(--warning); }

.calendar-events-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.calendar-events-panel h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.event-item {
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  margin-bottom: 10px;
  border-left: 3px solid var(--primary);
}

.event-item.evt-sign { border-left-color: var(--primary); }
.event-item.evt-start { border-left-color: var(--success); }
.event-item.evt-end { border-left-color: var(--danger); }
.event-item.evt-payment { border-left-color: var(--warning); }

.event-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.event-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

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

/* ── Activity Feed ── */
.activity-list {
  list-style: none;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
}

.activity-dot.dot-create { background: var(--success); }
.activity-dot.dot-approve { background: var(--primary); }
.activity-dot.dot-edit { background: var(--warning); }
.activity-dot.dot-expire { background: var(--danger); }

.activity-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.activity-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Expiring List ── */
.expiring-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.expiring-info {
  flex: 1;
}

.expiring-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

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

.expiring-days {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--orange);
  white-space: nowrap;
}

/* ── Contract Detail ── */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.detail-header-left {
  flex: 1;
}

.detail-header-left h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.detail-header-left .detail-id {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
}

.detail-header-right {
  display: flex;
  gap: 10px;
}

.detail-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.detail-info-item {
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.detail-info-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-info-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.detail-info-value.value-highlight {
  color: var(--accent);
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 10px; top: 0;
  width: 2px;
  height: 100%;
  background: var(--border-light);
}

.timeline-item {
  position: relative;
  padding-bottom: 24px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -22px; top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 3px solid;
  background: var(--bg-surface);
}

.timeline-dot.tl-create { border-color: var(--success); }
.timeline-dot.tl-review { border-color: var(--warning); }
.timeline-dot.tl-approve { border-color: var(--primary); }
.timeline-dot.tl-sign { border-color: var(--accent); }
.timeline-dot.tl-amend { border-color: var(--orange); }

.timeline-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.timeline-content {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.timeline-content strong {
  color: var(--primary-hover);
}

/* Payment table */
.payment-progress {
  width: 100%;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.payment-progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.8s ease;
}

/* ── Partner cards ── */
.partner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.partner-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition-base);
}

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

.partner-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.partner-avatar {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.partner-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.partner-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.partner-stat {
  background: var(--bg-card);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.partner-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.partner-stat-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Report charts area ── */
.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.chart-container {
  padding: 20px;
}

.chart-container canvas {
  max-height: 300px;
}

/* ── Settings ── */
.settings-form {
  max-width: 700px;
}

.form-group {
  margin-bottom: 20px;
}

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

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition-fast);
}

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

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

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

/* Role matrix */
.role-matrix {
  width: 100%;
  border-collapse: collapse;
}

.role-matrix th,
.role-matrix td {
  padding: 10px 14px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.role-matrix th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.role-matrix td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
}

.role-check {
  color: var(--success);
}

.role-cross {
  color: var(--text-muted);
  opacity: 0.4;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease;
}

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

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

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 32px; height: 32px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

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

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

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

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

.pagination-btns .page-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--border-light);
  background: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

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

.pagination-btns .page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ── Chart Legend (for custom style) ── */
.legend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}

/* ── Wizard / Stepper ── */
.wizard-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 32px;
  padding: 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.wizard-step:hover { background: var(--bg-card); }

.wizard-step-number {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  border: 2px solid var(--border-light);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.wizard-step.active .wizard-step-number {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 12px var(--primary-glow);
}

.wizard-step.completed .wizard-step-number {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.wizard-step-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.wizard-step.active .wizard-step-label { color: var(--text-primary); }
.wizard-step.completed .wizard-step-label { color: var(--success); }

.wizard-connector {
  width: 48px;
  height: 2px;
  background: var(--border-light);
  flex-shrink: 0;
}

.wizard-connector.completed { background: var(--success); }

.wizard-form-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.wizard-form-section.active { display: block; }

.wizard-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Notification Center ── */
.notif-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.notif-tab {
  padding: 8px 18px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.notif-tab:hover { border-color: var(--text-muted); color: var(--text-primary); }
.notif-tab.active { background: var(--primary); border-color: var(--primary); color: white; }

.notif-tab .notif-tab-count {
  font-size: 0.72rem;
  background: rgba(255,255,255,0.2);
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

.notif-tab.active .notif-tab-count { background: rgba(255,255,255,0.25); }

.notif-date-group {
  margin-bottom: 24px;
}

.notif-date-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
  padding-left: 4px;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.notif-item:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.notif-item.unread {
  border-left: 3px solid var(--primary);
}

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

.notif-icon.ni-warning { background: var(--warning-bg); color: var(--warning); }
.notif-icon.ni-success { background: var(--success-bg); color: var(--success); }
.notif-icon.ni-danger { background: var(--danger-bg); color: var(--danger); }
.notif-icon.ni-info { background: var(--info-bg); color: var(--info); }
.notif-icon.ni-primary { background: var(--primary-glow); color: var(--primary); }
.notif-icon.ni-payment { background: var(--accent-glow); color: var(--accent); }

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

.notif-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.notif-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.notif-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

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

.notif-action-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}
.notif-action-link:hover { color: var(--primary-hover); }

.notif-unread-dot {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 8px;
}

/* ── Payment Management ── */
.payment-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.payment-summary-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.payment-summary-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 3px;
}

.payment-summary-card.psc-total::after { background: linear-gradient(90deg, var(--primary), var(--accent)); }
.payment-summary-card.psc-paid::after { background: linear-gradient(90deg, var(--success), #34d399); }
.payment-summary-card.psc-upcoming::after { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.payment-summary-card.psc-overdue::after { background: linear-gradient(90deg, var(--danger), #f87171); }

.psc-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.psc-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.psc-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.payment-status-paid {
  color: var(--success);
  font-weight: 600;
}

.payment-status-upcoming {
  color: var(--warning);
  font-weight: 600;
}

.payment-status-overdue {
  color: var(--danger);
  font-weight: 600;
  animation: pulse-text 2s infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.payment-progress-mini {
  display: flex;
  align-items: center;
  gap: 10px;
}

.payment-progress-mini .payment-progress {
  flex: 1;
  height: 6px;
}

.payment-progress-mini .ppm-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 36px;
  text-align: right;
}

/* ── Audit Log ── */
.audit-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.audit-log-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.audit-entry {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  transition: background 0.2s;
  border-left: 3px solid transparent;
}
.audit-entry:hover {
  background: var(--glass-bg);
}

.audit-entry.ae-create { border-left-color: var(--success); }
.audit-entry.ae-update { border-left-color: var(--primary); }
.audit-entry.ae-approve { border-left-color: #8b5cf6; }
.audit-entry.ae-reject { border-left-color: var(--danger); }
.audit-entry.ae-sign { border-left-color: var(--accent); }
.audit-entry.ae-payment { border-left-color: var(--warning); }
.audit-entry.ae-login { border-left-color: var(--text-muted); }
.audit-entry.ae-delete { border-left-color: #ef4444; }
.audit-entry.ae-export { border-left-color: #6366f1; }

.audit-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.audit-icon.ai-create { background: rgba(16,185,129,0.15); color: var(--success); }
.audit-icon.ai-update { background: rgba(99,102,241,0.15); color: var(--primary); }
.audit-icon.ai-approve { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.audit-icon.ai-reject { background: rgba(239,68,68,0.15); color: var(--danger); }
.audit-icon.ai-sign { background: rgba(6,182,212,0.15); color: var(--accent); }
.audit-icon.ai-payment { background: rgba(245,158,11,0.15); color: var(--warning); }
.audit-icon.ai-login { background: rgba(148,163,184,0.1); color: var(--text-muted); }
.audit-icon.ai-export { background: rgba(99,102,241,0.15); color: #6366f1; }

.audit-body { flex: 1; min-width: 0; }

.audit-action {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.5;
}
.audit-action strong { font-weight: 600; }
.audit-action .audit-target {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}
.audit-action .audit-target:hover { text-decoration: underline; }

.audit-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.audit-detail-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.audit-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-top: 4px;
  min-width: 130px;
  text-align: right;
  flex-shrink: 0;
}

.audit-date-divider {
  padding: 10px 18px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 6px;
}
.audit-date-divider:first-child { border-top: none; margin-top: 0; }

/* ── Partner Detail ── */
.partner-profile {
  display: flex;
  gap: 28px;
  align-items: center;
  margin-bottom: 28px;
}

.partner-profile-avatar {
  width: 80px; height: 80px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.partner-profile-info {
  flex: 1;
  min-width: 0;
}

.partner-profile-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.partner-profile-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.partner-profile-tags {
  display: flex; gap: 8px;
}

.partner-tag {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.partner-tag.pt-strategic { background: rgba(99,102,241,0.15); color: var(--primary); }
.partner-tag.pt-supplier { background: rgba(245,158,11,0.15); color: var(--warning); }
.partner-tag.pt-customer { background: rgba(16,185,129,0.15); color: var(--success); }
.partner-tag.pt-active { background: rgba(16,185,129,0.2); color: var(--success); }

.partner-profile-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

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

.partner-stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.partner-stat-card .ps-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}

.partner-stat-card .ps-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
}

.partner-contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.contact-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.contact-field-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.contact-field-value {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Contract Renewal ── */
.renewal-summary-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.renewal-stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  position: relative;
  overflow: hidden;
}

.renewal-stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
}

.renewal-stat-card.rsc-pending::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.renewal-stat-card.rsc-inprogress::before { background: linear-gradient(90deg, var(--primary), #818cf8); }
.renewal-stat-card.rsc-completed::before { background: linear-gradient(90deg, var(--success), #34d399); }

.rsc-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.rsc-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
}

.rsc-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.renewal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 14px;
  transition: all 0.2s;
  position: relative;
}
.renewal-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(99,102,241,0.2);
}

.renewal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.renewal-card-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.renewal-card-title .rc-code {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}
.renewal-card-title .rc-code:hover { text-decoration: underline; }

.renewal-card-title .rc-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.renewal-card-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.renewal-urgency {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.renewal-urgency.ru-critical { background: rgba(239,68,68,0.15); color: var(--danger); }
.renewal-urgency.ru-soon { background: rgba(245,158,11,0.15); color: var(--warning); }
.renewal-urgency.ru-normal { background: rgba(99,102,241,0.15); color: var(--primary); }
.renewal-urgency.ru-done { background: rgba(16,185,129,0.15); color: var(--success); }

.renewal-card-body {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 14px;
}

.renewal-field-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.renewal-field-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 3px;
}

.renewal-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.renewal-card-actions .rca-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.renewal-card-actions .rca-assignee {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.rca-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
}

.renewal-comparison {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: start;
}

.renewal-comparison-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 60px;
  color: var(--primary);
  font-size: 1.5rem;
}

/* ── Modal title with icon ── */
.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Toast Notification ── */
.toast-notification {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  padding: 16px 24px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4), 0 0 20px rgba(16,185,129,0.1);
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-notification.show {
  transform: translateX(0);
  opacity: 1;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .payment-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
  .report-grid { grid-template-columns: 1fr; }
  .calendar-wrapper { grid-template-columns: 1fr; }
  .detail-info-grid { grid-template-columns: repeat(2, 1fr); }
  .renewal-card-body { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: 300;
    width: var(--sidebar-width) !important;
    background: #111827 !important;
    transition: transform 0.3s ease;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  /* Force full display even if collapsed class is present */
  .sidebar.mobile-open .brand-text { opacity: 1 !important; pointer-events: auto !important; }
  .sidebar.mobile-open .nav-section-label { opacity: 1 !important; height: auto !important; padding: 12px 12px 8px !important; overflow: visible !important; }
  .sidebar.mobile-open .nav-item .nav-label { opacity: 1 !important; width: auto !important; overflow: visible !important; pointer-events: auto !important; }
  .sidebar.mobile-open .nav-item { justify-content: flex-start !important; padding: 10px 14px !important; pointer-events: auto !important; }
  .sidebar.mobile-open .sidebar-user .user-info { opacity: 1 !important; width: auto !important; overflow: visible !important; }

  .main-area {
    margin-left: 0 !important;
    position: relative;
    z-index: 1;
    overflow-x: hidden;
  }

  /* Topbar mobile */
  .topbar {
    background: #111827 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 12px !important;
    gap: 8px;
  }
  .topbar-title h1 { font-size: 1rem; }
  .topbar-title p { display: none; }
  .topbar-right { gap: 4px; }
  .topbar-right .btn-primary {
    font-size: 0.75rem;
    padding: 6px 10px;
    white-space: nowrap;
  }
  .topbar-btn { width: 34px; height: 34px; }

  /* Page content */
  .page-content { padding: 16px !important; }

  /* Filters */
  .filters-bar { gap: 8px; }
  .filter-input { width: 100% !important; min-width: 0; }
  .filter-select { flex-shrink: 1; min-width: 0; }

  /* Tables: smaller font, allow horizontal scroll */
  .data-table-wrapper { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
  .data-table { font-size: 0.8rem; min-width: 600px; }
  .data-table thead th { padding: 10px 8px; font-size: 0.7rem; }
  .data-table tbody td { padding: 10px 8px; }

  /* Tabs: horizontal scroll */
  .tabs { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 10px 14px; font-size: 0.82rem; }

  /* Wizard stepper */
  .wizard-stepper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 14px 12px;
    margin-bottom: 20px;
    justify-content: flex-start;
  }
  .wizard-stepper::-webkit-scrollbar { display: none; }
  .wizard-step { padding: 6px 8px; gap: 6px; }
  .wizard-step-number { width: 28px; height: 28px; font-size: 0.75rem; }
  .wizard-step-label { font-size: 0.72rem; }
  .wizard-connector { width: 24px; }

  /* KPI cards */
  .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 12px; }
  .kpi-card { padding: 16px; }

  /* Payment summary cards */
  .payment-summary-grid { grid-template-columns: 1fr 1fr !important; gap: 12px; }
  .payment-summary-card { padding: 14px; }
  .psc-value { font-size: 1.25rem; }

  /* Renewal page */
  .renewal-summary-bar { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
  .renewal-stat-card { padding: 14px 16px; }
  .rsc-value { font-size: 1.3rem; }
  .renewal-card { padding: 16px; }
  .renewal-card-header { flex-wrap: wrap; gap: 10px; }
  .renewal-card-title { flex-wrap: wrap; gap: 8px; }
  .renewal-card-body { grid-template-columns: repeat(2, 1fr) !important; gap: 12px; }
  .renewal-field-value { font-size: 0.8rem; word-break: break-all; }
  .renewal-card-actions { flex-wrap: wrap; gap: 10px; }
  .renewal-card-actions .rca-left { flex-wrap: wrap; gap: 8px; }

  /* Kanban */
  .kanban-board { grid-template-columns: 1fr; }

  /* Grids */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .detail-info-grid { grid-template-columns: 1fr 1fr !important; }

  /* Detail header */
  .detail-header { flex-direction: column; gap: 12px; }
  .detail-header-right { flex-wrap: wrap; }
  .detail-header-left h2 { font-size: 1.2rem; }

  /* Search hidden */
  .topbar-search { display: none; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }

  /* Partner grid */
  .partner-grid { grid-template-columns: 1fr !important; }

  /* Report filter bar */
  .report-filters { flex-wrap: wrap; gap: 8px; }
  .report-filters .filter-select { flex: 1; min-width: 100px; }

  /* Notification tabs */
  .notif-tabs { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .notif-tabs::-webkit-scrollbar { display: none; }

  /* Calendar */
  .calendar-grid { padding: 10px; overflow: hidden; }
  .calendar-header { margin-bottom: 12px; }
  .calendar-month { font-size: 0.95rem; }
  .legend-list { flex-wrap: wrap; gap: 8px 12px; }
  .legend-item { font-size: 0.7rem; }
  .calendar-table { font-size: 0.7rem; table-layout: fixed; width: 100%; }
  .calendar-table th { padding: 4px 1px; font-size: 0.65rem; }
  .calendar-table td { padding: 1px; height: 56px; }
  .calendar-day { padding: 3px 2px; overflow: hidden; }
  .calendar-day-num { font-size: 0.7rem; margin-bottom: 2px; }
  .calendar-event { font-size: 0.5rem; padding: 1px 2px; margin-bottom: 1px; }
  .calendar-events-panel { padding: 14px; }
  .calendar-events-panel h3 { font-size: 0.88rem; margin-bottom: 10px; }
  .event-item { padding: 10px; margin-bottom: 8px; }
  .event-name { font-size: 0.82rem; }
  .event-desc { font-size: 0.75rem; }
  .event-time { font-size: 0.7rem; }

  /* Audit logs */
  .audit-filters { flex-wrap: wrap; gap: 8px; }

  /* Cards - only affect card-body padding, not card itself to avoid double padding */
  .card > .card-body { padding: 14px 16px; }
  .card > .card-header { padding: 14px 16px; }

  /* Tables inside cards without wrapper — enable horizontal scroll */
  .card-body.no-padding {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Inline grid overrides for detail pages */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Modals */
  .modal-content { 
    width: 95% !important; 
    max-height: 90vh; 
    margin: 5vh auto;
  }
}

/* ── Mobile Sidebar Overlay ── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 250;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

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