/*
 * SaaS styling layer.
 *
 * Loaded after the purchased theme, so it restyles existing markup rather than
 * replacing it -- no theme file is edited and every page picks up the change.
 * Colours stay in the theme's indigo family (#4454c3) so nothing clashes.
 *
 * Scope note: overrides are deliberately shallow and class-based. Anything that
 * needs new structure (KPI cards, status pills, report tables) uses its own
 * `s-` prefixed classes so it cannot collide with the theme.
 */

:root {
    --s-primary: #4454c3;
    --s-primary-dark: #3544a8;
    --s-primary-soft: #eef0fb;
    --s-ink: #1b2559;
    --s-muted: #7987a1;
    --s-line: #e9ecf5;
    --s-bg: #f5f6fa;
    --s-card: #ffffff;

    --s-success: #16b37f;
    --s-success-soft: #e6f7f1;
    --s-warn: #f5a524;
    --s-warn-soft: #fdf3e2;
    --s-danger: #e5484d;
    --s-danger-soft: #fdeaea;
    --s-info: #3b9df7;
    --s-info-soft: #e8f3fe;

    --s-radius: 12px;
    --s-shadow: 0 1px 2px rgba(27, 37, 89, .04), 0 8px 24px rgba(27, 37, 89, .06);
    --s-shadow-sm: 0 1px 2px rgba(27, 37, 89, .06);
}

body {
    background: var(--s-bg);
    color: var(--s-ink);
    -webkit-font-smoothing: antialiased;
}

/* ---------- Cards ---------------------------------------------------- */

.card {
    border: 1px solid var(--s-line);
    border-radius: var(--s-radius);
    box-shadow: var(--s-shadow);
    transition: box-shadow .18s ease, transform .18s ease;
}

.card-body {
    padding: 1.25rem 1.35rem;
}

/* ---------- Page header ---------------------------------------------- */

.page-header {
    margin-bottom: 1.1rem;
    padding-bottom: .35rem;
}

.page-title {
    font-weight: 700;
    letter-spacing: -.015em;
    color: var(--s-ink);
}

.s-page-sub {
    color: var(--s-muted);
    font-size: .845rem;
    margin-top: .15rem;
}

/* ---------- KPI cards ------------------------------------------------- */

.s-kpi {
    display: block;
    position: relative;
    overflow: hidden;
    height: 100%;
    padding: 1.05rem 1.15rem;
    background: var(--s-card);
    border: 1px solid var(--s-line);
    border-radius: var(--s-radius);
    box-shadow: var(--s-shadow-sm);
    color: inherit;
    transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}

a.s-kpi:hover {
    text-decoration: none;
    color: inherit;
    transform: translateY(-2px);
    border-color: #d7dcf0;
    box-shadow: var(--s-shadow);
}

/* Accent rail down the left edge, tinted per card. */
.s-kpi::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--s-kpi-accent, var(--s-primary));
}

.s-kpi-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .55rem;
}

.s-kpi-label {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--s-muted);
    line-height: 1.3;
}

.s-kpi-icon {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    font-size: .95rem;
    background: var(--s-kpi-soft, var(--s-primary-soft));
    color: var(--s-kpi-accent, var(--s-primary));
}

.s-kpi-value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -.02em;
    color: var(--s-ink);
}

.s-kpi-foot {
    margin-top: .4rem;
    font-size: .76rem;
    color: var(--s-muted);
}

/* Accent variants */
.s-kpi--primary { --s-kpi-accent: var(--s-primary); --s-kpi-soft: var(--s-primary-soft); }
.s-kpi--success { --s-kpi-accent: var(--s-success); --s-kpi-soft: var(--s-success-soft); }
.s-kpi--warn    { --s-kpi-accent: var(--s-warn);    --s-kpi-soft: var(--s-warn-soft); }
.s-kpi--danger  { --s-kpi-accent: var(--s-danger);  --s-kpi-soft: var(--s-danger-soft); }
.s-kpi--info    { --s-kpi-accent: var(--s-info);    --s-kpi-soft: var(--s-info-soft); }

/* ---------- Tables ---------------------------------------------------- */

.table-responsive {
    border-radius: 10px;
}

.table {
    color: var(--s-ink);
    margin-bottom: 0;
}

.table thead th,
.table th.border-bottom-0 {
    background: #fafbfe;
    border-bottom: 1px solid var(--s-line) !important;
    border-top: 0 !important;
    color: var(--s-muted);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .055em;
    text-transform: uppercase;
    white-space: nowrap;
    padding: .7rem .8rem;
}

.table tbody td {
    border-top: 1px solid var(--s-line);
    padding: .7rem .8rem;
    vertical-align: middle;
    font-size: .86rem;
}

.table tbody tr:hover > td {
    background: #fafbff;
}

.table.table-bordered,
.table.table-bordered td,
.table.table-bordered th {
    border-color: var(--s-line);
}

/* ---------- Status pills ---------------------------------------------- */

.s-pill {
    display: inline-block;
    padding: .22rem .55rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .01em;
    line-height: 1.4;
    white-space: nowrap;
    background: var(--s-primary-soft);
    color: var(--s-primary-dark);
}

.s-pill--success { background: var(--s-success-soft); color: #0d7a56; }
.s-pill--warn    { background: var(--s-warn-soft);    color: #9a6410; }
.s-pill--danger  { background: var(--s-danger-soft);  color: #b02a2e; }
.s-pill--info    { background: var(--s-info-soft);    color: #1f6fbf; }
.s-pill--muted   { background: #eef0f5;               color: #5c6880; }

/* ---------- Buttons --------------------------------------------------- */

.btn {
    border-radius: 8px;
    font-weight: 600;
    font-size: .82rem;
    padding: .42rem .85rem;
    transition: filter .15s ease, box-shadow .15s ease, transform .15s ease;
}

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

.btn:focus, .btn:active:focus {
    box-shadow: 0 0 0 3px rgba(68, 84, 195, .18);
}

/* The action column packs several icon buttons per row: keep them compact. */
.table td .btn {
    padding: .3rem .55rem;
    font-size: .78rem;
}

/* ---------- List toolbar (search + export) ---------------------------- */

.s-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.s-search {
    position: relative;
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
}

.s-search .form-control {
    border-radius: 8px;
    border: 1px solid var(--s-line);
    background: #fff;
    font-size: .86rem;
    height: auto;
    padding: .45rem .7rem .45rem 2rem;
    min-width: 240px;
}

.s-search .form-control:focus {
    border-color: var(--s-primary);
    box-shadow: 0 0 0 3px rgba(68, 84, 195, .12);
}

.s-search-icon {
    position: absolute;
    left: .68rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--s-muted);
    font-size: .8rem;
    pointer-events: none;
}

/* ---------- Pagination ------------------------------------------------ */

.s-pagefoot {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    padding-top: .9rem;
    border-top: 1px solid var(--s-line);
}

.s-count {
    color: var(--s-muted);
    font-size: .82rem;
}

.s-count strong { color: var(--s-ink); font-weight: 600; }

.pagination { margin: 0; }

.pagination .page-link {
    border: 1px solid var(--s-line);
    color: var(--s-ink);
    border-radius: 8px;
    margin-left: 4px;
    min-width: 34px;
    text-align: center;
    font-size: .82rem;
    font-weight: 600;
    padding: .34rem .55rem;
}

.pagination .page-link:hover {
    background: var(--s-primary-soft);
    border-color: #d7dcf0;
    color: var(--s-primary-dark);
}

.pagination .page-item.active .page-link {
    background: var(--s-primary);
    border-color: var(--s-primary);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: #b6bed0;
    background: #fbfcfe;
}

/* ---------- Report helpers -------------------------------------------- */

.s-report-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: 1.1rem;
}

.s-report-nav a {
    padding: .42rem .8rem;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--s-muted);
    background: #fff;
    border: 1px solid var(--s-line);
    white-space: nowrap;
}

.s-report-nav a:hover {
    text-decoration: none;
    color: var(--s-primary-dark);
    border-color: #d7dcf0;
}

.s-report-nav a.active {
    background: var(--s-primary);
    border-color: var(--s-primary);
    color: #fff;
}

/* Numeric columns read better right-aligned and tabular. */
.s-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

th.s-num { text-align: right; }

/* Inline proportion bar used by the funnel and breakdown reports. */
.s-bar {
    position: relative;
    height: 8px;
    min-width: 60px;
    border-radius: 999px;
    background: #eef0f5;
    overflow: hidden;
}

.s-bar > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--s-bar-color, var(--s-primary));
}

.s-funnel-row td { vertical-align: middle; }

.s-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--s-muted);
}

.s-empty i {
    display: block;
    font-size: 1.8rem;
    margin-bottom: .5rem;
    opacity: .5;
}

/* ---------- Small screens --------------------------------------------- */

@media (max-width: 575.98px) {
    .s-toolbar, .s-pagefoot { justify-content: flex-start; }
    .s-search .form-control { min-width: 0; width: 100%; }
    .s-kpi-value { font-size: 1.4rem; }
}

/* =====================================================================
 * Data table layout
 *
 * `.s-table` replaces the boxed, fully-bordered grid with a row-separated
 * list: the vertical rules are dropped, the header becomes a sticky label
 * strip, and each row gets an identity cell that carries a name plus a
 * quieter second line. Denser to scan, and the eye follows rows instead of
 * being chopped into cells.
 * ===================================================================== */

.s-tablewrap {
    border: 1px solid var(--s-line);
    border-radius: 10px;
    overflow: auto;
    background: #fff;
    max-height: 68vh;
}

.table.s-table {
    margin: 0;
    border: 0;
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

/* Header stays put while the body scrolls. */
.table.s-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fafbfe;
    border: 0 !important;
    border-bottom: 1px solid var(--s-line) !important;
    padding: .68rem .85rem;
    color: var(--s-muted);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table.s-table tbody td {
    border: 0 !important;
    border-bottom: 1px solid #f1f3f9 !important;
    padding: .62rem .85rem;
    vertical-align: middle;
    font-size: .855rem;
}

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

.table.s-table tbody tr { transition: background .12s ease; }

.table.s-table tbody tr:hover > td { background: #f7f9ff; }

/* Row-number column: quiet, fixed width. */
.table.s-table td:first-child,
.table.s-table th:first-child {
    width: 52px;
    color: var(--s-muted);
    font-variant-numeric: tabular-nums;
    font-size: .78rem;
}

/* Identity cell: strong first line, muted second. */
.s-cell {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
}

.s-avatar {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .02em;
    background: var(--s-primary-soft);
    color: var(--s-primary-dark);
    text-transform: uppercase;
}

.s-avatar--muted { background: #eef0f5; color: #5c6880; }

.s-cell-main { min-width: 0; }

.s-cell-title {
    font-weight: 600;
    color: var(--s-ink);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.s-cell-sub {
    font-size: .755rem;
    color: var(--s-muted);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Actions: ghost icon buttons that only colour up on hover. */
.s-actions {
    display: flex;
    gap: .3rem;
    justify-content: flex-end;
    white-space: nowrap;
}

.table.s-table td.s-actions-cell,
.table.s-table th.s-actions-cell { text-align: right; width: 1%; }

.s-iconbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--s-line);
    border-radius: 8px;
    background: #fff;
    color: var(--s-muted);
    font-size: .78rem;
    line-height: 1;
    cursor: pointer;
    transition: background .14s ease, color .14s ease, border-color .14s ease;
}

.s-iconbtn:hover,
.s-iconbtn:focus {
    text-decoration: none;
    background: var(--s-primary-soft);
    border-color: #d2d8f3;
    color: var(--s-primary-dark);
}

.s-iconbtn--danger:hover,
.s-iconbtn--danger:focus {
    background: var(--s-danger-soft);
    border-color: #f4c9ca;
    color: #b02a2e;
}

.s-iconbtn--success:hover,
.s-iconbtn--success:focus {
    background: var(--s-success-soft);
    border-color: #bfe9da;
    color: #0d7a56;
}

/* Below ~760px a wide grid stops working: turn each row into a stacked
   card and use the header text (via data-label) as the field name. */
@media (max-width: 760px) {
    .s-tablewrap { max-height: none; border: 0; background: transparent; }

    .table.s-table thead { display: none; }

    .table.s-table, .table.s-table tbody, .table.s-table tr, .table.s-table td { display: block; width: 100%; }

    .table.s-table tbody tr {
        background: #fff;
        border: 1px solid var(--s-line);
        border-radius: 10px;
        margin-bottom: .6rem;
        padding: .3rem .1rem;
        box-shadow: var(--s-shadow-sm);
    }

    .table.s-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        border-bottom: 0 !important;
        padding: .38rem .85rem;
    }

    .table.s-table tbody td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: .66rem;
        font-weight: 700;
        letter-spacing: .06em;
        text-transform: uppercase;
        color: var(--s-muted);
    }

    .table.s-table td:first-child { display: none; }

    .table.s-table td.s-actions-cell { justify-content: flex-end; padding-top: .5rem; }
    .s-actions { justify-content: flex-end; width: 100%; }
}

/* =====================================================================
 * Sidebar -- light rail
 *
 * White to match the Scrapify logo lockup, separated from the page by a
 * hairline rather than a colour change. Navy text (the logo's wordmark
 * colour) with indigo reserved for the active item, so the accent means
 * "you are here" instead of being decoration.
 *
 * Selectors are prefixed with `body.app` to outrank the theme, which sets
 * `.slide a { color: #576482 !important }`.
 * ===================================================================== */

body.app .app-sidebar,
body.app .app-sidebar.app-sidebar2,
body.app aside.app-sidebar.app-sidebar3 {
    background-color: #ffffff !important;
    border-right: 1px solid var(--s-line) !important;
    box-shadow: none !important;
}

body.app .app-sidebar__logo {
    background-color: #ffffff !important;
    border-bottom: 1px solid var(--s-line) !important;
    padding: .85rem 1.1rem !important;
}

.side-menu { padding: .7rem .55rem 2rem !important; }

/* Top-level rows ------------------------------------------------------ */

body.app .app-sidebar a.side-menu__item {
    display: flex;
    align-items: center;
    margin: 2px 0;
    padding: .58rem .7rem !important;
    border-radius: 9px;
    color: #5b6683 !important;
    font-size: .855rem;
    font-weight: 500;
    border-left: 0 !important;
    background: transparent !important;
    transition: background .16s ease, color .16s ease;
}

body.app .app-sidebar a.side-menu__item:hover,
body.app .app-sidebar a.side-menu__item:focus {
    background: #f4f5fb !important;
    color: var(--s-ink) !important;
}

.app-sidebar .side-menu__icon {
    width: 19px;
    height: 19px;
    margin-right: .7rem;
    color: inherit !important;
    fill: none !important;
    opacity: .75;
}

.app-sidebar .side-menu__label { color: inherit !important; }

.app-sidebar .side-menu__item .angle {
    margin-left: auto;
    font-size: .76rem;
    opacity: .45;
    transition: transform .18s ease;
}

.app-sidebar .slide.is-open > .side-menu__item .angle { transform: rotate(90deg); }

/* Active page --------------------------------------------------------- */

body.app .app-sidebar a.side-menu__item.active {
    background: var(--s-primary) !important;
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(68, 84, 195, .28);
}

body.app .app-sidebar a.side-menu__item.active .side-menu__icon { opacity: 1; }

/* Parent of the current page: marked, but quietly. */
body.app .app-sidebar .slide.has-active > a.side-menu__item {
    background: var(--s-primary-soft) !important;
    color: var(--s-primary-dark) !important;
    font-weight: 600;
}

/* Submenus ------------------------------------------------------------ */

.app-sidebar .slide-menu {
    margin: 2px 0 6px 1.4rem !important;
    padding-left: .75rem !important;
    border-left: 1px solid var(--s-line);
}

body.app .app-sidebar a.sub-side-menu__item {
    display: block;
    position: relative;
    padding: .38rem .6rem !important;
    margin: 1px 0;
    border-radius: 7px;
    color: #79839e !important;
    font-size: .805rem;
    font-weight: 500;
    background: transparent !important;
    transition: background .16s ease, color .16s ease;
}

body.app .app-sidebar a.sub-side-menu__item:hover,
body.app .app-sidebar a.sub-side-menu__item:focus {
    background: #f4f5fb !important;
    color: var(--s-ink) !important;
}

body.app .app-sidebar a.sub-side-menu__item.active {
    background: var(--s-primary-soft) !important;
    color: var(--s-primary-dark) !important;
    font-weight: 600;
}

/* Dot marking the active sub-item against the connector line. */
body.app .app-sidebar a.sub-side-menu__item.active::before {
    content: "";
    position: absolute;
    left: -1.1rem;
    top: 50%;
    width: 6px;
    height: 6px;
    margin-top: -3px;
    border-radius: 50%;
    background: var(--s-primary);
    box-shadow: 0 0 0 3px rgba(68, 84, 195, .18);
}

.app-sidebar .sub-side-menu__label { color: inherit !important; }

/* The theme flips active sub-items to a white pill; keep our own treatment. */
body.app .app-sidebar .slide-menu a.active,
body.app .app-sidebar .slide-item.active,
body.app .app-sidebar .slide-item:hover,
body.app .app-sidebar .slide-item:focus {
    background: var(--s-primary-soft) !important;
    color: var(--s-primary-dark) !important;
}

.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: #dfe3ef; border-radius: 99px; }
.app-sidebar::-webkit-scrollbar-track { background: transparent; }

/* =====================================================================
 * Dashboard tile container
 *
 * The theme's `.dashcolor * { color: #fff !important }` was painting the
 * KPI figures white on a white card, so the numbers rendered invisible.
 * ===================================================================== */

.dashcolor .s-kpi,
.dashcolor .s-kpi * { color: var(--s-ink) !important; }

.dashcolor .s-kpi .s-kpi-label,
.dashcolor .s-kpi .s-kpi-foot { color: var(--s-muted) !important; }

.dashcolor .s-kpi .s-kpi-value { color: var(--s-ink) !important; }

.dashcolor .s-kpi .s-kpi-icon,
.dashcolor .s-kpi .s-kpi-icon * { color: var(--s-kpi-accent, var(--s-primary)) !important; }

/* The gradient that used to sit behind the old tiles. */
.dashcolor .card-body { background: none; }
