* {
    box-sizing: border-box;
}

:root {
    --blue-dark: #4353F1;
    --blue: #4f60f5;
    --blue-light: #6b78ff;
    --cyan: #46C7EC;
    --purple: #7B68EE;
    --primary: #4353F1;
    --orange: #ff7628;
    --green: #11B76B;
    --red: #ff5252;
    --bg: #f3f7fd;
    --card: #ffffff;
    --border: #dfe8f3;
    --text: #172638;
    --muted: #6f7f91;
    --soft-blue: #eef2ff;
    --soft-green: #eafaf2;
    --soft-red: #fff1f0;
    --shadow: 0 10px 28px rgba(36, 50, 89, 0.07);
}

body {
    margin: 0;
    font-family: "Inter", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
.orange-btn,
.ghost-btn {
    border: 0;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 12px 17px;
    font-family: inherit;
    transition: 0.2s ease;
}

.orange-btn {
    background: var(--orange);
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 118, 40, 0.18);
}

.orange-btn:hover {
    background: #f26416;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
}

.ghost-btn {
    background: #f1f5fb;
    color: var(--text);
}

label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin: 14px 0 8px;
    color: var(--text);
}

.req {
    color: #e03131;
    font-weight: 800;
    margin-left: 3px;
}

input,
textarea,
select {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(67, 83, 241, 0.08);
}

textarea {
    resize: vertical;
}

.muted {
    color: var(--muted);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #eef4fb, #dfeaf7);
    padding: 24px;
}

.login-shell {
    width: min(1040px, 100%);
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(20, 48, 84, 0.16);
}

.login-brand-panel {
    background: linear-gradient(135deg, #4353F1, #5D6DFF);
    color: #fff;
    padding: 58px;
}

.brand-pill {
    display: inline-flex;
    background: rgba(255,255,255,0.16);
    padding: 9px 14px;
    border-radius: 999px;
    font-weight: 800;
    margin-bottom: 24px;
}

.login-brand-panel h1 {
    font-size: 42px;
    line-height: 1.08;
    margin: 0 0 18px;
}

.login-brand-panel p {
    color: rgba(255,255,255,0.84);
    line-height: 1.7;
}

.login-preview-card {
    display: flex;
    gap: 18px;
    margin-top: 36px;
}

.login-preview-card div {
    background: rgba(255,255,255,0.13);
    padding: 18px;
    border-radius: 16px;
    min-width: 150px;
}

.login-preview-card span {
    display: block;
    opacity: 0.82;
    font-size: 13px;
}

.login-preview-card strong {
    display: block;
    font-size: 26px;
    margin-top: 7px;
}

.login-card {
    background: #fff;
    padding: 52px 42px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-logo {
    width: 205px;
    height: auto;
    margin-bottom: 28px;
}

.login-card h2 {
    margin: 0 0 5px;
    font-size: 28px;
}

.full-btn {
    width: 100%;
    background: var(--orange);
    color: #fff;
    margin-top: 10px;
}

.alert.error {
    background: #fff1f0;
    color: #b42318;
    padding: 12px;
    border-radius: 8px;
    margin: 16px 0;
}

.secure-note {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.admin-app,
.client-app {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 250px;
    background: linear-gradient(180deg, #4353F1, #5D6DFF 55%, #6B78FF);
    color: rgba(255,255,255,0.86);
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 12px 0 32px rgba(67, 83, 241, 0.12);
}

.brand-area {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 22px;
    border-bottom: 1px solid rgba(255,255,255,0.16);
}

.brand-area img {
    max-width: 188px;
    max-height: 46px;
    object-fit: contain;
}

.admin-menu {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.admin-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    color: rgba(255,255,255,0.82);
    border-radius: 12px;
    font-weight: 700;
}

.admin-menu a:hover,
.admin-menu a.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
    text-decoration: none;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}

.admin-sidebar-section {
    margin-top: auto;
    padding: 18px 20px;
    border-top: 1px solid rgba(255,255,255,0.16);
}

.admin-sidebar-section span {
    display: block;
    color: rgba(255,255,255,0.62);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 9px;
}

.admin-sidebar-section a,
.admin-sidebar-section strong {
    color: #fff;
    font-weight: 800;
    word-break: break-all;
}

.admin-main {
    flex: 1;
    min-width: 0;
}

.admin-topbar {
    min-height: 70px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 26px;
    gap: 18px;
}

.admin-topbar h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    color: #172638;
}

.admin-topbar p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.admin-top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-user-pill {
    border: 1px solid var(--border);
    background: #f8fbff;
    padding: 8px 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 9px;
}

.avatar-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--cyan));
}

.admin-content {
    padding: 24px;
    max-width: 1500px;
}

.tabs-row {
    display: flex;
    gap: 38px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 22px;
    overflow-x: auto;
}

.tabs-row a {
    padding: 0 0 14px;
    color: #62748d;
    font-weight: 700;
    position: relative;
    white-space: nowrap;
}

.tabs-row a.active {
    color: var(--primary);
}

.tabs-row a.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    background: var(--primary);
    border-radius: 999px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 16px;
    padding: 20px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
}

.kpi-card strong {
    display: block;
    font-size: 28px;
    color: #263f5f;
    margin-bottom: 7px;
}

.kpi-card span {
    color: #6d7f98;
    font-weight: 700;
}

.trend {
    width: 58px;
    height: 58px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 30px;
    font-weight: 800;
    flex: 0 0 auto;
}

.trend.positive {
    background: #eefcf8;
    color: #11B76B;
}

.trend.neutral {
    background: #f2f6fc;
    color: #9eb0c7;
}

.report-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 20px;
}

.report-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 20px;
    min-width: 0;
    overflow: hidden;
}

.report-card.large {
    min-height: 330px;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.card-head h2 {
    margin: 0;
    font-size: 16px;
    color: #314b6c;
}

.card-head p {
    margin: 5px 0 0;
    color: #92a1b6;
    font-size: 13px;
}

.donut-wrap {
    position: relative;
    max-width: 460px;
    margin: 0 auto;
}

.donut-centre {
    position: absolute;
    left: 50%;
    top: 53%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.donut-centre strong {
    display: block;
    font-size: 24px;
}

.donut-centre span {
    color: var(--muted);
    font-size: 13px;
}

.chart-box {
    position: relative;
    height: 260px;
    width: 100%;
}

.table-wrap {
    overflow-x: auto;
}

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

.admin-table th,
.admin-table td {
    padding: 14px 15px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    background: #f7faff;
    color: #62748d;
    font-size: 13px;
}

.admin-table td span {
    color: var(--muted);
}

.admin-table tbody tr:hover {
    background: #fbfdff;
}

.empty-row {
    text-align: center !important;
    color: var(--muted);
    padding: 38px !important;
}

.mini-progress {
    width: 145px;
    max-width: 100%;
    height: 8px;
    border-radius: 999px;
    background: #e9f0f8;
    overflow: hidden;
    margin-bottom: 6px;
}

.mini-progress span {
    display: block;
    height: 100%;
    background: var(--primary);
}

.pill {
    display: inline-flex;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.pill.done {
    background: #ebf9e3;
    color: #11945a;
}

.pill.progress {
    background: #edf4ff;
    color: #4353F1;
}

.pill.pending {
    background: #fff6e8;
    color: #b96a00;
}

.copy-btn {
    background: #edf4ff;
    color: var(--primary);
    padding: 7px 10px;
    margin-left: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.form-actions.centre {
    justify-content: center;
}

.full-width-panel {
    max-width: 1100px;
}

.search-filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 180px auto auto;
    gap: 10px;
    margin-bottom: 18px;
    align-items: center;
}

.soft-note {
    background: #f4f8ff;
    color: #5b718d;
    border: 1px solid #dbe8f8;
    border-radius: 10px;
    padding: 14px;
    line-height: 1.6;
}

.success-panel {
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
}

.success-panel img {
    width: 220px;
    margin-bottom: 16px;
}

.success-panel input {
    max-width: 780px;
    margin: 14px auto;
}

.client-hero {
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 16px;
    padding: 22px;
    margin-bottom: 20px;
    min-width: 0;
}

.client-hero h2 {
    margin: 0;
    color: #172638;
}

.client-hero p {
    margin: 6px 0 0;
    color: var(--muted);
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    color: var(--primary);
    font-weight: 800;
    margin: 20px 0 9px;
    gap: 10px;
}

.progress-bar {
    height: 14px;
    background: #e9f0f8;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar div {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #4353F1, #46C7EC);
    transition: width 1.2s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar div::after {
    content: "";
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(120deg, rgba(255,255,255,0.12), rgba(255,255,255,0.65), rgba(255,255,255,0.12));
    animation: shine 2s infinite;
}

@keyframes shine {
    0% { left: -50%; }
    100% { left: 120%; }
}

.last-updated {
    color: var(--muted);
    font-size: 13px;
}

.activity-log {
    list-style: none;
    padding: 0;
    margin: 0;
}

.activity-log li {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.activity-dot {
    width: 10px;
    height: 10px;
    margin-top: 5px;
    border-radius: 999px;
    background: var(--primary);
    box-shadow: 0 0 0 5px rgba(67,83,241,0.10);
    flex: 0 0 auto;
}

.activity-log strong {
    display: block;
    font-size: 14px;
}

.activity-log small {
    color: var(--muted);
}

.info-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
}

.info-strip p {
    background: #f7faff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 13px;
    margin: 0;
    min-width: 0;
}

.notice {
    margin-top: 15px;
    background: #fff9e8;
    border: 1px solid #ffe2a6;
    border-radius: 12px;
    padding: 15px;
    color: #965500;
    line-height: 1.7;
}

.pagination {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.pagination a,
.pagination span {
    background: #f7faff;
    border: 1px solid var(--border);
    color: #5d718d;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 800;
}

.pagination a.active,
.pagination a:hover {
    background: var(--primary);
    color: #fff;
    text-decoration: none;
}

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 18px;
}

@media (max-width: 1200px) {
    .kpi-grid,
    .info-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .report-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .admin-sidebar {
        display: none;
    }

    .admin-topbar {
        height: auto;
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-top-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .admin-content {
        padding: 16px;
        max-width: 100%;
    }

    .form-grid,
    .kpi-grid,
    .info-strip,
    .search-filter-bar {
        grid-template-columns: 1fr;
    }

    .tabs-row {
        overflow-x: auto;
        gap: 24px;
    }

    .progress-meta {
        flex-direction: column;
        gap: 6px;
    }

    .report-card.large {
        min-height: auto;
    }

    .chart-box {
        height: 240px;
        max-width: 100%;
        overflow: hidden;
    }

    canvas {
        max-width: 100% !important;
    }
}

@media (max-width: 760px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-brand-panel {
        display: none;
    }

    .login-card {
        padding: 36px 24px;
    }

    .admin-user-pill {
        display: none;
    }

    .kpi-card {
        padding: 16px;
    }

    .kpi-card strong {
        font-size: 24px;
    }

    .trend {
        width: 46px;
        height: 46px;
        font-size: 22px;
    }

    .admin-table th,
    .admin-table td {
        padding: 11px 10px;
        font-size: 13px;
    }
}


/* V4 chart and tracking refinements */
.dashboard-donut-layout {
    display: grid;
    grid-template-columns: minmax(260px, 360px) 1fr;
    align-items: center;
    gap: 24px;
    min-height: 260px;
}

.dashboard-donut-layout .donut-wrap {
    width: 100%;
    max-width: 340px;
    min-height: 260px;
}

.dashboard-donut-layout canvas {
    max-height: 260px !important;
}

.chart-legend-list {
    display: grid;
    gap: 14px;
    align-content: center;
}

.chart-legend-list div {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-weight: 700;
}

.chart-legend-list span {
    width: 13px;
    height: 13px;
    display: inline-block;
    border-radius: 4px;
    flex: 0 0 auto;
}

.chart-legend-list strong {
    color: var(--text);
    min-width: 54px;
}

.progress-days-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 14px 0 18px;
}

.progress-days-summary div {
    background: #f7faff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 13px;
}

.progress-days-summary strong {
    display: block;
    font-size: 24px;
    color: var(--text);
}

.progress-days-summary span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.days-chart-box {
    height: 230px;
}

.client-report .admin-content {
    max-width: none;
    width: 100%;
}

.client-report .report-card {
    width: 100%;
}

.url-truncate {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 100%;
    overflow: hidden;
    word-break: break-all;
    line-height: 1.35;
}

/* Keep Status visible on mobile/tablet backlink view */
.client-report .admin-table {
    table-layout: fixed;
}

.client-report .admin-table th:nth-child(1),
.client-report .admin-table td:nth-child(1) {
    width: 64px;
}

.client-report .admin-table th:nth-child(2),
.client-report .admin-table td:nth-child(2) {
    width: auto;
}

.client-report .admin-table th:nth-child(3),
.client-report .admin-table td:nth-child(3) {
    width: 118px;
}

@media (max-width: 1200px) {
    .dashboard-donut-layout {
        grid-template-columns: 1fr;
    }

    .dashboard-donut-layout .donut-wrap {
        margin: 0 auto;
    }
}

@media (max-width: 900px) {
    .client-report .table-wrap {
        overflow-x: visible;
    }

    .client-report .admin-table th,
    .client-report .admin-table td {
        padding: 10px 8px;
    }

    .client-report .admin-table th:nth-child(1),
    .client-report .admin-table td:nth-child(1) {
        width: 42px;
    }

    .client-report .admin-table th:nth-child(3),
    .client-report .admin-table td:nth-child(3) {
        width: 98px;
    }

    .client-report .pill {
        padding: 6px 8px;
        font-size: 11px;
    }

    .progress-days-summary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .client-report .admin-table th:nth-child(1),
    .client-report .admin-table td:nth-child(1) {
        width: 34px;
    }

    .client-report .admin-table th:nth-child(3),
    .client-report .admin-table td:nth-child(3) {
        width: 86px;
    }

    .url-truncate {
        font-size: 12px;
    }

    .client-report .admin-table th,
    .client-report .admin-table td {
        padding: 9px 5px;
        font-size: 12px;
    }
}


/* V5 layout fixes */
.admin-content {
    max-width: none !important;
    width: 100% !important;
}

.admin-main {
    width: calc(100% - 250px);
}

.report-card,
.client-hero,
.kpi-card {
    max-width: none;
}

.info-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.client-report .info-strip {
    width: 100%;
}

.client-report .report-card .info-strip p {
    width: 100%;
}

/* Desktop: show full URL */
.url-truncate {
    display: inline;
    max-width: none;
    overflow: visible;
    word-break: break-all;
    line-height: 1.4;
}

.url-truncate span {
    display: inline;
}

/* Remove unwanted native arrows/spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: none !important;
}

/* Help box in client sidebar */
.help-box {
    margin: 8px 14px 18px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255,255,255,0.16);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.12);
}

.help-box strong {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
}

.help-box p {
    margin: 0;
    line-height: 1.5;
    font-size: 12px;
    color: rgba(255,255,255,0.82);
}

.help-box a {
    color: #fff;
    font-weight: 800;
    word-break: break-all;
}

/* Mobile menu */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    z-index: 1200;
    top: 14px;
    left: 14px;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 10px 25px rgba(67,83,241,0.25);
    padding: 0;
    font-size: 22px;
}

.mobile-menu-backdrop {
    display: none;
}

@media (min-width: 901px) {
    .admin-sidebar {
        display: flex !important;
        transform: none !important;
    }
}

/* Tablet and mobile */
@media (max-width: 900px) {
    .mobile-menu-toggle {
        display: grid;
        place-items: center;
    }

    .admin-sidebar {
        display: flex !important;
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1100;
        width: 270px;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
    }

    body.mobile-menu-open .admin-sidebar {
        transform: translateX(0);
    }

    .mobile-menu-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.42);
        z-index: 1000;
        display: none;
    }

    body.mobile-menu-open .mobile-menu-backdrop {
        display: block;
    }

    .admin-main {
        width: 100%;
    }

    .admin-topbar {
        padding-left: 68px !important;
    }

    .admin-content {
        width: 100%;
    }

    .info-strip {
        grid-template-columns: 1fr !important;
    }

    /* Mobile/tablet: truncate URLs to 2 lines only */
    .url-truncate {
        display: block;
        max-width: 100%;
        overflow: hidden;
        word-break: break-all;
    }

    .url-truncate span {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

@media (max-width: 520px) {
    .admin-topbar {
        padding-left: 64px !important;
    }

    .mobile-menu-toggle {
        top: 12px;
        left: 10px;
        width: 40px;
        height: 40px;
    }
}
