:root, html { 
    font-size: 16px !important; 
    --navy: #006A4D; 
    --green: #486581;
    --emerald: #A3E635; 
    --accent: #F4C430;
    --bg: #F8FAFC;
    --white: #FFFFFF;
    --text: #1E293B;
    --muted: #64748B;
    --border: #E2E8F0;
    --shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
    font-family: 'DM Sans', sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    width: 100%;
    font-size: 1rem !important;
    line-height: 1.5;
}

header {
    background: var(--navy);
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    box-shadow: var(--shadow);
}
.header-title { font-family: 'DM Serif Display', serif; font-size: 1.6rem; }
.header-title span { color: var(--emerald); }

.meta-bar {
    background: #E2E8F0;
    padding: 0.5rem 2rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--navy);
    border-bottom: 1px solid var(--border);
}

main { padding: 1.5rem; width: 100%; max-width: 100% !important; }

.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); position: relative; overflow: hidden; border: 1px solid var(--border); }
.stat-card::after { content: ""; position: absolute; top: 0; left: 0; width: 6px; height: 100%; background: var(--navy); }
.stat-label { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 2.2rem; font-weight: 600; color: var(--navy); font-family: 'DM Serif Display', serif; margin: 0.5rem 0; }
.stat-sub { font-size: 0.85rem; color: var(--green); font-weight: 600; }

.control-panel { background: var(--white); padding: 1.2rem; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.5rem; border: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.search-wrapper { flex: 1 1 300px; position: relative; }
.search-wrapper i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-wrapper input { width: 100%; padding: 0.8rem 1rem 0.8rem 2.8rem; border-radius: 12px; border: 1px solid var(--border); background: #F1F5F9; font-size: 0.9rem; }

.filters { display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: center; }
.checkbox-group { display: flex; gap: 0.8rem; background: #F1F5F9; padding: 0.6rem 1rem; border-radius: 10px; border: 1px solid var(--border); }
.checkbox-group label { font-size: 0.8rem; font-weight: 600; display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
select { padding: 0.6rem 0.8rem; border-radius: 10px; border: 1px solid var(--border); background: white; cursor: pointer; min-width: 150px; font-family: inherit; font-size: 0.85rem; }

.table-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--border); }
.table-scroll { overflow-x: auto; width: 100%; }
table { width: 100%; min-width: 1700px; border-collapse: collapse; font-size: 0.88rem; table-layout: fixed; }

th:nth-child(1), td:nth-child(1) { width: 50px; }
th:nth-child(2), td:nth-child(2) { width: 100px; }
th:nth-child(3), td:nth-child(3) { width: 85px; }
th:nth-child(4), td:nth-child(4) { width: 220px; }
th:nth-child(5), td:nth-child(5) { width: 160px; }
th:nth-child(6), td:nth-child(6) { width: 120px; }
th:nth-child(7), td:nth-child(7) { width: 160px; }
th:nth-child(8), td:nth-child(8) { width: 90px; }
th:nth-child(9), td:nth-child(9) { width: 110px; }
th:nth-child(10), td:nth-child(10) { width: 65px; }
th:nth-child(11), td:nth-child(11) { width: 70px; }
th:nth-child(12), td:nth-child(12) { width: 100px; }
th:nth-child(13), td:nth-child(13) { width: 140px; }
th:nth-child(14), td:nth-child(14) { width: 180px; }
th:nth-child(15), td:nth-child(15) { width: 50px; }

thead th { background: #F1F5F9; padding: 1.2rem 1rem; text-align: left; font-weight: 700; color: var(--muted); text-transform: uppercase; font-size: 0.7rem; position: sticky; top: 0; z-index: 10; cursor: pointer; white-space: nowrap; }
thead th i.sort-icon { margin-left: 8px; font-size: 0.7rem; color: var(--muted); vertical-align: middle; }
thead th.active-sort { color: var(--navy); }
thead th.active-sort i.sort-icon { color: var(--navy); opacity: 1; }

tr.heat-inactive { opacity: 0.6; background-color: #F1F5F9 !important; color: #64748B; font-style: italic; }

td { padding: 1rem; border-bottom: 1px solid rgba(0,0,0,0.05); vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
td:nth-child(1), td:nth-child(2), td:nth-child(3), td:nth-child(4), td:nth-child(5), td:nth-child(7), td:nth-child(14) { text-align: left; }

.ally-wrap { display: flex; align-items: center; justify-content: center; gap: 8px; }
.ally-bar { width: 24px; height: 6px; border-radius: 3px; }
.bar-green { background: #166534; }
.bar-yellow { background: #ca8a04; }
.bar-red { background: #dc2626; }

.badge { padding: 0.3rem 0.7rem; border-radius: 6px; font-weight: 800; font-size: 0.7rem; background: var(--navy); color: white; text-transform: uppercase; }
.status-tag { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; background: #E2E8F0; color: #475569; }
.copy-btn { margin-left: 8px; cursor: pointer; color: var(--muted); font-size: 0.8rem; transition: color 0.2s; }
.copy-btn:hover { color: var(--navy); }

.lock-btn { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: 10px; border: none; cursor: pointer; font-family: inherit; font-size: 0.85rem; font-weight: 600; transition: all 0.2s; }
.lock-btn.locked { background: rgba(255,255,255,0.15); color: white; }
.lock-btn.unlocked { background: var(--accent); color: var(--navy); }

.pin-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.7); backdrop-filter: blur(6px); z-index: 2000; display: none; align-items: center; justify-content: center; }
.pin-overlay.active { display: flex; }
.pin-box { background: white; border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 360px; text-align: center; box-shadow: var(--shadow); }

.write-control.disabled { opacity: 0.25; pointer-events: none; filter: grayscale(1); }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.6); backdrop-filter: blur(4px); z-index: 1000; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.active { display: flex; }
.modal { background: white; border-radius: var(--radius); width: 100%; max-width: 800px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 2rem; display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.full-width { grid-column: span 2; }
.form-group label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--muted); margin-bottom: 0.5rem; text-transform: uppercase; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.7rem; border-radius: 8px; border: 1px solid var(--border); font-family: inherit; font-size: 0.9rem; }

.btn { padding: 0.7rem 1.5rem; border-radius: 10px; font-weight: 600; cursor: pointer; border: none; font-size: 0.9rem; transition: 0.2s; display: inline-flex; align-items: center; gap: 0.5rem; }
.btn-primary { background: var(--navy); color: white; }
.btn-accent { background: var(--accent); color: var(--navy); }
.btn-outline { background: white; border: 1px solid var(--border); }

.view-card { max-width: 550px; padding: 2rem; }
.view-header { margin-bottom: 1.5rem; border-bottom: 2px solid var(--border); padding-bottom: 1rem; }
.view-title { font-family: 'DM Serif Display', serif; font-size: 1.8rem; color: var(--navy); }
.view-section { margin-bottom: 1.5rem; }
.view-section-title { font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-bottom: 0.75rem; letter-spacing: 1px; display: flex; align-items: center; gap: 0.5rem; }
.view-section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.view-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.view-item { display: flex; flex-direction: column; }
.view-label { font-size: 0.7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.view-value { font-size: 0.95rem; font-weight: 500; color: var(--text); }
.view-full { grid-column: span 2; }
.view-shell { background: #F1F5F9; padding: 0.6rem; border-radius: 8px; font-family: monospace; font-size: 0.85rem; border: 1px solid var(--border); }

#toast-container { position: fixed; bottom: 2rem; right: 2rem; z-index: 3000; display: flex; flex-direction: column; gap: 0.75rem; pointer-events: none; }
.toast { background: var(--navy); color: white; padding: 1rem 1.5rem; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; font-size: 0.9rem; border-left: 5px solid var(--emerald); animation: toastIn 0.3s ease-out forwards; pointer-events: auto; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.fade-out { animation: toastOut 0.5s ease-in forwards; }
@keyframes toastOut { to { transform: translateX(100%); opacity: 0; } }
