/* ──────────────────────────────────────────────────────────
   UltraStats — Professional Modern Dark Theme Design System
   Design Philosophy: Clean, flat, borderless, single-theme dark.
   Zero purple slop. Zero harsh outlines.
   ────────────────────────────────────────────────────────── */

:root {
    --bg-base: #0a0e17;
    --bg-card: #121824;
    --bg-card-hover: #172030;
    --bg-subtle: #192233;
    --bg-input: #151c2c;
    --bg-pill: #1a2336;
    --bg-pill-active: #25334d;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0a0e17;

    --accent-emerald: #10b981;
    --accent-emerald-subtle: rgba(16, 185, 129, 0.12);
    --accent-cyan: #38bdf8;
    --accent-cyan-subtle: rgba(56, 189, 248, 0.12);
    --accent-amber: #f59e0b;
    --accent-amber-subtle: rgba(245, 158, 11, 0.12);
    --accent-rose: #f43f5e;
    --accent-rose-subtle: rgba(244, 63, 94, 0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-popover: 0 20px 45px -10px rgba(0, 0, 0, 0.7);

    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Typography & Numbers ── */
.num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    letter-spacing: -0.02em;
}

/* ── Layout ── */
.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px 28px 60px;
}

@media (max-width: 768px) {
    .app-container {
        padding: 16px 14px 40px;
    }
}

/* ── Header ── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-badge {
    width: 44px;
    height: 44px;
    background: var(--bg-subtle);
    color: var(--accent-cyan);
    font-weight: 800;
    font-size: 18px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -0.5px;
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.team-pill {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.admin-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-subtle);
    padding: 6px 14px 6px 8px;
    border-radius: 30px;
}

.admin-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-pill-active);
    color: var(--accent-emerald);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    overflow: hidden;
}

.admin-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-info {
    text-align: left;
    line-height: 1.2;
}

.admin-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.admin-id {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-icon {
    background: var(--bg-subtle);
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-pill-active);
    color: var(--text-primary);
}

.btn-logout {
    color: var(--accent-rose);
}

.btn-logout:hover {
    background: var(--accent-rose-subtle);
    color: var(--accent-rose);
}

/* ── Period Selector Toolbar ── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: var(--bg-card);
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
}

.period-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.period-pill {
    background: var(--bg-pill);
    border: none;
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.period-pill:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.period-pill.active {
    background: var(--bg-pill-active);
    color: var(--text-primary);
    font-weight: 600;
}

.custom-range-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.custom-input {
    background: var(--bg-input);
    border: none;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.custom-input:focus {
    background: #1c263c;
}

.btn-apply {
    background: #2563eb;
    border: none;
    color: #ffffff;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-apply:hover {
    background: #1d4ed8;
}

.last-n-select {
    background: var(--bg-input);
    border: none;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

/* ── Navigation Tabs ── */
.nav-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 22px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.tab-btn {
    background: var(--bg-card);
    border: none;
    color: var(--text-secondary);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.tab-btn.active {
    background: #1e293b;
    color: #38bdf8;
    font-weight: 600;
}

/* ── Metrics Grid ── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

.metric-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 22px 20px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.metric-card:hover {
    transform: translateY(-2px);
    background: var(--bg-card-hover);
}

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

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

.metric-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
}

.badge-emerald {
    background: var(--accent-emerald-subtle);
    color: var(--accent-emerald);
}

.badge-cyan {
    background: var(--accent-cyan-subtle);
    color: var(--accent-cyan);
}

.badge-amber {
    background: var(--accent-amber-subtle);
    color: var(--accent-amber);
}

.metric-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.15;
    margin-bottom: 8px;
}

.metric-value .currency {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 4px;
}

.metric-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.metric-footer span strong {
    color: var(--text-secondary);
}

/* ── Content Sections ── */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .dashboard-row {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px 22px;
    box-shadow: var(--shadow-card);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-subtext {
    font-size: 12px;
    color: var(--text-muted);
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 320px;
}

/* ── Breakdown List ── */
.breakdown-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px 22px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
}

.breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
}

.breakdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
}

.breakdown-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.breakdown-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.breakdown-value {
    text-align: right;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Tables ── */
.table-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px 22px;
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
}

.table-responsive {
    overflow-x: auto;
    margin-top: 14px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

th {
    padding: 12px 14px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

th:first-child {
    border-top-left-radius: var(--radius-sm);
    border-bottom-left-radius: var(--radius-sm);
}

th:last-child {
    border-top-right-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
}

td {
    padding: 14px 14px;
    border-bottom: 1px solid #161e2d;
    color: var(--text-secondary);
}

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

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

/* ── Status Badges ── */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
}

.status-active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.status-completed {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
}

.status-cancelled {
    background: rgba(244, 63, 94, 0.15);
    color: #f87171;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Cost Settings Card ── */
.cost-settings-card {
    background: #141c2c;
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
}

.cost-settings-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}

.quick-rate-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0f1523;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    flex-wrap: wrap;
    gap: 14px;
}

.quick-rate-label {
    display: flex;
    flex-direction: column;
}

.quick-rate-label strong {
    font-size: 14px;
    color: #f1f5f9;
}

.quick-rate-label span {
    font-size: 12px;
    color: #64748b;
}

.quick-rate-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.input-with-unit {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.input-with-unit input {
    padding-right: 75px;
}

.unit-text {
    position: absolute;
    right: 12px;
    color: #64748b;
    font-size: 12px;
    pointer-events: none;
}

.detailed-costs-box {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.cost-pack-input {
    background: #0c121e;
    border: none;
    color: #f1f5f9;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    width: 130px;
}

.cost-pack-input:focus {
    background: #172236;
}

/* ── Modal ── */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.open {
    display: flex;
}

.modal-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    padding: 30px 28px;
    box-shadow: var(--shadow-popover);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

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

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    border: none;
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.form-control:focus {
    background: #1d273d;
}

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.btn-secondary {
    background: var(--bg-subtle);
    border: none;
    color: var(--text-secondary);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--bg-pill-active);
    color: var(--text-primary);
}

.btn-primary {
    background: #10b981;
    border: none;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: #059669;
}

.btn-danger-sm {
    background: var(--accent-rose-subtle);
    border: none;
    color: var(--accent-rose);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-danger-sm:hover {
    background: #dc2626;
    color: #ffffff;
}

/* ── Loading Spinner ── */
.loading-overlay {
    display: none;
    position: fixed;
    top: 24px;
    right: 28px;
    background: #1e293b;
    color: #38bdf8;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    z-index: 999;
}

.loading-overlay.active {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spin-icon {
    animation: spin 1s linear infinite;
}

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

/* ── UC Cost & Finance Settings ── */
.cost-settings-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
    border: 1px solid var(--border-subtle);
}

.cost-settings-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}

.cost-settings-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quick-rate-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    background: rgba(255, 255, 255, 0.02);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    margin-bottom: 20px;
}

.quick-rate-label {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.quick-rate-label strong {
    font-size: 14px;
    color: var(--text-primary);
}

.quick-rate-label span {
    font-size: 12px;
    color: var(--text-muted);
}

.quick-rate-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.input-with-unit {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.input-with-unit input.custom-input {
    width: 175px !important;
    min-width: 160px !important;
    padding: 9px 76px 9px 14px !important;
    font-size: 14px;
    font-weight: 700;
    color: #38bdf8;
    background: #0f172a;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    transition: var(--transition);
}

.input-with-unit input.custom-input:focus {
    border-color: #38bdf8;
    outline: none;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.input-with-unit .unit-text {
    position: absolute;
    right: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
    user-select: none;
}

.cost-pack-input {
    width: 140px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--font-mono);
    font-weight: 600;
    background: #0f172a;
    color: #f1f5f9;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    box-sizing: border-box;
    transition: var(--transition);
}

.cost-pack-input:focus {
    border-color: #38bdf8;
    outline: none;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.comm-rate-input {
    width: 80px;
    padding: 6px 10px;
    font-size: 13px;
    font-family: var(--font-mono);
    font-weight: 600;
    background: #0f172a;
    color: #f1f5f9;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    box-sizing: border-box;
    text-align: right;
    transition: var(--transition);
}

.comm-rate-input:focus {
    border-color: #10b981;
    outline: none;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

.detailed-costs-box {
    margin-top: 14px;
}

/* ── Fleet & Search Bar ── */
.table-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 260px;
}

.search-input-wrapper input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: #0f172a;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    transition: var(--transition);
}

.search-input-wrapper input:focus {
    border-color: #38bdf8;
    outline: none;
}

.search-input-wrapper svg {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    pointer-events: none;
}

.status-free {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.status-rented {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

