/* ========== Reset & Base ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* ========== Layout ========== */
.container { max-width: 1400px; margin: 0 auto; }
.header {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}
.header h1 { color: #333; font-size: 2.5em; margin-bottom: 10px; }
.header p { color: #666; font-size: 1.1em; }
.content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

/* ========== Navigation ========== */
.nav { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.nav a {
    padding: 10px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9em;
    transition: transform 0.3s, opacity 0.3s;
}
.nav a:hover { transform: translateY(-2px); }
.nav a.active { opacity: 0.8; box-shadow: 0 0 0 2px white inset; }
.nav a.nav-logout {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

/* ========== Buttons ========== */
.btn {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    margin-right: 5px;
    text-decoration: none;
    display: inline-block;
    font-size: 0.9em;
    transition: background 0.2s, transform 0.2s;
}
.btn:hover { background: #5568d3; transform: translateY(-1px); }
.btn-sm { padding: 6px 12px; font-size: 0.85em; }
.btn-xs { padding: 4px 8px !important; font-size: 0.8em !important; }
.btn-success { background: #27ae60; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: #e74c3c; }
.btn-danger:hover { background: #c0392b; }
.btn-warning { background: #f39c12; }
.btn-warning:hover { background: #e67e22; }
.btn-primary { background: #3498db; }
.btn-primary:hover { background: #2980b9; }
.btn-outline {
    background: transparent;
    border: 1px solid #667eea;
    color: #667eea;
}
.btn-outline:hover { background: #667eea; color: white; }

/* ========== Badges ========== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
}
.badge-active, .badge-success { background: #d4edda; color: #155724; }
.badge-inactive, .badge-error { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-pending { background: #e2e3e5; color: #383d41; }

/* ========== Tables ========== */
table { width: 100%; border-collapse: collapse; margin-top: 15px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #eee; }
th { background: #f8f9fa; font-weight: 600; color: #333; position: sticky; top: 0; }
tr:hover { background: #f8f9fa; }
td code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    word-break: break-all;
}
.table-wrapper { overflow-x: auto; max-height: 600px; overflow-y: auto; }
.table-actions { white-space: nowrap; }

/* ========== Forms ========== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: #333; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}
.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: auto;
    padding: 0;
    margin: 0;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: flex; gap: 15px; }
.form-row .form-group { flex: 1; }
.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }

/* ========== Cards ========== */
.stat-card {
    border-radius: 15px;
    padding: 25px;
    color: white;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}
.stat-card h3 { font-size: 0.9em; opacity: 0.9; margin-bottom: 10px; }
.stat-card .stat-value { font-size: 2.5em; font-weight: bold; }
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* ========== Customer Tree ========== */
.customer-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.customer-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.3s;
}
.customer-header:hover { background: linear-gradient(135deg, #5568d3 0%, #6548a2 100%); }
.toggle-icon { font-size: 12px; transition: transform 0.3s; }
.customer-card.expanded .toggle-icon { transform: rotate(90deg); }
.customer-name { font-weight: bold; font-size: 1.1em; flex: 1; }
.doc-count { font-size: 0.9em; opacity: 0.9; }
.customer-docs { padding: 20px; background: #f8f9fa; }
.docs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}
.doc-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 10px;
    transition: all 0.3s;
}
.doc-item:hover { border-color: #667eea; box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2); }
.doc-header {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.doc-icon { font-size: 1.2em; }
.doc-name { flex: 1; font-weight: 500; }
.doc-details { padding: 0 15px 15px 45px; color: #666; font-size: 0.95em; display: none; }
.doc-details p { margin: 5px 0; }
.customer-actions, .doc-actions { display: flex; gap: 5px; }
.empty-customers, .empty-docs {
    text-align: center; padding: 40px; color: #999; font-size: 1.1em;
}
.empty-docs { padding: 20px; background: white; border-radius: 6px; }

/* ========== Modals ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.2s;
}
.modal.active { display: flex; align-items: center; justify-content: center; }
.modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: slideIn 0.3s;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}
.modal-header h3 { margin: 0; color: #333; }
.modal-close {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #666;
    line-height: 1;
}
.modal-close:hover { color: #000; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ========== Notifications/Toast ========== */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.toast {
    padding: 14px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideInRight 0.3s;
    min-width: 280px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.toast-success { background: #27ae60; }
.toast-error { background: #e74c3c; }
.toast-warning { background: #f39c12; }
.toast-info { background: #3498db; }
.toast .toast-close { cursor: pointer; margin-left: 10px; opacity: 0.8; }
.toast .toast-close:hover { opacity: 1; }

@keyframes slideInRight { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ========== Pagination ========== */
.pagination { display: flex; gap: 5px; align-items: center; margin-top: 20px; justify-content: center; }
.pagination a, .pagination span {
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: all 0.2s;
}
.pagination a:hover { background: #667eea; color: white; border-color: #667eea; }
.pagination .active { background: #667eea; color: white; border-color: #667eea; }
.pagination .disabled { opacity: 0.5; pointer-events: none; }

/* ========== Search/Filter ========== */
.search-box {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    width: 300px;
    font-size: 14px;
    transition: border-color 0.3s;
}
.search-box:focus { outline: none; border-color: #667eea; }
.filter-bar {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

/* ========== Inline Edit ========== */
.inline-edit { display: flex; gap: 8px; align-items: center; }
.inline-edit input {
    padding: 6px 10px;
    border: 1px solid #667eea;
    border-radius: 4px;
    font-size: 14px;
    flex: 1;
}
.edit-trigger { cursor: pointer; opacity: 0.6; transition: opacity 0.2s; }
.edit-trigger:hover { opacity: 1; }

/* ========== Tabs ========== */
.tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 2px solid #e0e0e0; }
.tab {
    padding: 12px 24px;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.tab:hover { color: #667eea; }
.tab.active { color: #667eea; border-bottom-color: #667eea; }
a.tab { text-decoration: none; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== Log Items ========== */
.log-item {
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.88em;
    border-left: 4px solid #ddd;
    background: #f8f9fa;
}
.log-item.error { border-left-color: #e74c3c; background: #fdf0f0; }
.log-item.warning { border-left-color: #f39c12; background: #fef9e7; }
.log-item.success { border-left-color: #27ae60; background: #eafaf1; }
.log-item.info { border-left-color: #3498db; background: #ebf5fb; }

/* ========== Utilities ========== */
.empty { text-align: center; padding: 40px; color: #999; }
.text-muted { color: #999; }
.truncate { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hidden { display: none !important; }
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.page-header h2 { color: #333; margin: 0; }
.masked { color: #999; letter-spacing: 2px; }
.expandable { cursor: pointer; }
.expandable:hover { color: #667eea; }
.detail-row { background: #f8f9fa; }
.detail-row td { padding: 15px 12px; }
.checkbox-cell { width: 40px; text-align: center; }

/* ========== Carrier Cards ========== */
.carrier-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.carrier-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.3s;
}
.carrier-header:hover { background: linear-gradient(135deg, #1a252f 0%, #2980b9 100%); }
.carrier-card.expanded .carrier-toggle { transform: rotate(90deg); }
.carrier-toggle { font-size: 12px; transition: transform 0.3s; }
.carrier-name { font-weight: bold; font-size: 1.1em; flex: 1; }
.carrier-badge { font-size: 0.85em; opacity: 0.9; background: rgba(255,255,255,0.2); padding: 3px 10px; border-radius: 12px; }
.carrier-actions { display: flex; gap: 8px; }
.carrier-actions .btn { font-size: 0.8em; padding: 4px 10px; }
.carrier-body { padding: 20px; background: #f8f9fa; display: none; }
.carrier-card.expanded .carrier-body { display: block; }
.bubble-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    margin-bottom: 15px;
    align-items: center;
}
.bubble-param {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.bubble-param .label { font-size: 0.8em; color: #999; }
.bubble-param .value { font-weight: 600; color: #333; }
.carrier-rates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.carrier-rates-header h4 { margin: 0; color: #555; }

