/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #1a3a4a;
    --primary-light: #2a5a6a;
    --accent: #f0a030;
    --accent-hover: #e09020;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #303133;
    --text-light: #606266;
    --text-muted: #909399;
    --border: #e4e7ed;
    --success: #67c23a;
    --warning: #e6a23c;
    --danger: #f56c6c;
    --info: #409eff;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
}

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

/* === Login === */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    width: 64px;
    height: 64px;
    background: var(--primary);
    color: var(--accent);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 16px;
}

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

.login-header .subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    font-family: inherit;
}

.form-group input:focus {
    border-color: var(--info);
    box-shadow: 0 0 0 3px rgba(64,158,255,0.15);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.error-msg {
    background: #fef0f0;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid #fde2e2;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Top Bar === */
.topbar {
    background: var(--primary);
    color: #fff;
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-small {
    width: 36px;
    height: 36px;
    background: var(--accent);
    color: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
}

.topbar h2 {
    font-size: 18px;
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    font-size: 14px;
    opacity: 0.9;
}

.btn-logout {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 6px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.2);
}

/* === Dashboard === */
.dashboard {
    padding: 24px 32px;
    max-width: 1400px;
    margin: 0 auto;
}

/* === Summary Cards === */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-icon svg {
    width: 24px;
    height: 24px;
}

.clients-icon { background: #e8f4fd; color: var(--info); }
.orders-icon { background: #e1f3d8; color: var(--success); }
.products-icon { background: #fdf6ec; color: var(--warning); }
.invoices-icon { background: #fde2e2; color: var(--danger); }

.card-content {
    display: flex;
    flex-direction: column;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

.card-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* === Filter Bar === */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-left input,
.filter-left select {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    background: var(--card-bg);
}

.filter-left input { width: 260px; }
.filter-left select { min-width: 200px; }

.filter-bar-numeric {
    margin-top: -8px;
}

.filter-bar-numeric .filter-left {
    gap: 8px;
}

.numeric-filter {
    display: flex;
    align-items: center;
    gap: 6px;
}

.numeric-filter label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
}

.numeric-filter select {
    padding: 7px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    background: var(--card-bg);
    min-width: auto;
}

.numeric-filter select:focus {
    border-color: var(--info);
}

.numeric-filter select.filter-active {
    border-color: var(--info);
    background: #f0f7ff;
}

.filter-left input:focus,
.filter-left select:focus {
    border-color: var(--info);
}

.filter-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--accent);
    color: var(--primary);
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.btn-secondary:hover {
    background: var(--accent-hover);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Progress === */
.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar {
    width: 200px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--info), var(--success));
    border-radius: 4px;
    transition: width 0.3s;
    width: 0%;
}

.progress-text {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* === Table === */
.table-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

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

th {
    background: var(--primary);
    color: #fff;
    padding: 14px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    user-select: none;
}

th.sortable {
    cursor: pointer;
    transition: background 0.2s;
}

th.sortable:hover {
    background: var(--primary-light);
}

th.num, td.num {
    text-align: right;
}

.sort-icon {
    font-size: 11px;
    margin-left: 4px;
    opacity: 0.5;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

tbody tr {
    transition: background 0.15s;
}

tbody tr:hover {
    background: #f0f7ff;
}

tbody tr:last-child td {
    border-bottom: none;
}

.loading-cell {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 15px;
}

.cell-loading {
    color: var(--text-muted);
    font-style: italic;
    font-size: 12px;
}

.cell-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.cell-zero {
    color: var(--text-muted);
}

.tenant-name {
    font-weight: 600;
    color: var(--text);
}

.manager-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.manager-0 { background: #e8f4fd; color: #1a6fb5; }
.manager-1 { background: #e1f3d8; color: #3d8c1e; }
.manager-2 { background: #fdf6ec; color: #a67c1a; }

/* Footer totals row */
tfoot td {
    background: #f0f2f5;
    padding: 14px 16px;
    border-top: 2px solid var(--border);
    font-size: 14px;
}

tfoot .cell-value {
    font-size: 16px;
}

/* Row number */
.row-num {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}

/* === Responsive === */
@media (max-width: 768px) {
    .dashboard { padding: 16px; }
    .topbar { padding: 0 16px; }
    .filter-left input { width: 100%; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-right { justify-content: flex-end; }
    .filter-bar-numeric .filter-left { flex-wrap: wrap; }
    .numeric-filter { flex: 1 1 45%; min-width: 140px; }
}
