/* Logout link */
.btn-logout { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 600; cursor: pointer; }

/* Portal Layout */
#portal { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 250px; background: white; border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 0; }
.sidebar .logo { padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.nav-menu { list-style: none; flex-grow: 1; }
.nav-menu li { padding: 15px 20px; cursor: pointer; display: flex; align-items: center; gap: 10px; color: #64748b; transition: 0.2s; }
.nav-menu li:hover, .nav-menu li.active { background: var(--light); color: var(--primary); border-right: 3px solid var(--primary); }

.main-content { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; }
.top-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 30px; background: white; border-bottom: 1px solid var(--border); }
.user-controls { display: flex; align-items: center; gap: 15px; }
.avatar { width: 40px; height: 40px; background: var(--primary); color: white; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-weight: bold; }

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

/* Map / Earth Pro View */
.map-container { height: 100%; width: 100%; border-radius: 10px; overflow: hidden; position: relative; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
#map { height: 100%; width: 100%; z-index: 1; }
.side-panel { position: absolute; top: 20px; right: 20px; width: 300px; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); z-index: 1000; transition: 0.3s; }
.side-panel h3 { margin-bottom: 15px; color: var(--dark); }
.side-panel p { margin-bottom: 10px; font-size: 0.9rem; }
.side-panel hr { margin: 15px 0; border: 0; border-top: 1px solid var(--border); }

/* Tables & Data */
.action-bar { margin-bottom: 20px; display: flex; justify-content: flex-end; }
.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.data-table th, .data-table td { padding: 15px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--light); font-weight: 600; color: var(--dark); }
.badge { padding: 5px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; color: white; }
.badge.green { background: var(--green); }
.badge.yellow { background: var(--yellow); }
.badge.red { background: var(--red); }

/* Financial Cards */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.card { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.card h4 { color: #64748b; margin-bottom: 10px; }
.card .amount { font-size: 2rem; font-weight: bold; color: var(--dark); }
.text-red { color: var(--red) !important; }

/* Utility for doc icons in table */
.doc-icon { color: var(--primary); margin-right: 8px; cursor: pointer; font-size: 1.1rem; }

/* --- Modals & Forms --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    animation: overlayIn 0.2s ease-out;
}
.modal-overlay.hidden { display: none !important; }

.modal-content {
    background: #ffffff;
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(15, 23, 42, 0.06);
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
    from { transform: translateY(16px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 28px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 1;
}
.modal-header h3 { font-size: 1.2rem; font-weight: 700; color: var(--dark); letter-spacing: -0.01em; }

.close-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: #64748b;
    border-radius: 8px;
}
.close-btn:hover { background: #fef2f2; color: var(--red); }

.modal-content form { padding: 24px 28px 0; }

.form-row { display: flex; gap: 16px; margin-bottom: 18px; }
.form-group { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.form-group label { font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: var(--dark); }

.form-group input,
.form-group select {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    width: 100%;
    background: #ffffff;
    color: var(--dark);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input::placeholder { color: #94a3b8; }
.form-group input:hover,
.form-group select:hover { border-color: #94a3b8; }
.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

/* File inputs */
.file-group input[type="file"] {
    padding: 10px;
    background: var(--light);
    border: 1.5px dashed #cbd5e1;
    font-size: 0.85rem;
    color: #64748b;
    cursor: pointer;
}
.file-group input[type="file"]:hover { border-color: var(--primary); background: #eff6ff; }
.file-group input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    color: var(--dark);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.2s;
}
.file-group input[type="file"]::file-selector-button:hover { background: var(--light); border-color: var(--primary); color: var(--primary); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin: 8px -28px 0;
    padding: 16px 28px;
    background: var(--light);
    border-top: 1px solid var(--border);
    border-radius: 0 0 14px 14px;
}
.modal-footer .btn-primary,
.modal-footer .btn-secondary { padding: 10px 20px; font-size: 0.95rem; border-radius: 8px; }
.modal-footer .btn-secondary { border-color: #cbd5e1; }

button:focus-visible,
.close-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (max-width: 560px) {
    .form-row { flex-direction: column; gap: 18px; }
    .modal-header, .modal-content form { padding-left: 20px; padding-right: 20px; }
    .modal-footer { margin-left: -20px; margin-right: -20px; padding-left: 20px; padding-right: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    .modal-overlay, .modal-content { animation: none; }
}
