/* ==========================================================================
   MARTIN EDUVERSE - COMMISSION DECLARATION & AGREEMENT GENERATOR
   Core Design System & Responsive Stylesheet
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-main: #0B1120;
  --bg-surface: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --bg-input: rgba(15, 23, 42, 0.8);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(201, 168, 76, 0.6);
  --border-active: rgba(99, 102, 241, 0.5);

  --text-main: #F9FAFB;
  --text-muted: #9CA3AF;
  --text-subtle: #6B7280;

  /* Martin Eduverse Signature Brand Colors */
  --brand-navy: #1F3864;
  --brand-navy-light: #2D4C82;
  --brand-gold: #C9A84C;
  --brand-gold-hover: #DFBD5D;
  --brand-gold-glow: rgba(201, 168, 76, 0.25);

  /* Functional Accents */
  --accent-emerald: #10B981;
  --accent-emerald-bg: rgba(16, 185, 129, 0.12);
  --accent-emerald-border: rgba(16, 185, 129, 0.3);
  --accent-blue: #3B82F6;
  --accent-indigo: #6366F1;
  --accent-danger: #EF4444;
  --accent-danger-bg: rgba(239, 68, 68, 0.12);
  --accent-warning: #F59E0B;

  /* Typography */
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Shadows & Glassmorphism */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 25px rgba(201, 168, 76, 0.2);
  --glass-blur: blur(16px);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(31, 56, 100, 0.3) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(201, 168, 76, 0.15) 0px, transparent 40%),
    radial-gradient(at 50% 100%, rgba(17, 24, 39, 0.6) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-layout {
  max-width: 1380px;
  margin: 0 auto;
  padding: 20px 24px 60px 24px;
}

/* ==========================================================================
   APP HEADER
   ========================================================================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

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

.logo-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(31, 56, 100, 0.8), rgba(201, 168, 76, 0.3));
  border: 1px solid rgba(201, 168, 76, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.brand-logo {
  max-width: 44px;
  max-height: 44px;
  object-fit: contain;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #FFFFFF;
  line-height: 1.1;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(201, 168, 76, 0.18);
  color: var(--brand-gold);
  border: 1px solid rgba(201, 168, 76, 0.35);
  text-transform: uppercase;
}

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

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

.stats-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stats-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: linear-gradient(135deg, #C9A84C 0%, #B8923A 100%);
  color: #0A0F1D;
  box-shadow: 0 4px 15px rgba(201, 168, 76, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #DFBD5D 0%, #C9A84C 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(201, 168, 76, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-outline {
  background: transparent;
  color: var(--brand-gold);
  border-color: rgba(201, 168, 76, 0.4);
}

.btn-outline:hover {
  background: rgba(201, 168, 76, 0.1);
  border-color: var(--brand-gold);
}

.btn-doc {
  background: linear-gradient(135deg, #1F3864 0%, #152747 100%);
  color: #FFFFFF;
  border-color: rgba(31, 56, 100, 0.6);
  box-shadow: 0 4px 15px rgba(31, 56, 100, 0.4);
}

.btn-doc:hover {
  background: linear-gradient(135deg, #2D4C82 0%, #1F3864 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(31, 56, 100, 0.5);
}

.btn-ilovepdf {
  background: linear-gradient(135deg, #E53935 0%, #C62828 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 15px rgba(229, 57, 53, 0.35);
}

.btn-ilovepdf:hover {
  background: linear-gradient(135deg, #EF5350 0%, #E53935 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(229, 57, 53, 0.45);
}

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

.chip-btn {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip-btn:hover {
  background: rgba(201, 168, 76, 0.15);
  color: var(--brand-gold);
  border-color: rgba(201, 168, 76, 0.4);
}

/* ==========================================================================
   TABS NAVIGATION
   ========================================================================== */
.tabs-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: var(--glass-blur);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(31, 56, 100, 0.6) 0%, rgba(17, 24, 39, 0.9) 100%);
  color: #FFFFFF;
  border: 1px solid rgba(201, 168, 76, 0.35);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.tab-btn.active svg {
  color: var(--brand-gold);
}

.tab-count {
  font-size: 0.7rem;
  padding: 2px 7px;
  background: rgba(201, 168, 76, 0.2);
  color: var(--brand-gold);
  border-radius: var(--radius-full);
  font-weight: 700;
}

/* Tab Content Panes */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

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

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

/* ==========================================================================
   CARDS & SECTIONS
   ========================================================================== */
.card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  overflow: hidden;
}

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

.card-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-indigo);
  border: 1px solid rgba(99, 102, 241, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-icon-wrap.icon-uni {
  background: rgba(201, 168, 76, 0.12);
  color: var(--brand-gold);
  border-color: rgba(201, 168, 76, 0.3);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: #FFFFFF;
}

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

.quick-preset {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.card-body {
  padding: 24px;
}

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

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

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

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #E2E8F0;
  letter-spacing: 0.01em;
}

.form-group label .req {
  color: var(--accent-danger);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: #FFFFFF;
  outline: none;
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--brand-gold);
  box-shadow: 0 0 0 3px var(--brand-gold-glow);
}

.form-control::placeholder {
  color: var(--text-subtle);
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-subtle);
  margin-top: 2px;
}

/* ==========================================================================
   CONTROL BAR & SEARCH
   ========================================================================== */
.control-header {
  background: rgba(15, 23, 42, 0.4);
}

.header-left-bar {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 12px;
  color: var(--text-subtle);
  pointer-events: none;
}

.search-box input {
  padding: 9px 34px 9px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: #FFFFFF;
  outline: none;
  width: 280px;
  transition: all var(--transition-fast);
}

.search-box input:focus {
  border-color: var(--brand-gold);
  width: 320px;
}

.btn-icon-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-subtle);
  font-size: 1.1rem;
  cursor: pointer;
}

/* ==========================================================================
   CATEGORY PRESETS (A, B, C, D)
   ========================================================================== */
.category-preset-section {
  padding: 16px 24px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.7) 0%, rgba(10, 15, 29, 0.85) 100%);
  border-bottom: 1px solid rgba(201, 168, 76, 0.2);
}

.cat-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.cat-bar-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cat-icon-chip {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(201, 168, 76, 0.25) 0%, rgba(31, 56, 100, 0.5) 100%);
  color: var(--brand-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(201, 168, 76, 0.4);
}

.cat-main-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.01em;
}

.cat-hint {
  display: block;
  font-size: 0.76rem;
  color: var(--text-subtle);
  margin-top: 2px;
}

.cat-save-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.save-tag-text {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand-gold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}

.btn-save-chip {
  padding: 4px 9px;
  font-size: 0.73rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #E2E8F0;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-save-chip:hover {
  background: rgba(201, 168, 76, 0.2);
  border-color: var(--brand-gold);
  color: #FFFFFF;
  transform: translateY(-1px);
}

.cat-tiers-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

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

@media (max-width: 576px) {
  .cat-tiers-grid {
    grid-template-columns: 1fr;
  }
}

.cat-card-btn {
  background: rgba(17, 24, 39, 0.6);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.cat-card-btn:hover {
  border-color: rgba(201, 168, 76, 0.4);
  background: rgba(31, 56, 100, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.cat-card-btn.active {
  border-color: var(--brand-gold);
  background: linear-gradient(135deg, rgba(31, 56, 100, 0.6) 0%, rgba(15, 23, 42, 0.9) 100%);
  box-shadow: 0 0 15px rgba(201, 168, 76, 0.25), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.cat-card-btn.active::after {
  content: '✓ ACTIVE';
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(201, 168, 76, 0.25);
  color: var(--brand-gold);
  border: 1px solid var(--brand-gold);
  letter-spacing: 0.04em;
}

.cat-card-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.badge-cat-a {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #111827;
}

.badge-cat-b {
  background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
  color: #FFFFFF;
}

.badge-cat-c {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  color: #FFFFFF;
}

.badge-cat-d {
  background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
  color: #FFFFFF;
}

.cat-card-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #FFFFFF;
  margin-bottom: 2px;
}

.cat-card-sub {
  font-size: 0.74rem;
  color: var(--text-subtle);
  font-weight: 500;
}

/* Bulk Toolbar */
.bulk-toolbar {
  padding: 12px 24px;
  background: rgba(10, 15, 29, 0.6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.bulk-left, .bulk-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bulk-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 4px;
}

.tool-btn {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #CBD5E1;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
}

.tool-margin {
  background: rgba(201, 168, 76, 0.1);
  color: var(--brand-gold);
  border-color: rgba(201, 168, 76, 0.25);
}

.tool-margin:hover {
  background: rgba(201, 168, 76, 0.2);
  border-color: var(--brand-gold);
}

/* ==========================================================================
   UNIVERSITIES TABLE
   ========================================================================== */
.uni-table-wrapper {
  max-height: 640px;
  overflow-y: auto;
  position: relative;
}

.uni-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.uni-table thead {
  position: sticky;
  top: 0;
  background: #0D1424;
  z-index: 10;
}

.uni-table th {
  padding: 12px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
}

.uni-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

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

.uni-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.uni-table tbody tr.row-selected {
  background: rgba(31, 56, 100, 0.15);
}

.uni-table tbody tr.row-unselected {
  opacity: 0.55;
}

.th-center, .td-center {
  text-align: center;
}

/* Checkbox */
.custom-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--brand-gold);
}

/* University Details in Row */
.uni-name-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.uni-full-name {
  font-weight: 600;
  color: #F8FAFC;
  font-size: 0.9rem;
}

.uni-code-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand-gold);
  background: rgba(201, 168, 76, 0.12);
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201, 168, 76, 0.25);
  width: fit-content;
}

.mode-badge {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.12);
  color: #818CF8;
  border: 1px solid rgba(99, 102, 241, 0.25);
  font-weight: 500;
  display: inline-block;
}

/* Base Comm & Stepper */
.base-comm-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #94A3B8;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.partner-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
}

.partner-input-wrap:focus-within {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 2px var(--accent-emerald-bg);
}

.partner-input {
  width: 54px;
  background: transparent;
  border: none;
  color: var(--accent-emerald);
  font-size: 0.95rem;
  font-weight: 800;
  text-align: center;
  outline: none;
}

.step-btn {
  width: 22px;
  height: 22px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 4px;
  color: #CBD5E1;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.step-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

/* Margin Indicator */
.margin-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.margin-positive {
  background: var(--accent-emerald-bg);
  color: var(--accent-emerald);
  border: 1px solid var(--accent-emerald-border);
}

.margin-zero {
  background: rgba(255, 255, 255, 0.05);
  color: #94A3B8;
  border: 1px solid var(--border-subtle);
}

.margin-negative {
  background: var(--accent-danger-bg);
  color: var(--accent-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-del-uni {
  background: transparent;
  border: none;
  color: #64748B;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.btn-del-uni:hover {
  color: var(--accent-danger);
  background: var(--accent-danger-bg);
}

/* Summary Bar */
.table-summary-bar {
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.7);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.summary-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

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

.text-emerald { color: var(--accent-emerald); }
.text-gold { color: var(--brand-gold); }

/* ==========================================================================
   TAB 2: A4 OFFICIAL AGREEMENT DOCUMENT (WORD / PDF VIEW)
   ========================================================================== */
.doc-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 14px;
}

.doc-actions-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-badge {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(31, 56, 100, 0.4);
  color: #93C5FD;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

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

.doc-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Authentic A4 Document Canvas */
.a4-document-container {
  display: flex;
  justify-content: center;
  padding: 10px 0 50px 0;
}

.a4-sheet {
  width: 820px;
  min-height: 1100px;
  background: #FFFFFF;
  color: #1E293B;
  padding: 45px 50px;
  border-radius: 4px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
}

/* Letterhead */
.doc-letterhead {
  display: flex;
  align-items: center;
  gap: 20px;
  border-bottom: 2.5px solid #1F3864;
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.letterhead-logo-wrap {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.emblem-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.doc-company-name {
  font-size: 24px;
  font-weight: 800;
  color: #1F3864;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.doc-tagline {
  font-size: 11px;
  font-weight: 700;
  color: #C9A84C;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.doc-location-line {
  font-size: 10.5px;
  color: #64748B;
  margin-top: 2px;
}

/* Document Title Banner */
.doc-title-banner {
  background: #F4F7FB;
  border: 1.5px solid #1F3864;
  border-radius: 6px;
  padding: 8px 12px;
  text-align: center;
  margin-bottom: 14px;
}

.doc-title-banner h3 {
  font-size: 13px;
  font-weight: 800;
  color: #1F3864;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Meta row */
.doc-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: #334155;
  margin-bottom: 12px;
}

/* Recipient Box */
.doc-recipient-box {
  background: #FAFCFF;
  border: 1px solid #CBD5E1;
  border-left: 4px solid #1F3864;
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 11.5px;
  line-height: 1.45;
}

.recipient-to {
  font-weight: bold;
  color: #475569;
}

.recipient-name {
  font-size: 13.5px;
  font-weight: bold;
  color: #1F3864;
}

.recipient-org {
  font-weight: 600;
  color: #334155;
}

.recipient-contact {
  color: #64748B;
  font-size: 10.5px;
}

/* Subject Bar */
.doc-subject-bar {
  background: #F1F5F9;
  border-left: 3.5px solid #C9A84C;
  padding: 7px 12px;
  font-size: 11.5px;
  font-weight: 700;
  color: #1F3864;
  margin-bottom: 12px;
}

/* Preamble */
.doc-preamble {
  font-size: 11.5px;
  color: #334155;
  text-align: justify;
  line-height: 1.55;
  margin-bottom: 14px;
}

/* Document University Table */
.doc-table-box {
  margin-bottom: 16px;
}

.doc-uni-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.doc-uni-table th {
  background: #1F3864;
  color: #FFFFFF;
  font-weight: bold;
  padding: 7px 10px;
  border: 1px solid #1F3864;
  font-size: 10.5px;
  letter-spacing: 0.02em;
}

.doc-uni-table td {
  padding: 6px 10px;
  border: 1px solid #CBD5E1;
  color: #1E293B;
}

.doc-uni-table tr:nth-child(even) td {
  background: #F8FAFC;
}

.doc-uni-table .uni-strong {
  font-weight: bold;
  color: #1F3864;
}

.doc-uni-table .uni-short {
  font-weight: bold;
  color: #C9A84C;
}

.doc-uni-table .comm-val {
  font-weight: bold;
  color: #047857;
  font-size: 12px;
}

/* Terms Box */
.doc-terms-box {
  background: #FFFDF7;
  border: 1px solid #CBD5E1;
  border-left: 4px solid #C9A84C;
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 16px;
}

.terms-title {
  font-size: 11px;
  font-weight: bold;
  color: #1F3864;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.terms-list {
  padding-left: 18px;
  font-size: 10.5px;
  color: #334155;
  line-height: 1.5;
}

.terms-list li {
  margin-bottom: 4px;
}

/* Signatures Dual Block */
.doc-signature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1.5px solid #1F3864;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 14px;
}

.sig-column {
  padding: 12px 16px;
  font-size: 11px;
}

.sig-company {
  border-right: 1px solid #CBD5E1;
  background: #FAFCFF;
}

.sig-partner {
  background: #FFFFFF;
}

.sig-heading {
  font-size: 11px;
  font-weight: bold;
  color: #1F3864;
  border-bottom: 1px solid #E2E8F0;
  padding-bottom: 4px;
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}

.sig-person {
  font-weight: bold;
  color: #0F172A;
}

.sig-designation {
  font-size: 10px;
  color: #64748B;
}

.sig-stamp-wrap {
  margin: 8px 0;
  min-height: 75px;
  display: flex;
  align-items: center;
}

.official-stamp-img {
  height: 75px;
  width: 75px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}

.sig-footer-note {
  font-size: 10.5px;
  font-weight: 600;
  color: #1F3864;
  letter-spacing: 0.02em;
}

.sig-confirm-text {
  font-size: 10.5px;
  color: #475569;
  line-height: 1.4;
  margin-bottom: 8px;
}

.partner-sign-fields {
  font-size: 10.5px;
  color: #334155;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sig-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.line-fill {
  color: #94A3B8;
}

/* Document Footer */
.doc-footer {
  border-top: 1px solid #E2E8F0;
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: #94A3B8;
  font-style: italic;
}

/* ==========================================================================
   TAB 3: EMAIL FORMAT PREVIEW
   ========================================================================== */
.email-view-container {
  max-width: 900px;
  margin: 0 auto;
}

.email-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.badge-email {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.email-subtext {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.email-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Envelope Container */
.email-window {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  color: #1E293B;
  border: 1px solid #CBD5E1;
}

.email-envelope {
  background: #F8FAFC;
  border-bottom: 1px solid #E2E8F0;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
}

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

.envelope-label {
  font-weight: 700;
  color: #64748B;
  width: 60px;
}

.envelope-val {
  color: #0F172A;
  font-weight: 600;
}

.email-subject-text {
  color: #1F3864;
  font-size: 0.95rem;
}

.btn-copy-mini {
  margin-left: auto;
  padding: 3px 8px;
  font-size: 0.72rem;
  background: #E2E8F0;
  border: none;
  border-radius: 4px;
  color: #475569;
  cursor: pointer;
  font-weight: 600;
}

.btn-copy-mini:hover {
  background: #CBD5E1;
  color: #0F172A;
}

/* Email Body HTML Preview */
.email-body-preview {
  padding: 32px 36px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #334155;
  background: #FFFFFF;
}

.email-body-preview h4 {
  color: #1F3864;
  margin: 18px 0 8px 0;
  font-size: 15px;
}

.email-meta-card {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-left: 4px solid #1F3864;
  padding: 14px 18px;
  border-radius: 6px;
  margin: 16px 0;
}

.email-uni-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}

.email-uni-table th {
  background: #1F3864;
  color: #FFFFFF;
  padding: 8px 12px;
  text-align: left;
  border: 1px solid #1F3864;
}

.email-uni-table td {
  padding: 8px 12px;
  border: 1px solid #CBD5E1;
  color: #1E293B;
}

.email-uni-table tr:nth-child(even) {
  background: #F8FAFC;
}

.email-footer-sign {
  margin-top: 24px;
  border-top: 2px solid #E2E8F0;
  padding-top: 14px;
}

/* ==========================================================================
   MODAL DIALOG
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: #111827;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: #FFFFFF;
}

.btn-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.btn-modal-close:hover {
  color: #FFFFFF;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

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

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toastSlideIn 0.25s ease forwards;
  color: #FFFFFF;
}

@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-success {
  background: #065F46;
  border: 1px solid #059669;
}

.toast-info {
  background: #1E3A8A;
  border: 1px solid #2563EB;
}

.toast-error {
  background: #991B1B;
  border: 1px solid #DC2626;
}

/* ==========================================================================
   PRINT MEDIA STYLESHEET (FOR PERFECT VECTOR A4 PDF)
   ========================================================================== */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .app-header,
  .tabs-nav,
  .doc-actions-bar,
  #tab-configurator,
  #tab-email,
  .toast-container,
  .modal-backdrop {
    display: none !important;
  }

  #tab-agreement {
    display: block !important;
  }

  .a4-document-container {
    padding: 0 !important;
    margin: 0 !important;
  }

  .a4-sheet {
    box-shadow: none !important;
    border: none !important;
    padding: 20px 25px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .tabs-nav {
    flex-direction: column;
  }
  .search-box input {
    width: 100%;
  }
  .search-box input:focus {
    width: 100%;
  }
  .bulk-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .a4-sheet {
    width: 100%;
    padding: 25px 20px;
  }
  .doc-signature-grid {
    grid-template-columns: 1fr;
  }
  .sig-company {
    border-right: none;
    border-bottom: 1px solid #CBD5E1;
  }
}

/* ==========================================================================
   PORTAL AUTHENTICATION & LOGIN LOCK
   ========================================================================== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 25%, rgba(31, 56, 100, 0.5) 0%, rgba(10, 15, 29, 0.98) 75%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.4s ease;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(160deg, rgba(20, 29, 47, 0.92) 0%, rgba(10, 15, 29, 0.98) 100%);
  border: 1.5px solid rgba(201, 168, 76, 0.35);
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(31, 56, 100, 0.45);
  padding: 32px 30px;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #1F3864 0%, #C9A84C 50%, #1F3864 100%);
}

.login-brand {
  text-align: center;
  margin-bottom: 20px;
}

.login-emblem-wrap {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 4px 12px rgba(201, 168, 76, 0.3));
}

.login-emblem {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.login-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--brand-gold);
  background: rgba(201, 168, 76, 0.15);
  border: 1px solid rgba(201, 168, 76, 0.35);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 0.78rem;
  color: var(--text-subtle);
}

.login-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 168, 76, 0.3), transparent);
  margin-bottom: 22px;
}

.login-form-group {
  margin-bottom: 18px;
  text-align: left;
}

.login-form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #E2E8F0;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .field-icon {
  position: absolute;
  left: 14px;
  color: var(--brand-gold);
  pointer-events: none;
  opacity: 0.85;
}

.input-with-icon .form-control {
  padding-left: 42px;
  padding-right: 42px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  font-size: 0.9rem;
  height: 44px;
  border-radius: 8px;
  transition: all var(--transition-fast);
}

.input-with-icon .form-control:focus {
  border-color: var(--brand-gold);
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.2);
}

.btn-toggle-pw {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: color var(--transition-fast);
}

.btn-toggle-pw:hover {
  color: var(--brand-gold);
}

.login-error-alert {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #FCA5A5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.btn-login-submit {
  width: 100%;
  height: 44px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1F3864 0%, #2A4D8D 50%, #C9A84C 100%);
  border: 1px solid rgba(201, 168, 76, 0.4);
  color: #FFFFFF;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.btn-login-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(201, 168, 76, 0.35);
  border-color: var(--brand-gold);
}

.login-card-footer {
  text-align: center;
  margin-top: 18px;
  font-size: 0.72rem;
  color: var(--text-subtle);
  letter-spacing: 0.03em;
}

/* User Session Pill in App Header */
.user-session-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(201, 168, 76, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.admin-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 8px #10B981;
}

.admin-user-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #FFFFFF;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-logout-header {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #F87171;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
}

.btn-logout-header:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #FFFFFF;
  border-color: #EF4444;
}

