:root {
    --ej-sidebar-top: #111827;
    --ej-sidebar-bottom: #0b1220;
    --ej-sidebar-hover: rgba(255, 255, 255, 0.06);
    --ej-accent: #4f46e5;
    --ej-accent-hover: #4338ca;
    --ej-accent-active: #3730a3;
    --ej-accent-soft: rgba(99, 102, 241, 0.14);
    --ej-accent-glow: #818cf8;
    --ej-bg: #f5f6fb;
    --ej-surface: #ffffff;
    --ej-border: #e6e9f0;
    --ej-text: #0f172a;
    --ej-text-muted: #64748b;
    --ej-radius: 14px;
    --ej-radius-sm: 10px;
    --ej-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --ej-shadow-md: 0 4px 16px rgba(15, 23, 42, 0.07);
    --ej-shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.16);
}

* {
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    margin: 0;
    background-color: var(--ej-bg);
    color: var(--ej-text);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
    border: 2px solid var(--ej-bg);
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ---------- App shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    display: flex;
    flex-direction: column;
    width: 258px;
    flex: 0 0 258px;
    background: linear-gradient(180deg, var(--ej-sidebar-top) 0%, var(--ej-sidebar-bottom) 100%);
    color: #e2e8f0;
    padding: 20px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 20px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand strong {
    display: block;
    font-size: 1rem;
    color: #fff;
    letter-spacing: 0;
}

.sidebar-brand small {
    color: #94a3b8;
    font-size: 0.75rem;
}

.sidebar-logo,
.login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.45);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
}

.sidebar-section {
    color: #64748b;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    padding: 14px 12px 6px;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: var(--ej-radius-sm);
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.sidebar-link:hover {
    background: var(--ej-sidebar-hover);
    color: #fff;
}

.sidebar-link.active {
    background: var(--ej-accent-soft);
    color: #fff;
}

.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: var(--ej-accent-glow);
}

.sidebar-link.active .sidebar-icon {
    color: var(--ej-accent-glow);
    opacity: 1;
}

.sidebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    opacity: 0.8;
    flex: 0 0 20px;
}

.sidebar-icon svg {
    width: 19px;
    height: 19px;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 16px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.sidebar-user strong {
    display: block;
    color: #fff;
    font-size: 0.85rem;
}

.sidebar-user small {
    color: #94a3b8;
    font-size: 0.72rem;
}

.sidebar-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    font-weight: 600;
    flex: 0 0 36px;
}

.app-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---------- Topbar ---------- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--ej-border);
    padding: 14px 24px;
}

.topbar-title {
    font-weight: 600;
    font-size: 1rem;
}

.topbar-meta {
    margin-left: auto;
    color: var(--ej-text-muted);
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.topbar-meta::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.app-content {
    padding: 26px;
    width: 100%;
    /* Icerik ana alanin tamamini kullanir; genis ekranlarda sagda bos gri alan kalmaz.
       Cok genis (>1920) ekranlarda satirlarin asiri uzamasini onlemek icin ust sinir. */
    max-width: 2160px;
    margin: 0 auto;
}

/* ---------- Page header ---------- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 4px;
    letter-spacing: -0.02em;
}

/* ---------- Stat cards ---------- */
.stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 100%;
    background: var(--ej-surface);
    border: 1px solid var(--ej-border);
    border-radius: var(--ej-radius);
    padding: 20px;
    box-shadow: var(--ej-shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--ej-accent);
}

.stat-card-success::before {
    background: #16a34a;
}

.stat-card-danger::before {
    background: #dc2626;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ej-shadow-md);
}

.stat-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--ej-accent-soft);
    color: var(--ej-accent);
}

.stat-card-success .stat-icon {
    background: rgba(22, 163, 74, 0.12);
    color: #16a34a;
}

.stat-card-danger .stat-icon {
    background: rgba(220, 38, 38, 0.12);
    color: #dc2626;
}

.stat-icon svg {
    width: 20px;
    height: 20px;
}

.stat-label {
    color: var(--ej-text-muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-value {
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.03em;
}

.stat-hint {
    color: var(--ej-text-muted);
    font-size: 0.8rem;
}

.stat-hint a {
    color: var(--ej-accent);
    text-decoration: none;
    font-weight: 500;
}

.stat-hint a:hover {
    text-decoration: underline;
}

/* ---------- Panels ---------- */
.panel {
    background: var(--ej-surface);
    border: 1px solid var(--ej-border);
    border-radius: var(--ej-radius);
    box-shadow: var(--ej-shadow-sm);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--ej-border);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.panel-header h3 {
    margin: 0;
}

.panel-body {
    padding: 20px;
}

.rules-list {
    padding-left: 1.2rem;
}

.rules-list li {
    margin-bottom: 0.65rem;
    line-height: 1.5;
    color: var(--ej-text);
}

.rules-list li:last-child {
    margin-bottom: 0;
}

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

/* ---------- Daily success-rate strip ---------- */
.daily-rate-strip {
    display: grid;
    grid-template-columns: repeat(var(--day-count, 7), minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
    padding-top: 12px;
    padding-left: var(--strip-left, 0px);
    padding-right: var(--strip-right, 0px);
    border-top: 1px solid var(--ej-border);
}

.daily-rate-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    min-width: 0;
    padding: 8px 4px;
    border-radius: var(--ej-radius-sm);
    background: #f8fafc;
    border: 1px solid var(--ej-border);
    text-align: center;
}

.daily-rate-strip.is-plain .daily-rate-cell {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 2px 2px 0;
}

.daily-rate-date {
    font-size: 0.72rem;
    color: var(--ej-text-muted);
    font-weight: 500;
}

.daily-rate-value {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.daily-rate-meta {
    font-size: 0.68rem;
    color: var(--ej-text-muted);
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    white-space: nowrap;
}

.daily-rate-platforms {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1px;
    width: 100%;
    max-width: 118px;
    margin-top: 4px;
}

.daily-rate-platform {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 0.68rem;
    color: var(--ej-text-muted);
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.daily-rate-platform-name {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.daily-rate-platform-count {
    font-weight: 500;
    white-space: nowrap;
}

.daily-rate-cell.is-good {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.daily-rate-cell.is-good .daily-rate-value {
    color: #15803d;
}

.daily-rate-cell.is-warn {
    background: #fffbeb;
    border-color: #fde68a;
}

.daily-rate-cell.is-warn .daily-rate-value {
    color: #b45309;
}

.daily-rate-cell.is-bad {
    background: #fef2f2;
    border-color: #fecaca;
}

.daily-rate-cell.is-bad .daily-rate-value {
    color: #b91c1c;
}

.daily-rate-cell.is-empty .daily-rate-value {
    color: #cbd5e1;
}

/* ---------- Platform listing counts ---------- */
.platform-day-heading {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0 6px;
}

.platform-category-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 18px 0 8px;
}

.platform-count-table {
    margin-bottom: 4px;
}

.platform-count-table td,
.platform-count-table th {
    font-variant-numeric: tabular-nums;
    padding: 8px 12px;
}

.platform-count-table tfoot th {
    background: #f8fafc;
}

/* ---------- Empty state ---------- */
.empty-state {
    padding: 48px 20px;
    text-align: center;
    color: var(--ej-text-muted);
}

.empty-state strong {
    display: block;
    color: var(--ej-text);
    margin-bottom: 6px;
    font-size: 1rem;
}

/* ---------- Tables ---------- */
.table {
    margin-bottom: 0;
    color: var(--ej-text);
}

.table thead th {
    background: #f8fafc;
    color: var(--ej-text-muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    border-bottom: 1px solid var(--ej-border);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid #eef1f6;
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table-hover tbody tr {
    transition: background-color 0.12s ease;
}

.table-hover tbody tr:hover {
    background-color: #f7f8fc;
}

.user-row:hover {
    background-color: var(--ej-accent-soft) !important;
}

/* Kullanicilar tablosu: sabit sutunlar icerik kadar, "Vendorlar" bos alani yutar (tam genislikte duzenli gorunum). */
.table-users th,
.table-users td {
    white-space: nowrap;
}

.table-users .col-vendors {
    width: 100%;
    white-space: normal;
}

/* ---------- Worker durum göstergesi ---------- */
.worker-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0.38em 0.75em;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.74rem;
    background: #eef2f7;
    color: #64748b;
    border: 1px solid var(--ej-border);
}

.worker-status .worker-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    flex: 0 0 8px;
}

.worker-status.is-active {
    background: #dcfce7;
    color: #15803d;
    border-color: #bbf7d0;
}

.worker-status.is-active .worker-dot {
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
    animation: worker-pulse 1.4s ease-out infinite;
}

@keyframes worker-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
    70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ---------- Badges (soft pills) ---------- */
.badge {
    border-radius: 999px;
    padding: 0.38em 0.72em;
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.01em;
    line-height: 1.4;
}

.badge.bg-success {
    background-color: #dcfce7 !important;
    color: #15803d !important;
}

.badge.bg-danger {
    background-color: #fee2e2 !important;
    color: #b91c1c !important;
}

.badge.bg-warning {
    background-color: #fef3c7 !important;
    color: #b45309 !important;
}

.badge.bg-secondary {
    background-color: #eef2f7 !important;
    color: #475569 !important;
}

.badge.bg-light {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid var(--ej-border) !important;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--ej-radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.5rem 1rem;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 9px;
}

.btn-primary {
    background-color: var(--ej-accent);
    border-color: var(--ej-accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.28);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--ej-accent-hover);
    border-color: var(--ej-accent-hover);
    color: #fff;
}

.btn-primary:active {
    background-color: var(--ej-accent-active) !important;
    border-color: var(--ej-accent-active) !important;
}

.btn-success {
    background-color: #16a34a;
    border-color: #16a34a;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}

.btn-success:hover,
.btn-success:focus {
    background-color: #15803d;
    border-color: #15803d;
}

.btn-outline-primary {
    color: var(--ej-accent);
    border-color: #c7d2fe;
}

.btn-outline-primary:hover {
    background-color: var(--ej-accent);
    border-color: var(--ej-accent);
    color: #fff;
}

.btn-outline-secondary {
    color: #475569;
    border-color: var(--ej-border);
}

.btn-outline-secondary:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
}

.btn-outline-light {
    border-color: rgba(255, 255, 255, 0.25);
}

/* ---------- Forms ---------- */
.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: #334155;
}

.form-control,
.form-select {
    border-radius: var(--ej-radius-sm);
    border-color: var(--ej-border);
    font-size: 0.9rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ej-accent-glow);
    box-shadow: 0 0 0 3px var(--ej-accent-soft);
}

.form-control-sm,
.form-select-sm {
    border-radius: 9px;
}

/* ---------- Alerts ---------- */
.alert {
    border-radius: var(--ej-radius-sm);
    border: 1px solid transparent;
    font-size: 0.9rem;
}

.alert-success {
    background-color: #dcfce7;
    border-color: #bbf7d0;
    color: #166534;
}

.alert-danger {
    background-color: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

/* ---------- Pager ---------- */
.pagination {
    margin-bottom: 0;
    gap: 4px;
}

.page-link {
    border-radius: 9px !important;
    border-color: var(--ej-border);
    color: #475569;
    font-size: 0.85rem;
    min-width: 36px;
    text-align: center;
}

.page-link:hover {
    background-color: #f1f5f9;
    color: var(--ej-accent);
}

.page-item.active .page-link {
    background-color: var(--ej-accent);
    border-color: var(--ej-accent);
    color: #fff;
}

.error-message {
    max-width: 420px;
    word-break: break-word;
}

/* ---------- Details / inline editors ---------- */
details > summary {
    list-style: none;
    user-select: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

details > summary::before {
    content: "\25B8";
    display: inline-block;
    margin-right: 4px;
    transition: transform 0.15s ease;
    font-size: 0.7em;
}

details[open] > summary::before {
    transform: rotate(90deg);
}

/* ---------- Login ---------- */
.login-body {
    background: radial-gradient(1200px 600px at 20% -10%, #1e2a5a 0%, transparent 60%),
                linear-gradient(135deg, #0b1220 0%, #312e81 100%);
    min-height: 100vh;
}

.login-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--ej-surface);
    border-radius: 20px;
    padding: 36px;
    box-shadow: var(--ej-shadow-lg);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
}

.login-brand h1 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.login-brand p {
    margin: 0;
    color: var(--ej-text-muted);
    font-size: 0.8rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1030;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--ej-shadow-lg);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-content {
        padding: 16px;
    }
}

/* Dosya (Excel) disa aktarma yukleniyor gostergesi */
.export-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(1px);
}

.export-overlay.is-visible {
    display: flex;
}

.export-overlay-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 26px 34px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: var(--ej-shadow-lg);
    min-width: 220px;
}

.export-spinner {
    width: 38px;
    height: 38px;
    border: 4px solid #e2e8f0;
    border-top-color: #16a34a;
    border-radius: 50%;
    animation: export-spin 0.8s linear infinite;
}

.export-overlay-text {
    font-weight: 600;
    color: #1e293b;
}

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