/* Reset and Base Styles */
/* --- Training Portal Modern UI --- */
#training-page .tp-card { position:relative; border-radius: 14px; border:1px solid var(--border-color); background:#fff; padding:16px; box-shadow: var(--shadow-sm); display:flex; flex-direction:column; gap:10px; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; min-height: 220px; }
#training-page .tp-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color:#c7d2fe; }
#training-page .tp-header { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
#training-page .tp-title { font-weight:800; color:#0f172a; font-size:1.05rem; line-height:1.25; display:-webkit-box; -webkit-line-clamp:2; line-clamp: 2; -webkit-box-orient:vertical; overflow:hidden; }
#training-page .tp-desc { color:#64748b; margin-top:4px; font-size:.95rem; display:-webkit-box; -webkit-line-clamp:4; line-clamp: 4; -webkit-box-orient:vertical; overflow:hidden; }
#training-page .tp-actions { display:flex; gap:.5rem; align-items:center; }
#training-page .tp-card .tp-actions .btn-icon { margin: 0 !important; padding: 0 !important; width:34px; height:34px; display:inline-flex; align-items:center; justify-content:center; border-radius:10px; }
#training-page .tp-card .tp-actions { gap: .5rem; }
#training-page .tp-footer { margin-top:auto; display:flex; align-items:center; justify-content:space-between; gap:.5rem; }
#training-page .tp-meta { display:flex; align-items:center; gap:10px; color:#64748b; font-size:.9rem; }
#training-page .tp-pill { background:#f1f5f9; border:1px solid #e5e7eb; color:#334155; padding:4px 8px; border-radius:999px; font-size:.85rem; }
#training-page .tp-stripe { position:absolute; left:0; top:0; bottom:0; width:4px; border-top-left-radius:14px; border-bottom-left-radius:14px; background:linear-gradient(135deg,#1e40af,#3b82f6); }
#training-page .btn-icon { width:34px; height:34px; display:inline-flex; align-items:center; justify-content:center; border-radius:10px; border:1px solid #e5e7eb; background:#f8fafc; color:#334155; cursor:pointer; padding:0 !important; margin:0 !important; line-height:1 !important; box-sizing:border-box; vertical-align:middle; }
#training-page .btn-icon i { font-size:14px; line-height:1; }
#training-page .btn-icon.danger { background:#fee2e2; border-color:#fecaca; color:#b91c1c; }
#training-page .btn-icon.danger:hover { background:#fecaca; border-color:#fca5a5; color:#7f1d1d; }
#training-page .btn-icon:hover { background:#eef2ff; border-color:#c7d2fe; color:#1e40af; }
#training-page .tp-files { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
#training-page .tp-chip { display:inline-flex; align-items:center; gap:6px; background:#f8fafc; border:1px solid #e2e8f0; padding:6px 10px; border-radius:999px; color:#0f172a; text-decoration:none; transition:all .15s ease; }
#training-page .tp-chip:hover { background:#eef2ff; border-color:#c7d2fe; color:#1e40af; }
#training-page .tp-chip .del { padding:2px 6px; background:#ef4444; color:#fff; border-radius:6px; margin-left:4px; border:0; cursor:pointer; }

/* Upload dropzone */
#tpm-drop { min-height: 120px; display:flex; align-items:center; justify-content:center; flex-direction:column; }

/* Grid for topics */
#training-topics-container { display:grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap:18px; align-items:stretch; }

/* Inline players */
#training-page .tp-player video, #training-page .tp-player audio { width:100%; border-radius:12px; background:#0b1020; outline:none; box-shadow: 0 6px 16px rgba(2, 6, 23, .12); }
#training-page .tp-player { display:flex; flex-direction:column; gap:6px; margin-top:6px; }

/* Training Topic – Text Blocks refined cards */
#training-topic-page .tb-list { display:flex; flex-direction:column; gap:12px; }
#training-topic-page .tb-card { background:#fff; border:1px solid var(--border-color); border-radius:12px; padding:14px 16px; box-shadow: var(--shadow-sm); transition: box-shadow .15s ease, transform .12s ease; }
#training-topic-page .tb-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
#training-topic-page .tb-head { display:flex; align-items:center; justify-content:space-between; gap:.75rem; }
#training-topic-page .tb-title { margin:0; font-size:1rem; font-weight:700; color:#0f172a; letter-spacing:.2px; }
#training-topic-page .tb-actions { display:flex; gap:.5rem; }
#training-topic-page .tb-body { color:#334155; margin-top:.35rem; white-space:pre-wrap; line-height:1.6; }
#training-topic-page .tb-body p { margin:.4rem 0; }

/* Training Topic – Keywords grid (3 in a row) */
#training-topic-page .kw-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
}
@media (max-width: 991px){
  #training-topic-page .kw-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 639px){
  #training-topic-page .kw-grid { grid-template-columns: 1fr; }
}
#training-topic-page .kw-tile {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: var(--shadow-sm);
}
#training-topic-page .kw-left { display:flex; align-items:center; gap:10px; }
#training-topic-page .kw-dot { width:10px; height:10px; border-radius:999px; background:#2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
#training-topic-page .kw-label { font-weight:600; color:#0f172a; }
#training-topic-page .kw-actions { display:flex; gap:.25rem; }
/* Drag cues */
#training-topic-page .kw-grid .kw-tile { cursor: default; }
#training-topic-page .kw-grid .kw-tile[draggable="true"] { cursor: grab; }
#training-topic-page .kw-grid .kw-tile[draggable="true"]:active { cursor: grabbing; }
#training-topic-page .kw-tile.dragging { opacity: .75; border-color: #c7d2fe; box-shadow: 0 8px 16px rgba(30,64,175,.15); }
#training-topic-page .kw-tile.drag-over { outline: 2px dashed #c7d2fe; outline-offset: 3px; }

/* Gradient header bar */
#training-page .tp-headerbar { height: 56px; border-radius: 12px; background: linear-gradient(135deg,#1e40af,#3b82f6); display:flex; align-items:center; padding:10px 12px; color:#fff; gap:10px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
#training-page .tp-headerbar .tp-title { color:#fff; font-weight:800; letter-spacing:.2px; }

/* Progress ring */
#training-page .tp-ring { width:40px; height:40px; position:relative; flex: 0 0 auto; }
#training-page .tp-ring svg { transform: rotate(-90deg); width:40px; height:40px; }
#training-page .tp-ring .bg { stroke: rgba(255,255,255,.35); stroke-width: 6; fill: none; }
#training-page .tp-ring .fg { stroke: #22c55e; stroke-width: 6; fill: none; stroke-linecap: round; transition: stroke-dashoffset .25s ease; }
#training-page .tp-ring .pct { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:.75rem; font-weight:700; color:#fff; }
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Manager-style KPI tile used on Managers Dashboard; reuse for Contracts Dashboard */
.content-card.kpi {
  background: linear-gradient(135deg, #312e81, #1e40af) !important;
  color:#fff;
  border: none !important;
  box-shadow: 0 8px 20px rgba(30,64,175,.25);
  border-radius: 12px;
  min-height: 140px;
  display:flex; flex-direction:column; justify-content:center;
  padding:1rem;
  position: relative;
  overflow: hidden;
}
.kpi .kpi-title { color:#e2e8f0; font-size:.85rem; letter-spacing:.02em; }
.kpi .kpi-value { color:#fff; font-size:1.75rem; font-weight:700; margin-top:.25rem; }
.kpi .kpi-icon { position:absolute; right:14px; bottom:10px; font-size:38px; color: rgba(255,255,255,.25); }

/* Fallback: if older JS renders stat-card tiles on Contracts page, force gradient look */
#contracts-page .stat-card {
  background: linear-gradient(135deg, #1e40af, #3b82f6) !important;
  color: #fff !important;
  border-color: transparent !important;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --sidebar-width: 280px;
    --header-height: 70px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content h2 {
    font-size: 24px;
    margin-bottom: 8px;
    font-weight: 600;
}

.loading-content p {
    opacity: 0.9;
    font-size: 14px;
}

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

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

/* App Layout */
.app {
    display: flex;
    min-height: 100vh;
}

/* Mobile sidebar overlay to close menu on outside tap */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 900; /* below sidebar (1000) */
    display: none;
}
.sidebar-overlay.show { display: block; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
}

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

/* Close button inside sidebar for mobile */
.sidebar-close-btn {
  display: none; /* visible on mobile only */
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.sidebar-close-btn:hover { background: var(--background-color); color: var(--text-primary); }

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 18px;
    color: var(--primary-color);
}

.logo i {
    font-size: 24px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

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

.sidebar-menu {
    flex: 1;
    padding: 20px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.menu-item:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

.menu-item.active {
    background: var(--background-color);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.menu-item i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

.user-info i {
    font-size: 24px;
}

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

/* Header */
.header {
    height: var(--header-height);
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Content */
.content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.page-header h2 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: var(--surface-color);
    color: var(--text-primary);
}

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

.btn-warning {
    background: var(--warning-color);
    color: white;
}

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

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

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* Cards */
.card {
    background: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

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

.card-body {
    padding: 22px;
}

.card-header h3, .card-header h2 {
    margin: 0;
    font-weight: 700;
    color: var(--text-primary);
}

.card-header .subtext {
    font-size: 12px;
    color: var(--text-secondary);
}

.card-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: var(--background-color);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-flow: row dense; /* pack tiles to avoid gaps */
    gap: 16px;
    align-items: stretch;
    margin-bottom: 30px;
}

/* Manager-style KPI grid utility used across dashboards */
.grid.grid-4 { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap:16px; }
@media (min-width: 1536px) { .grid.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); } }
@media (max-width: 1279px) { .grid.grid-4 { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 991px)  { .grid.grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 639px)  { .grid.grid-4 { grid-template-columns: 1fr; } }

@media (min-width: 1536px) {
    .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1279px) {
    .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

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

.stat-card {
    position: relative;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: #fff;
    padding: 22px 22px 20px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 8px 18px rgba(31, 41, 55, 0.15);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    overflow: hidden;
    min-height: 150px; /* ensure equal visual height */
}

.stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(120px 120px at 90% 85%, rgba(255,255,255,0.16), transparent 60%);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(31, 41, 55, 0.22);
}

.stat-card .kpi-title {
    font-size: 12px;
    letter-spacing: 0.3px;
    opacity: 0.95;
}

.stat-card .kpi-value {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.stat-card .kpi-sub {
    font-size: 12px;
    opacity: 0.9;
}

.stat-card .stat-icon {
    position: absolute;
    right: 10px;
    bottom: 8px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.85);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.stat-content h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-content p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    margin-bottom: 20px;
}

/* Standardized filter bar (used by Call Sheet and Proposals) */
.filter-bar {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

/* Standardized group container cards (manager grouping) */
.group-card {
    background: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 0;
    margin-bottom: 1rem;
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 1rem;
    border: none;
    background: transparent;
    border-radius: 0;
    font-weight: 600;
    color: #1f2937;
}

.group-header h4 {
    margin: 0;
    color: #1f2937;
    font-size: 1rem;
    font-weight: 600;
}

.group-header .meta {
    color: #64748b;
    font-size: .9rem;
}

.group-body {
    display: none;
    padding: 0 1rem 1rem;
}

/* Day header (inside group body) */
.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #334155;
    font-weight: 600;
    margin: .5rem 0 .25rem;
}
.day-header .count {
    color: #94a3b8;
    font-weight: 500;
}

/* Proposal row container (used in manager list items) */
.proposal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.proposal-row .title { font-weight: 600; color: #1e293b; }
.proposal-row .meta { color: #64748b; font-size: .9rem; display: flex; align-items: center; gap: .5rem; }

/* Utility min-width helpers */
.min-220 { min-width: 220px; }
.min-180 { min-width: 180px; }
.min-160 { min-width: 160px; }

/* Ensure Salesperson filter on Proposals is visible by default; JS hides for sales users */
#proposals-filters #pr-user-filter-wrap { display: block !important; }

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

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s ease;
    background: var(--surface-color);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
}

.modal {
    background: var(--surface-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay:not(.hidden) .modal {
    transform: scale(1);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

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

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Contract View modal: ensure meta items have visible labels on light background */
.modal .meta-item {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-primary);
}
.modal .meta-item strong { color: var(--text-primary); }
.modal .meta-item a { color: var(--primary-color); }

/* SLA Sections Modal */
#sla-sections-modal { padding: 0 8px; }
#sla-sections-modal input[type="text"],
#sla-sections-modal textarea { width: 100%; }
#sla-sections-modal #sla-section-editor { position: relative; z-index: 5; }
#sla-sections-modal #sla-sections-list { position: relative; z-index: 1; max-height: 65vh; overflow: auto; }

/* EasyMDE layout fixes inside SLA modal */
#sla-sections-modal .EasyMDEContainer {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
#sla-sections-modal .EasyMDEContainer .editor-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
}
#sla-sections-modal .EasyMDEContainer .CodeMirror,
#sla-sections-modal .EasyMDEContainer .CodeMirror-scroll { min-height: 280px; }

/* SLA list card look */
#sla-sections-list .sla-item {
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: #fff;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 0;
}
#sla-sections-list .sla-item .drag-handle { color: #94a3b8; }

/* Buttons inside modal tighter line-height to avoid clipping */
#sla-sections-modal .btn { line-height: 1; }
#sla-sections-modal .btn.btn-secondary { background: #f1f5f9; }

/* Make SLA modal wider and use grid for two-column layout */
#sla-sections-modal > div { width: 1024px !important; max-width: 96vw !important; }
#sla-sections-modal > div > div[style*="display:flex"][style*="overflow:auto"] {
  display: grid !important;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 16px !important;
}
#sla-sections-modal > div > div[style*="display:flex"][style*="overflow:auto"] > div:first-child {
  min-width: 320px !important;
}
#sla-sections-modal > div > div[style*="display:flex"][style*="overflow:auto"] > div:last-child {
  min-width: 420px !important;
  overflow: visible !important;
}

/* Keep modal header visible while scrolling */
#sla-sections-modal > div > div:first-child { position: sticky; top: 0; z-index: 10; background: #fff; }

/* Inputs spacing in editor */
#sla-section-editor .form-group { margin-bottom: 12px; }
#sla-editor-title { height: 40px; }

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast-icon {
    font-size: 18px;
}

.toast.success .toast-icon {
    color: var(--success-color);
}

.toast.warning .toast-icon {
    color: var(--warning-color);
}

.toast.error .toast-icon {
    color: var(--danger-color);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 500;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Modal overlay hard overrides to ensure visibility across pages */
.modal-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0,0,0,0.5) !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 99999 !important;
  visibility: visible !important;
  opacity: 1 !important;
}
.modal-overlay:not(.hidden) {
  display: flex !important;
}
.modal-content {
  background: #fff !important;
  border-radius: 8px !important;
  max-width: 720px !important;
  width: 92% !important;
  max-height: 90vh !important;
  overflow-y: auto !important;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1) !important;
  position: relative !important;
  z-index: 100000 !important;
}
.modal-content .modal-header { 
  border-bottom: 1px solid #e5e7eb; 
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-content .modal-body { 
  padding: 16px 20px; 
}
.btn-icon { 
  cursor: pointer; 
  padding: 4px 8px;
  border: none;
  background: none;
  border-radius: 4px;
  transition: background-color 0.2s;
}
.btn-icon:hover {
  background-color: #f1f5f9;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .content {
        padding: 20px;
    }
    
    .modal {
        margin: 20px;
        width: calc(100% - 40px);
    }
    .sidebar-close-btn { display: inline-flex; align-items: center; justify-content: center; }
    /* Ensure overlay is only relevant on mobile */
    .sidebar-overlay { display: none; }
    .sidebar.open + .sidebar-overlay,
    .sidebar-overlay.show { display: block; }
}

@media (max-width: 480px) {
    .header {
        padding: 0 15px;
    }
    
    .content {
        padding: 15px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}



/* Proposal Builder Styles */
/* Single column layout: services at the top full width, preview below */
.proposal-builder {
    position: relative;
    display: grid;
    grid-template-columns: 1fr; /* stack vertically */
    gap: 24px;
    align-items: stretch;
    height: auto;
    background: transparent;
    z-index: auto;
}

/* Left column */
.proposal-builder .builder-panel {
    min-width: 0; /* allow content to shrink without overflow */
}

/* Preview: no sticky; occupy full width below services */
.proposal-builder .preview-panel {
    position: static;
    top: auto;
    align-self: stretch;
    overflow-x: hidden; /* prevent horizontal scrollbars */
    width: 100%;
    max-width: 100%;
}

/* Constrain document width so there is no horizontal scroll */
.proposal-document {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}
.proposal-document img,
.proposal-document table {
    max-width: 100%;
}

.proposal-document pre,
.proposal-document code {
    white-space: pre-wrap;
    word-break: break-word;
}

.section-content-preview table {
    display: block;
    width: 100%;
    overflow-x: auto;
}

.builder-header {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.builder-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.builder-title h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.proposal-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    text-transform: capitalize;
}

.builder-actions {
    display: flex;
    gap: 10px;
}

.builder-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.builder-sidebar {
    width: 250px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.builder-sections {
    padding: 20px 0;
}

.section-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.section-item:hover {
    background: var(--background-color);
}

.section-item.active {
    background: var(--background-color);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.section-item i {
    width: 20px;
    text-align: center;
}

.builder-main {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.builder-preview {
    width: 400px;
    background: var(--surface-color);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

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

.preview-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.preview-controls {
    display: flex;
    gap: 5px;
}

.preview-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: white;
}

.preview-content.tablet {
    max-width: 768px;
    margin: 0 auto;
}

.preview-content.mobile {
    max-width: 375px;
    margin: 0 auto;
}

/* Form Sections */
.form-section {
    max-width: 800px;
}

.form-section h3 {
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

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

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

/* Client Section */
.client-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.client-card {
    background: var(--background-color);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.client-card h4 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.client-card p {
    margin-bottom: 8px;
    font-size: 14px;
}

.client-logo-section h4 {
    margin-bottom: 15px;
}

.current-logo {
    margin-top: 15px;
    text-align: center;
}

.current-logo img {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 10px;
}

/* Services Section */
.services-builder {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.services-catalog {
    max-height: 600px;
    overflow-y: auto;
}

.service-category {
    margin-bottom: 25px;
}

.service-category h5 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-weight: 600;
}

.service-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.service-item {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: all 0.2s ease;
}

.service-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.service-info {
    flex: 1;
}

.service-info h6 {
    margin-bottom: 5px;
    font-weight: 600;
}

.service-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.service-pricing {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
}

.service-pricing span {
    color: var(--text-secondary);
}

.selected-services {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    max-height: 600px;
    overflow-y: auto;
}

.proposal-items {
    margin-bottom: 20px;
}

.proposal-item {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 15px;
}

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

.item-header h6 {
    margin: 0;
    font-weight: 600;
}

.item-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.item-controls {
    display: flex;
    gap: 10px;
}

.item-controls .form-group {
    margin-bottom: 0;
}

.item-controls .form-input {
    width: 80px;
    padding: 6px 10px;
    font-size: 13px;
}

.item-pricing {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.price-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.pricing-summary-content {
    background: var(--primary-color);
    color: white;
    padding: 15px;
    border-radius: var(--radius);
}

.pricing-summary-content h5 {
    margin-bottom: 15px;
    color: white;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.summary-row.total {
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    padding-top: 8px;
    margin-top: 10px;
    font-weight: 600;
    font-size: 16px;
}

.summary-row .amount {
    font-weight: 600;
}

/* Proposal Preview */
.proposal-preview {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: #333;
}

/* Inline client-name token styling (bold, without block behavior) */
.token-client-name { font-weight: 600; }

/* Cover page preview layout */
.cover-page {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border-radius: 14px;
    padding: 24px 24px 16px;
}

.cover-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.cover-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.brand-text h1 { font-size: 22px; margin: 0; }
.brand-text .brand-website { opacity: 0.9; font-size: 12px; }

.cover-content { margin-top: 14px; }
.cover-title { font-size: 24px; font-weight: 800; margin: 0 0 6px; }
.cover-subtitle { opacity: 0.95; margin-bottom: 12px; }

/* Centered meta blocks */
.cover-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    align-items: stretch;
    justify-content: center;
}

.cover-meta::before,
.cover-meta::after {
    content: '';
}

.meta-item {
    background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 1px 2px rgba(0,0,0,0.08);
}

.meta-item span { display: block; font-size: 12px; opacity: 0.9; margin-bottom: 6px; }
.meta-item strong { font-size: 14px; color: #fff; }

/* Signature area preview */
.signature-area {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.signature-box {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}

.signature-box .sig-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.signature-box .sig-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    font-size: 14px;
}

.signature-box .sig-line {
    height: 1px;
    background: var(--border-color);
}

/* Proposal & Contract section preview heading spacing and content typography */
.proposal-section-preview,
.contract-section {
    margin: 18px 0 28px;
}
.proposal-section-preview > h2,
.contract-section > h3 {
    color: var(--primary-color);
    margin: 18px 0 10px;
}
.section-content-preview h1,
.section-content-preview h2,
.section-content-preview h3,
.section-content-preview h4,
.section-content-preview h5,
.section-content-preview h6,
.section-content h1,
.section-content h2,
.section-content h3,
.section-content h4,
.section-content h5,
.section-content h6 {
    margin-top: 14px;
    margin-bottom: 6px;
    line-height: 1.3;
    color: var(--text-primary);
}
.section-content-preview p,
.section-content p {
    margin: 0 0 12px;
}
.section-content-preview ul,
.section-content-preview ol,
.section-content ul,
.section-content ol {
    margin: 0 0 12px 20px;
}

/* Table of Contents styles (supports nested subheadings) */
.table-of-contents {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0 24px;
}
.table-of-contents h2 {
    margin: 0 0 10px;
    color: var(--text-primary);
}
.table-of-contents ul {
    list-style: none;
    padding-left: 0;
}
.table-of-contents li {
    margin: 6px 0;
}
.table-of-contents li ul {
    margin-top: 4px;
    margin-left: 18px;
}
.table-of-contents a {
    color: var(--primary-color);
    text-decoration: none;
}
.table-of-contents a:hover {
    text-decoration: underline;
}

/* Contract Builder: show only top-level TOC entries (hide any right-side extras) */
.table-of-contents li > ul {
    display: none !important; /* hide nested subheadings */
}
.table-of-contents li ul {
    display: none !important; /* hide any nested ul */
}
.table-of-contents li li {
    display: none !important; /* hide any nested list items */
}
.table-of-contents li:not(:first-child) a:not(:first-child) {
    display: none !important; /* hide secondary anchors */
}
.table-of-contents li span {
    display: none !important; /* hide any span elements */
}
.table-of-contents li div {
    display: none !important; /* hide any div elements */
}
/* Force only the first anchor in each li to show */
.table-of-contents li > a:nth-child(n+2) {
    display: none !important;
}

/* Pseudo subheadings: paragraphs that begin with bold text */
.section-content-preview p.pseudo-heading,
.section-content p.pseudo-heading {
    margin-top: 14px;
}
.section-content-preview p.pseudo-heading > strong:first-child,
.section-content p.pseudo-heading > strong:first-child {
    display: inline-block;
    width: 100%;
    margin-bottom: 4px;
}

.proposal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
}

.company-info {
    display: flex;
    gap: 20px;
    align-items: center;
}

.company-logo {
    max-width: 120px;
    max-height: 60px;
}

.company-details h1 {
    margin-bottom: 5px;
    color: var(--primary-color);
    font-size: 24px;
}

.company-details p {
    margin-bottom: 2px;
    font-size: 14px;
    color: var(--text-secondary);
}

.client-logo img {
    max-width: 100px;
    max-height: 50px;
}

.proposal-title {
    margin-bottom: 30px;
}

.proposal-title h2 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 28px;
}

.proposal-meta p {
    margin-bottom: 5px;
    font-size: 14px;
    color: var(--text-secondary);
}

.client-section {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--background-color);
    border-radius: var(--radius);
}

.client-section h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.client-details h4 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.client-details p {
    margin-bottom: 5px;
    font-size: 14px;
}

.executive-summary {
    margin-bottom: 30px;
}

.executive-summary h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.services-section {
    margin-bottom: 30px;
}

.services-section h3 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

.services-table table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.services-table th,
.services-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.services-table th {
    background: var(--background-color);
    font-weight: 600;
    color: var(--text-primary);
}

.services-table td strong {
    color: var(--text-primary);
}

.services-table td small {
    color: var(--text-secondary);
}

/* Costing table (Slide-style) */
.costing-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 16px 0 24px;
    table-layout: fixed;
}

.costing-table thead th {
    background: var(--primary-color);
    color: #fff;
    font-weight: 700;
    text-transform: none;
    padding: 14px 16px;
    border: 1px solid var(--primary-color);
}

.costing-table thead th.desc-col { text-align: left; }
.costing-table thead th.qty-col { text-align: center; }
.costing-table thead th.total-col { text-align: center; }

/* Once-off costing table uses 4 columns: desc, qty, setup, total */
.costing-table.onceoff thead th.desc-col { width: 52%; }
.costing-table.onceoff thead th.qty-col { width: 12%; }
.costing-table.onceoff thead th.setup-col { width: 18%; text-align: center; }
.costing-table.onceoff thead th.total-col { width: 18%; }

/* Column widths to match slide layout */
.costing-table thead th.desc-col { width: 62%; }
.costing-table thead th.qty-col { width: 18%; }
.costing-table thead th.total-col { width: 20%; }

/* Category blocks */
.costing-category { margin-top: 20px; }
.costing-category-title {
    margin: 0 0 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 6px;
}
.costing-table.costing-summary { margin-top: 12px; }

.costing-table th:first-child { border-top-left-radius: 8px; }
.costing-table th:last-child { border-top-right-radius: 8px; }

.costing-table td {
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    vertical-align: top;
    background: #fff;
}

.costing-table td:first-child { overflow-wrap: anywhere; }

.costing-table td .desc-title {
    font-weight: 600;
    color: var(--text-primary);
}

.costing-table td .desc-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.costing-table td .desc-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.costing-table .muted {
    font-weight: 500;
    opacity: 0.9;
}

.costing-table .qty { text-align: center; vertical-align: middle; }
.costing-table .amount { text-align: right; font-weight: 600; }

.costing-table .qty .svc-qty {
    width: 90px;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-align: center;
    background: var(--surface-color);
}

.costing-table .total-row td {
    font-weight: 700;
    background: var(--primary-color);
    color: #fff;
}

.costing-table .subtotal-row td {
    font-weight: 600;
    background: var(--primary-color);
    color: #fff;
}

.costing-table .vat-row td {
    font-weight: 500;
    background: var(--primary-color);
    color: #fff;
}

.costing-table .total-row .label {
    font-size: 18px;
    letter-spacing: 0.2px;
}

.costing-table .total-row .amount {
    font-size: 18px;
}

.discount {
    color: var(--success-color);
    font-weight: 500;
}

.pricing-summary-preview {
    background: var(--background-color);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

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

.summary-table td {
    padding: 8px 0;
    border: none;
}

.summary-table .amount {
    text-align: right;
    font-weight: 600;
}

.summary-table .total-row {
    border-top: 2px solid var(--primary-color);
    padding-top: 12px;
}

.summary-table .total-row td {
    font-size: 18px;
    color: var(--primary-color);
}

.additional-notes {
    margin-bottom: 30px;
}

.additional-notes h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

/* Terms Section */
.terms-content .help-text {
    margin-top: 15px;
    padding: 10px;
    background: var(--background-color);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-secondary);
}

.terms-content .help-text i {
    margin-right: 8px;
    color: var(--primary-color);
}

/* File Upload in Builder */
.file-upload {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: all 0.2s ease;
}

.file-upload:hover,
.file-upload.drag-over {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.upload-area {
    cursor: pointer;
    position: relative;
}

.upload-content {
    pointer-events: none;
}

.upload-content i {
    font-size: 32px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.upload-content h4 {
    margin-bottom: 5px;
    color: var(--text-primary);
}

.upload-content p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.upload-area input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-files {
    margin-top: 15px;
}

.upload-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: var(--background-color);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

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

.file-details {
    display: flex;
    flex-direction: column;
}

.file-name {
    font-weight: 500;
    font-size: 14px;
}

.file-size {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Responsive Design for Builder */
@media (max-width: 1200px) {
    .builder-preview {
        width: 350px;
    }
    
    .services-builder {
        grid-template-columns: 1fr;
    }
    
    .client-info {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .proposal-builder {
        position: relative;
        height: auto;
        min-height: 100vh;
    }
    
    .builder-content {
        flex-direction: column;
    }
    
    .builder-sidebar {
        width: 100%;
        order: 2;
    }
    
    .builder-main {
        order: 1;
        padding: 20px;
    }
    
    .builder-preview {
        width: 100%;
        order: 3;
    }
    
    .builder-header {
        padding: 15px 20px;
    }
    
    .builder-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .item-details {
        grid-template-columns: 1fr;
    }
    
    .proposal-header {
        flex-direction: column;
        gap: 20px;
    }
    
    .company-info {
        flex-direction: column;
        text-align: center;
    }
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-draft {
    background: #fef3c7;
    color: #92400e;
}

.badge-sent {
    background: #dbeafe;
    color: #1e40af;
}

.badge-approved {
    background: #d1fae5;
    color: #065f46;
}

.badge-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-secondary {
    background: var(--secondary-color);
    color: white;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 5px;
}

.action-buttons .btn {
    padding: 6px 8px;
    font-size: 12px;
}

/* Text Utilities */
.text-success {
    color: var(--success-color);
}

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

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

/* SLA Builder & Contracts Styling */
.builder-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

/* Contract Builder: show preview below the edit panel by using a single column */
#contract-builder-page .builder-container {
    grid-template-columns: 1fr;
}

.sla-edit-panel, .sla-preview-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.section-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    background: var(--surface-color);
    transition: all 0.2s ease;
}

.section-item.selected {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

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

.section-content {
    padding: 1rem;
}

.section-type-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.section-type-badge.sla {
    background: #dbeafe;
    color: #1e40af;
}

.section-type-badge.terms {
    background: #f3e8ff;
    color: #7c3aed;
}

.section-type-badge.service_level {
    background: #dcfce7;
    color: #166534;
}

.section-type-badge.penalty {
    background: #fef3c7;
    color: #92400e;
}

.section-type-badge.escalation {
    background: #fee2e2;
    color: #dc2626;
}

.required-badge {
    background: var(--danger-color);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    margin-left: 0.5rem;
}

.contracts-admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.contracts-admin-badge.active {
    background: #dcfce7;
    color: #166534;
}

.contracts-admin-badge.inactive {
    background: #f1f5f9;
    color: #64748b;
}

.role-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.role-badge.role-admin {
    background: #fef3c7;
    color: #92400e;
}

.role-badge.role-manager {
    background: #dbeafe;
    color: #1e40af;
}

.role-badge.role-sales {
    background: #dcfce7;
    color: #166534;
}

.contract-info {
    background: var(--background-color);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-color);
}

.sla-document {
    font-family: 'Georgia', serif;
    line-height: 1.8;
}

.sla-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.sla-header h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.generated-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.sla-section {
    margin-bottom: 2rem;
}

.sla-section h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.btn-icon {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--background-color);
    font-weight: 600;
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: var(--background-color);
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.active {
    background: #dcfce7;
    color: #166534;
}

.status-badge.inactive {
    background: #fee2e2;
    color: #dc2626;
}

@media (max-width: 768px) {
    .builder-container {
        grid-template-columns: 1fr;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Collapsible cards */
.collapsible-card .collapsible-body {
    max-height: 9999px;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease, margin 0.2s ease, padding 0.2s ease;
    opacity: 1;
    margin-top: 8px;
}
.collapsible-card.collapsed .collapsible-body {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
.collapsible-card .collapsible-toggle {
    line-height: 1;
}
.collapsible-card .collapsible-toggle i {
    transition: transform 0.2s ease;
}
.collapsible-card.collapsed .collapsible-toggle i.fa-chevron-up {
    transform: rotate(180deg);
}

/* Contract Pricing Table */
.contract-section .pricing-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 12px;
    font-size: 14px;
}
.contract-section .pricing-table thead th {
    background: var(--background-color);
    color: var(--text-primary);
    text-align: left;
    border: 1px solid var(--border-color);
    padding: 10px 12px;
}
.contract-section .pricing-table td {
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    vertical-align: top;
}
.contract-section .pricing-table td.num,
.contract-section .pricing-table th.num {
    text-align: right;
    white-space: nowrap;
}
.contract-section .pricing-table tbody tr:nth-child(odd) td {
    background: #fafbff;
}

.contract-section .pricing-summary {
    margin-top: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.contract-section .pricing-summary .summary-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    background: #fff;
}
.contract-section .pricing-summary .summary-row:first-child {
    border-top: none;
}
.contract-section .pricing-summary .summary-row.total {
    background: var(--primary-color);
    color: #fff;
    font-weight: 600;
}
.contract-section .pricing-summary .summary-row .amount { font-weight: 600; }

/* Contract Preview Typography: blue headings, black body text */
#contract-preview-content {
    color: #000;
    text-align: left;
    line-height: 1.55;
}
#contract-preview-content h1,
#contract-preview-content h2,
#contract-preview-content h3,
#contract-preview-content h4,
#contract-preview-content h5,
#contract-preview-content h6 {
    color: var(--primary-color);
    margin-top: 16px;
    margin-bottom: 8px;
}
#contract-preview-content p,
#contract-preview-content li,
#contract-preview-content td,
#contract-preview-content th,
#contract-preview-content div,
#contract-preview-content span {
    color: #000;
}

#contract-preview-content p { margin: 10px 0; }
#contract-preview-content ul,
#contract-preview-content ol { margin: 8px 0 12px 20px; }
#contract-preview-content li { margin: 4px 0; }

/* Tables and totals in preview */
#contract-preview-content table { width: 100%; border-collapse: collapse; }
#contract-preview-content .pricing-table { margin-top: 8px; margin-bottom: 14px; }
#contract-preview-content .pricing-summary { margin-top: 12px; }
