
:root {
    --bg-color: #f1f5f9; --card-bg: #ffffff; --text-main: #0f172a; --text-muted: #64748b;
    --border-color: #cbd5e1; --accent: #2563eb; --accent-hover: #1d4ed8;
    --header-gradient: linear-gradient(135deg, #1e3a8a 0%, #312e81 100%);
    --radius-lg: 12px; --radius-md: 8px; --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
* { box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background-color: var(--bg-color); color: var(--text-main); margin: 0; padding: 10px 5px; max-width: 100vw; overflow-x: hidden; }
@media (min-width: 768px) { body { padding: 20px; } }

input, select, textarea { text-transform: uppercase; font-family: inherit; font-size: 16px; padding: 10px; border: 1px solid var(--border-color); border-radius: var(--radius-md); width: 100%; background-color: #f8fafc; color: #0f172a; box-sizing: border-box; }
@media (min-width: 768px) { input, select, textarea { font-size: 14px; } }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background-color: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }

.alert { text-align: center !important; max-width: 1000px; margin: 15px auto !important; padding: 15px; border-radius: var(--radius-md); font-weight: 700; display: block; width: 100%;}
.alert.success { background-color: #d1fae5; color: #065f46; border: 1px solid #10b981; }
.alert.error { background-color: #fee2e2; color: #991b1b; border: 1px solid #ef4444; }

.top-nav { background: var(--header-gradient); color: #fff; padding: 15px; display: flex; flex-direction: column; gap: 12px; border-radius: var(--radius-md); margin-bottom: 15px; box-shadow: var(--shadow); position: sticky; top: 5px; z-index: 100; min-width: 0; }
@media (min-width: 768px) { .top-nav { flex-direction: row; align-items: center; justify-content: space-between; padding: 15px 25px; border-radius: var(--radius-lg); top: 10px;} }
.top-nav-brand { display: flex; align-items: center; gap: 15px; justify-content: space-between; width: 100%; }
@media (min-width: 768px) { .top-nav-brand { width: auto; } }
.top-nav h3 { margin: 0; font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 8px; }

.search-bar { display: flex; width: 100%; min-width: 0; }
@media (min-width: 768px) { .search-bar { width: 320px; } }
.search-bar input { background: #fff; border: none; border-radius: var(--radius-md) 0 0 var(--radius-md); color: #000; }
.search-bar .btn { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.nav-buttons { display: flex; gap: 8px; width: 100%; overflow-x: auto; padding-bottom: 5px; -webkit-overflow-scrolling: touch; }
@media (min-width: 768px) { .nav-buttons { width: auto; padding-bottom: 0; overflow-x: visible; } }

.btn { padding: 10px 14px; border: none; border-radius: var(--radius-md); cursor: pointer; font-weight: 700; text-transform: uppercase; color: white; transition: all 0.2s; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; text-decoration: none; }
.btn-primary { background: var(--accent); } .btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: #ef4444; } .btn-danger:hover { background: #dc2626; }
.btn-success { background: #10b981; } .btn-success:hover { background: #059669; }
.btn-secondary { background: rgba(255,255,255,0.2); backdrop-filter: blur(4px); } .btn-secondary:hover { background: rgba(255,255,255,0.3); }
.btn-dark { background: #475569; } .btn-dark:hover { background: #334155; }
.btn-warning { background: #f59e0b; color:#fff;} .btn-warning:hover { background: #d97706; }
.btn-cancel { background: #94a3b8; } .btn-cancel:hover { background: #64748b; }

.app-layout { display: grid; grid-template-columns: 1fr; gap: 15px; min-width: 0; width: 100%; }
@media (min-width: 1024px) { .app-layout { grid-template-columns: 2fr 1fr; gap: 20px; } }
.main-column, .side-column { min-width: 0; }

.dashboard-stack { display: flex; flex-direction: column; gap: 15px; width: 100%; }

.card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-md); box-shadow: var(--shadow); margin-bottom: 15px; border-top: 4px solid #cbd5e1; min-width: 0; overflow: hidden; }
@media (min-width: 768px) { .card { border-radius: var(--radius-lg); margin-bottom: 20px; } }
.card-header { background: #f8fafc; padding: 12px 15px; font-weight: 800; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px; }
.card-body { padding: 15px; width: 100%; min-width: 0; overflow-x: hidden; }

/* Dashboard Business Analytics UI */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 15px; width: 100%; }
@media (min-width: 768px) { .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 15px; } }
@media (min-width: 1024px) { .stats-grid { grid-template-columns: repeat(6, 1fr); gap: 15px; } }
.stat-card { background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 15px; text-align: center; box-shadow: var(--shadow); cursor: default;}
.stat-card h5 { margin: 0; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card h2 { margin: 5px 0 0 0; font-size: 24px; color: var(--text-main); font-weight: 800; }
.stat-card.clickable { cursor: pointer; transition: 0.2s; border-color: var(--accent); }
.stat-card.clickable:hover { background: #eff6ff; transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.stat-card.clickable h2 { color: var(--accent); }

.alerts-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 15px; width: 100%; }
@media (min-width: 768px) { .alerts-grid { grid-template-columns: repeat(3, 1fr); gap: 15px; } }
.alert-card { background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 15px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow); cursor: pointer; transition: 0.2s; }
.alert-card:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.alert-card.red { border-left: 5px solid #ef4444; } .alert-card.red:hover { background: #fef2f2; }
.alert-card.yellow { border-left: 5px solid #f59e0b; } .alert-card.yellow:hover { background: #fffbeb; }
.alert-card.green { border-left: 5px solid #10b981; } .alert-card.green:hover { background: #ecfdf5; }
.alert-card h4 { margin: 0; font-size: 13px; color: var(--text-main); text-transform: uppercase; }
.alert-card h2 { margin: 0; font-size: 20px; font-weight: 800; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 10px; min-width: 0; }
@media (min-width: 600px) { .grid-2 { grid-template-columns: 1fr 1fr; gap: 15px; } }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 10px; min-width: 0; }
@media (min-width: 600px) { .grid-3 { grid-template-columns: 1fr 1fr 1fr; gap: 15px; } }

.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; min-width: 0; }
.form-group label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.full-width { grid-column: 1 / -1; }

.table-responsive { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border-color); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th { text-align: left; padding: 10px; font-size: 11px; color: var(--text-muted); background: #f8fafc; border-bottom: 2px solid var(--border-color); text-transform: uppercase; }
td { padding: 8px; border-bottom: 1px solid #f1f5f9; }

.modal-overlay { display: none; position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(15,23,42,0.8); z-index: 1000; justify-content: center; align-items: center; backdrop-filter: blur(4px); padding: 10px; }
.modal-content { background: white; width:100%; max-width: 1000px; max-height: 85vh; border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.modal-body { padding: 10px; overflow-y: auto; background: #f1f5f9; }
.modal-card { background: #fff; border-radius: var(--radius-md); padding: 12px; margin-bottom: 10px; border: 1px solid #e2e8f0; cursor: pointer; transition: 0.2s;}
.modal-card:hover { border-color: var(--accent); background: #eff6ff; }
.close-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: #64748b; }

/* Dashboard Calendar Specifics (MOBILE RESPONSIVE FIXES) */
.calendar-wrapper { width: 100%; overflow: hidden; padding-bottom: 5px; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-top: 10px; width: 100%; }
@media (min-width: 768px) { .calendar-grid { gap: 5px; } }

.calendar-day-header { text-align: center; font-weight: 800; font-size: 10px; color: var(--text-muted); background: #e2e8f0; padding: 4px 0; border-radius: 4px; text-transform: uppercase;}
@media (min-width: 768px) { .calendar-day-header { font-size: 12px; padding: 5px; } }

.calendar-cell { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border-color); border-radius: 4px; min-height: 60px; padding: 4px; position: relative; min-width: 0; }
@media (min-width: 768px) { .calendar-cell { min-height: 100px; padding: 6px; } }
.calendar-cell.empty { background: transparent; border: none; }

.cal-date-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 5px; }
.calendar-date { font-weight: 700; font-size: 12px; color: var(--text-muted); }
@media (min-width: 768px) { .calendar-date { font-size: 14px; } }

.cal-add-note { cursor: pointer; color: #cbd5e1; font-size: 14px; padding: 2px 4px; border-radius: 4px; transition: 0.2s; }
.calendar-cell:hover .cal-add-note { color: var(--accent); background: #eff6ff; }

/* Compact Badges Matrix for Mobile Fit */
.badge-wrapper { position: absolute; bottom: 2px; right: 2px; left: 2px; display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
@media (min-width: 768px) { .badge-wrapper { bottom: 4px; right: 4px; left: 4px; gap: 4px; } }

.calendar-badge, .calendar-note-badge { color: white; border-radius: 4px; padding: 2px 4px; font-size: 10px; font-weight: 800; cursor: pointer; box-shadow: var(--shadow); transition: 0.2s; z-index: 10; display:flex; align-items:center; gap:2px;}
@media (min-width: 768px) { .calendar-badge, .calendar-note-badge { padding: 2px 6px; font-size: 11px; gap:4px; } }

.calendar-badge:hover, .calendar-note-badge:hover { transform: scale(1.05); }
.calendar-badge.open { background: var(--accent); }
.calendar-badge.closed { background: #10b981; }
.calendar-badge.past { background: #94a3b8; color: #fff; }
.calendar-badge.overdue { background: #ef4444; color: #fff; } /* The RED Grab Attention Class */

.calendar-note-badge { background-color: #f59e0b; }
.calendar-note-badge.has-overdue { background-color: #ef4444; }

/* Notes List Modal Display */
.notes-list-item { background: #fff; padding: 12px; border: 1px solid var(--border-color); border-radius: var(--radius-md); margin-bottom: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 2px rgba(0,0,0,0.05); transition:0.2s;}
.notes-list-item:hover { border-color: #f59e0b; background: #fffbeb; }
.notes-list-item.completed { opacity: 0.6; text-decoration: line-through; background: #f8fafc;}

.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-nav h2 { margin: 0; font-size: 16px; }
@media (min-width: 768px) { .cal-nav h2 { font-size: 18px; } }

.open-claim-item { background: #fff; border-left: 4px solid var(--accent); padding: 12px; margin-bottom: 10px; border-radius: var(--radius-md); box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center; cursor: pointer;}
.open-claim-item:hover { background: #f8fafc; }

/* Expanded Modals inputs inside tables */
#schedule-table input, #schedule-table select { padding: 6px; font-size: 12px; min-width: 90px; }

.ko-footer { text-align: center; padding: 30px; font-size: 12px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.5px; margin-top:20px; }

/* Upload Progress Bar */
.upload-progress-wrapper { width: 100%; background: #e2e8f0; border-radius: 4px; overflow: hidden; margin-top: 5px; display: none; }
.upload-progress-bar { height: 6px; background: var(--accent); width: 0%; transition: width 0.2s; }

/* ==========================================
   PRINT ENGINE CSS
   ========================================== */
#print-view { display: none; background: white; color: black; font-family: 'Inter', sans-serif; font-size: 10px; line-height: 1.2; width: 800px; max-width: 100%; margin: 0 auto; padding: 20px;}
.p-header { display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 5px; margin-bottom: 10px; }
.p-header h2 { margin: 0; font-size: 18px; font-weight: 800; }
.p-blocks-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.p-card-box { border: 1px solid #000; padding: 8px; }
.p-card-box h4 { margin: -8px -8px 6px -8px; background: #eaeaea; padding: 4px 8px; font-size: 10px; border-bottom: 1px solid #000; text-transform: uppercase; font-weight: 700; }
.p-row-inline { display: flex; margin-bottom: 3px; }
.p-row-inline strong { width: 110px; display: inline-block; white-space: nowrap; font-size: 9px; text-transform: uppercase;}
.p-row-val { flex-grow: 1; border-bottom: 1px solid #bbb; min-height: 14px; word-break: break-all; }
.p-print-table { width: 100%; border-collapse: collapse; margin-top: 5px; margin-bottom: 10px; }
.p-print-table th { background: #eaeaea; border: 1px solid #000; padding: 4px; font-size: 9px; text-transform: uppercase; }
.p-print-table td { border: 1px solid #000; padding: 4px; height: 18px; min-height: 18px; }
.p-print-foot-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 15px; margin-top: 10px; align-items: start; }
.p-print-totals-box { border: 1px solid #000; padding: 8px; background: #fafafa; }
.p-print-totals-box div { display: flex; justify-content: space-between; margin-bottom: 3px; font-size: 9px; }
.p-print-totals-box .p-bold { font-weight: 800; border-top: 1px solid #000; padding-top: 4px; margin-top: 4px; font-size: 11px; }
.p-print-sigs-layout { display: flex; justify-content: space-between; margin-top: 15px; gap: 15px; }
.p-sig-block-element { width: 48%; text-align: center; font-size: 9px; }
.p-sig-canvas-line { border-bottom: 1px solid #000; height: 40px; display: flex; align-items: flex-end; justify-content: center; position: relative; margin-bottom: 4px;}
.p-sig-image-render { max-height: 38px; max-width: 100%; position: absolute; bottom: 0; }

body.pdf-mode { background: #fff !important; padding: 0 !important; margin: 0 !important;}
body.pdf-mode .no-print, body.pdf-mode form { display: none !important; }
body.pdf-mode #print-view { display: block !important; }

@media print {
    body { background: white; margin: 0; padding: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .no-print, .top-nav, .alert, form, .app-layout, .dash-layout, .modal-overlay, .stats-grid, .alerts-grid, .ko-footer { display: none !important; }
    #print-view { display: block !important; width: 100%; }
    #print-modal-area { display: block !important; width: 100%; font-size: 10px; }
    #print-modal-area h2 { border-bottom: 2px solid #000; padding-bottom: 5px; margin-bottom: 15px;}
    #print-modal-area table { width: 100%; border-collapse: collapse; }
    #print-modal-area th, #print-modal-area td { border: 1px solid #000; padding: 5px; text-align: left; }
}
