:root {
    --sw-blue: #0b63ce;
    --sw-blue-600: #0a58bb;
    --sw-blue-700: #084c9d;
    --sw-blue-soft: #eaf3ff;
    --sw-blue-line: #bfd9ff;
    --sw-ink: #151922;
    --sw-ink-2: #263244;
    --sw-muted: #667085;
    --sw-muted-2: #8a94a6;
    --sw-bg: #f5f7fb;
    --sw-surface: #ffffff;
    --sw-surface-2: #f9fbfe;
    --sw-border: #d9e2ef;
    --sw-border-strong: #c7d3e4;
    --sw-success: #14804a;
    --sw-warning: #b7791f;
    --sw-danger: #c93434;
    --sw-info: #0873a5;
    --sidebar-width: 286px;
    --topbar-height: 86px;
    --radius: 8px;
    --font-heading: "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", Arial, sans-serif;
    --font-body: "Inter", "Montserrat", "Poppins", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--sw-ink);
    background: var(--sw-bg);
    font-family: var(--font-body);
    font-size: 14.5px;
    line-height: 1.5;
}

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

a:hover {
    color: var(--sw-blue-700);
}

img {
    max-width: 100%;
}

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

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--sw-surface);
    border-right: 1px solid var(--sw-border);
    box-shadow: 12px 0 32px rgba(21, 25, 34, 0.05);
}

.sidebar-brand {
    min-height: 98px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid var(--sw-border);
}

.logo-link,
.logo-white-wrap,
.print-logo-wrap {
    display: inline-flex;
    align-items: center;
    background: #fff;
}

.brand-logo,
.public-logo,
.login-logo,
.install-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 198px;
    max-height: 62px;
    object-fit: contain;
    background: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 12px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #c8d3e2 transparent;
}

.sidebar-link {
    position: relative;
    min-height: 46px;
    margin-bottom: 5px;
    padding: 11px 12px 11px 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-radius: var(--radius);
    color: #334155;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0;
    transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.35;
    color: #637083;
    flex: 0 0 auto;
}

.sidebar-link:hover {
    background: #f3f7fd;
    color: var(--sw-blue);
    transform: translateX(2px);
}

.sidebar-link.active {
    background: var(--sw-blue-soft);
    color: var(--sw-blue);
}

.sidebar-link.active::before {
    content: "";
    position: absolute;
    inset: 10px auto 10px 0;
    width: 4px;
    border-radius: 999px;
    background: var(--sw-blue);
}

.sidebar-link.active svg,
.sidebar-link:hover svg {
    color: var(--sw-blue);
}

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--sw-border);
    background: #fff;
}

.sidebar-user {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius);
    background: #f7faff;
    border: 1px solid #e7eef8;
}

.sidebar-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--sw-blue);
    font-family: var(--font-heading);
    font-weight: 700;
}

.sidebar-user strong,
.sidebar-user small {
    display: block;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user strong {
    color: var(--sw-ink);
    font-weight: 800;
}

.sidebar-user small {
    color: var(--sw-muted);
    font-size: 12px;
    font-weight: 700;
}

.app-main {
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: var(--topbar-height);
    padding: 15px 26px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--sw-border);
    backdrop-filter: blur(14px);
}

.app-topbar h1,
.auth-title,
.install-title,
.public-title,
.section-title h2,
.metric-value {
    margin: 0;
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: 0;
}

.app-topbar h1 {
    color: var(--sw-ink);
    font-size: clamp(22px, 2vw, 30px);
    line-height: 1.05;
}

.eyebrow {
    margin-bottom: 3px;
    color: var(--sw-blue);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 900;
    letter-spacing: 0;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-content {
    width: 100%;
    flex: 1;
    padding: 26px;
}

.btn {
    min-height: 40px;
    padding: 0.56rem 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
    box-shadow: none;
}

.btn svg {
    width: 17px;
    height: 17px;
    stroke-width: 2.35;
    flex: 0 0 auto;
}

.btn-icon {
    width: 42px;
    min-width: 42px;
    padding: 0;
}

.btn-primary {
    color: #fff;
    background: var(--sw-blue);
    border-color: var(--sw-blue);
}

.btn-primary:hover,
.btn-primary:focus {
    color: #fff;
    background: var(--sw-blue-700);
    border-color: var(--sw-blue-700);
}

.btn-outline-primary {
    color: var(--sw-blue);
    background: #fff;
    border-color: var(--sw-blue-line);
}

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

.btn-light {
    color: #344054;
    background: #fff;
    border-color: var(--sw-border);
}

.btn-light:hover {
    color: var(--sw-blue);
    background: #f5f9ff;
    border-color: var(--sw-blue-line);
}

.btn-success {
    background: var(--sw-success);
    border-color: var(--sw-success);
}

.btn-danger {
    background: var(--sw-danger);
    border-color: var(--sw-danger);
}

.dropdown-menu {
    border: 1px solid var(--sw-border);
    border-radius: var(--radius);
    box-shadow: 0 16px 36px rgba(21, 25, 34, 0.12);
}

.dropdown-item {
    font-weight: 700;
}

.user-chip {
    max-width: 210px;
}

.user-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

.metric-card,
.tool-panel,
.data-panel,
.auth-card,
.install-card,
.tracking-result,
.public-hero {
    background: var(--sw-surface);
    border: 1px solid var(--sw-border);
    border-radius: var(--radius);
    box-shadow: 0 14px 30px rgba(21, 25, 34, 0.045);
}

.metric-card {
    position: relative;
    overflow: hidden;
    min-height: 116px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.metric-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--sw-blue);
}

.metric-card:nth-child(2n)::before {
    background: #16181d;
}

.metric-card:nth-child(3n)::before {
    background: #64748b;
}

.metric-label {
    color: var(--sw-muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0;
}

.metric-value {
    margin-top: 8px;
    color: var(--sw-ink);
    font-size: clamp(27px, 2.4vw, 38px);
    line-height: 1;
}

.tool-panel,
.data-panel {
    padding: 20px;
}

.section-title {
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.section-title h2 {
    color: var(--sw-ink);
    font-size: 20px;
    line-height: 1.15;
}

.form-label {
    margin-bottom: 6px;
    color: var(--sw-ink-2);
    font-size: 13px;
    font-weight: 850;
}

.form-control,
.form-select {
    min-height: 43px;
    color: var(--sw-ink);
    background-color: #fff;
    border-color: var(--sw-border-strong);
    border-radius: var(--radius);
    font-weight: 600;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--sw-blue);
    box-shadow: 0 0 0 0.2rem rgba(11, 99, 206, 0.12);
}

.form-control[readonly],
.form-control:disabled,
.form-select:disabled {
    background-color: #f1f5f9;
    color: #64748b;
}

.form-text {
    color: var(--sw-muted);
    font-weight: 600;
}

.alert {
    border-radius: var(--radius);
    border-width: 1px;
    font-weight: 650;
}

.nav-pills {
    padding: 6px;
    background: #fff;
    border: 1px solid var(--sw-border);
    border-radius: var(--radius);
}

.nav-pills .nav-link {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    color: #475467;
    border-radius: var(--radius);
    font-weight: 800;
}

.nav-pills .nav-link.active {
    color: #fff;
    background: var(--sw-blue);
}

.table-responsive {
    width: 100%;
    border-radius: var(--radius);
}

.table {
    margin-bottom: 0;
    vertical-align: middle;
    --bs-table-hover-bg: #f4f8ff;
}

.table > :not(caption) > * > * {
    padding: 0.82rem 0.9rem;
    border-bottom-color: #e5ecf5;
}

.table thead th {
    color: #344054;
    background: #f8fbff;
    border-bottom: 1px solid var(--sw-border);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0;
    white-space: nowrap;
}

.table tbody td {
    color: #253044;
    font-weight: 650;
    white-space: nowrap;
}

.table td.text-wrap {
    white-space: normal;
}

.btn-group,
.btn-group-sm {
    display: inline-flex;
    flex-wrap: nowrap;
}

.btn-group .btn,
.btn-group-sm .btn {
    width: auto;
    min-width: 36px;
    padding-inline: 0.58rem;
}

.badge {
    border-radius: 999px;
    padding: 0.48rem 0.68rem;
    font-weight: 850;
    letter-spacing: 0;
}

.text-bg-success {
    background-color: #e8f7ef !important;
    color: #146c43 !important;
}

.text-bg-danger {
    background-color: #ffecec !important;
    color: #b42318 !important;
}

.text-bg-warning {
    background-color: #fff7e6 !important;
    color: #9a6700 !important;
}

.text-bg-info {
    background-color: #e6f7ff !important;
    color: #075985 !important;
}

.text-bg-secondary {
    background-color: #eef2f7 !important;
    color: #475467 !important;
}

.text-bg-primary {
    background-color: var(--sw-blue-soft) !important;
    color: var(--sw-blue) !important;
}

.relation-arrow {
    color: var(--sw-blue);
    font-family: var(--font-heading);
    font-weight: 700;
}

.dataTables_wrapper .dt-layout-row {
    margin: 0 0 14px;
    align-items: center;
}

.dataTables_wrapper .dt-search input,
.dataTables_wrapper .dt-length select {
    min-height: 40px;
    border-radius: var(--radius);
    border-color: var(--sw-border-strong);
}

.dataTables_wrapper .dt-search label,
.dataTables_wrapper .dt-length label,
.dataTables_info {
    color: var(--sw-muted);
    font-weight: 700;
}

.page-link {
    color: var(--sw-blue);
    border-color: var(--sw-border);
    font-weight: 800;
}

.active > .page-link,
.page-link.active {
    background: var(--sw-blue);
    border-color: var(--sw-blue);
}

.auth-page,
.install-page,
.tracking-page {
    min-height: 100vh;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sw-bg);
}

.auth-card {
    width: min(100%, 452px);
    padding: 30px;
}

.install-card {
    width: min(100%, 1140px);
    padding: 30px;
}

.tracking-wrap {
    width: min(100%, 930px);
}

.public-hero {
    padding: 30px;
    text-align: center;
}

.public-title {
    color: var(--sw-ink);
    font-size: clamp(30px, 5vw, 46px);
}

.auth-title,
.install-title {
    color: var(--sw-ink);
}

.requirement-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.requirement-item {
    min-height: 48px;
    padding: 11px 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--sw-border);
    border-radius: var(--radius);
    font-weight: 800;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 1399px) {
    .metric-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 1199px) {
    .metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s ease;
    }

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

    .sidebar-is-open .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1030;
        display: block;
        background: rgba(15, 23, 42, 0.44);
    }

    .app-main {
        width: 100%;
        margin-left: 0;
    }

    .app-topbar {
        min-height: 76px;
        padding: 12px 16px;
    }

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

@media (max-width: 767px) {
    body {
        font-size: 14px;
    }

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

    .metric-card {
        min-height: 106px;
        padding: 16px;
    }

    .topbar-actions {
        gap: 6px;
    }

    .user-chip {
        max-width: 132px;
        padding-inline: 0.65rem;
    }

    .user-chip span {
        max-width: 72px;
    }

    .requirement-list {
        grid-template-columns: 1fr;
    }

    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-title > .d-flex,
    .section-title > form {
        width: 100%;
    }

    .install-card,
    .auth-card,
    .public-hero,
    .tracking-result,
    .tool-panel,
    .data-panel {
        padding: 17px;
    }

    .nav-pills {
        overflow-x: auto;
        flex-wrap: nowrap !important;
    }

    .nav-pills .nav-link {
        white-space: nowrap;
    }

    .table > :not(caption) > * > * {
        padding: 0.72rem 0.78rem;
    }
}

@media (max-width: 480px) {
    .app-content {
        padding: 14px;
    }

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

    .btn:not(.btn-icon):not(.dropdown-toggle) {
        width: 100%;
    }

    .btn-group .btn,
    .btn-group-sm .btn {
        width: auto;
    }

    .d-flex.gap-2.flex-wrap .btn:not(.btn-icon) {
        flex: 1 1 auto;
    }

    .d-flex.gap-2.flex-wrap .btn-group .btn,
    .d-flex.gap-2.flex-wrap .btn-group-sm .btn {
        flex: 0 0 auto;
    }
}

@media print {
    .app-sidebar,
    .app-topbar,
    .sidebar-backdrop,
    .no-print,
    .dataTables_filter,
    .dataTables_length,
    .dataTables_info,
    .dataTables_paginate,
    .dt-search,
    .dt-length,
    .dt-paging,
    .dt-info {
        display: none !important;
    }

    .app-main,
    .app-content {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    body {
        background: #fff;
    }

    .metric-card,
    .tool-panel,
    .data-panel,
    .auth-card,
    .install-card,
    .tracking-result {
        box-shadow: none;
    }
}
