:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-muted: #f0f4f8;
    --ink: #17202a;
    --muted: #697586;
    --line: #d8e0ea;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --accent-soft: #d9f2ee;
    --nav: #132238;
    --nav-soft: #203552;
    --table-head: #102a43;
    --table-head-soft: #173b5e;
}

html {
    font-size: 15px;
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    min-height: 100vh;
}

    body.mobile-menu-open {
        overflow: hidden;
    }

a {
    color: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 0.2s ease;
}

    .app-shell.menu-collapsed,
    .sidebar-collapsed .app-shell {
        grid-template-columns: 78px minmax(0, 1fr);
    }

.sidebar-backdrop {
    display: none;
}

.app-sidebar {
    background: var(--nav);
    color: #f8fafc;
    overflow: hidden;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-header {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    margin-bottom: 28px;
}

.brand-mark {
    align-items: center;
    color: #ffffff;
    display: flex;
    gap: 12px;
    min-width: 0;
    text-decoration: none;
}

.brand-logo {
    align-items: center;
    background: var(--accent);
    border-radius: 8px;
    display: inline-flex;
    font-weight: 700;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.brand-copy {
    min-width: 0;
    white-space: nowrap;
}

.brand-title,
.brand-subtitle {
    display: block;
    line-height: 1.2;
}

.brand-title {
    font-weight: 700;
}

.brand-subtitle {
    color: #b8c4d4;
    font-size: 0.82rem;
    margin-top: 3px;
}

.sidebar-toggle {
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 7px;
    color: #dbe5f1;
    display: inline-flex;
    flex: 0 0 auto;
    height: 34px;
    justify-content: center;
    padding: 0;
    width: 34px;
}

    .sidebar-toggle:hover,
    .sidebar-toggle:focus {
        background: var(--nav-soft);
        color: #ffffff;
    }

    .sidebar-toggle svg,
    .nav-icon svg {
        fill: none;
        stroke: currentColor;
        stroke-linecap: round;
        stroke-linejoin: round;
        stroke-width: 1.8;
    }

    .sidebar-toggle svg {
        height: 20px;
        width: 20px;
    }

.app-nav {
    display: grid;
    gap: 6px;
}

.app-nav-link {
    align-items: center;
    border-radius: 8px;
    color: #dbe5f1;
    display: flex;
    gap: 10px;
    min-height: 44px;
    padding: 8px 10px;
    text-decoration: none;
    white-space: nowrap;
}

    .app-nav-link:hover,
    .app-nav-link.active {
        background: var(--nav-soft);
        color: #ffffff;
    }

.nav-icon {
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    display: inline-flex;
    flex: 0 0 auto;
    height: 28px;
    justify-content: center;
    width: 34px;
}

    .nav-icon svg {
        height: 18px;
        width: 18px;
    }

.menu-collapsed .app-sidebar,
.sidebar-collapsed .app-sidebar {
    padding-left: 12px;
    padding-right: 12px;
}

.menu-collapsed .sidebar-header,
.sidebar-collapsed .sidebar-header {
    flex-direction: column;
    gap: 12px;
}

.menu-collapsed .brand-copy,
.menu-collapsed .app-nav-link span:not(.nav-icon),
.sidebar-collapsed .brand-copy,
.sidebar-collapsed .app-nav-link span:not(.nav-icon) {
    height: 1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    width: 1px;
}

.menu-collapsed .brand-mark,
.menu-collapsed .app-nav-link,
.sidebar-collapsed .brand-mark,
.sidebar-collapsed .app-nav-link {
    justify-content: center;
}

.menu-collapsed .app-nav-link,
.sidebar-collapsed .app-nav-link {
    padding-left: 8px;
    padding-right: 8px;
}

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

.topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    min-height: 78px;
    padding: 16px 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-kicker {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 3px;
    text-transform: uppercase;
}

.topbar h1 {
    font-size: 1.55rem;
    font-weight: 700;
    margin: 0;
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

.status-pill {
    background: var(--panel-muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 10px;
}

.content-wrap {
    flex: 1 0 auto;
    padding: 26px 28px 36px;
}

.app-footer {
    background: #ffffff;
    border-top: 1px solid var(--line);
    color: var(--muted);
    flex: 0 0 auto;
    font-size: 0.86rem;
    padding: 14px 28px;
}

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

    .page-toolbar h2 {
        font-size: 1.18rem;
        font-weight: 700;
        margin: 0 0 4px;
    }

    .page-toolbar p {
        color: var(--muted);
        margin: 0;
    }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    border-radius: 7px;
    font-weight: 700;
    min-height: 40px;
}

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

.btn:focus,
.btn:active:focus,
.navbar-toggler:focus,
.form-control:focus {
    box-shadow: 0 0 0 0.18rem rgba(15, 118, 110, 0.22);
}

.navbar-toggler {
    border: 1px solid var(--line);
    border-radius: 7px;
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%2317202a' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.metric-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 18px;
}

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

.module-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    display: grid;
    gap: 8px;
    min-height: 168px;
    padding: 18px;
    text-decoration: none;
}

    .module-card:hover {
        border-color: var(--accent);
        color: var(--ink);
    }

.module-code {
    align-items: center;
    background: var(--accent-soft);
    border-radius: 7px;
    color: var(--accent-dark);
    display: inline-flex;
    font-weight: 800;
    height: 36px;
    justify-content: center;
    width: 42px;
}

.module-card strong {
    font-size: 1rem;
}

.module-card small {
    color: var(--muted);
}

.metric-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

    .metric-card span {
        color: var(--muted);
        display: block;
        font-size: 0.82rem;
        font-weight: 700;
        margin-bottom: 8px;
    }

    .metric-card strong {
        color: var(--ink);
        font-size: 1.42rem;
        line-height: 1.2;
    }

.data-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(15, 35, 56, 0.06);
}

.document-table {
    margin: 0;
    min-width: 780px;
    width: 100%;
}

    .document-table thead th,
    .data-panel table thead th,
    .data-panel table.dataTable thead th {
        background: linear-gradient(180deg, var(--table-head-soft), var(--table-head));
        border-bottom: 0;
        color: #f8fafc;
        font-size: 0.78rem;
        font-weight: 800;
        padding: 13px 16px;
        text-transform: uppercase;
        vertical-align: middle;
    }

    .document-table tbody td {
        border-color: #edf1f5;
        padding: 15px 16px;
    }

.data-panel table.dataTable {
    margin: 0 !important;
    min-width: 100%;
    width: 100% !important;
}

.data-panel table tbody tr {
    transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

    .data-panel table tbody tr:hover,
    .data-panel table tbody tr.is-selected {
        background: #f2fbf8;
        box-shadow: inset 3px 0 0 var(--accent);
    }

.data-panel table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
.data-panel table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
    background-color: var(--accent);
    border-color: #ffffff;
    left: 12px;
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.14);
    top: 50%;
    transform: translateY(-50%);
}

.data-panel table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
.data-panel table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
    min-width: 118px;
    padding-left: 42px !important;
}

.data-panel table.dataTable > thead .sorting::before,
.data-panel table.dataTable > thead .sorting::after,
.data-panel table.dataTable > thead .sorting_asc::before,
.data-panel table.dataTable > thead .sorting_asc::after,
.data-panel table.dataTable > thead .sorting_desc::before,
.data-panel table.dataTable > thead .sorting_desc::after {
    color: rgba(255, 255, 255, 0.78) !important;
    opacity: 1 !important;
}

.table-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    white-space: nowrap;
}

    .table-actions a,
    .data-panel tbody td > a {
        align-items: center;
        border-radius: 6px;
        display: inline-flex;
        gap: 5px;
        min-height: 34px;
        padding: 5px 7px;
        text-decoration: none;
    }

        .table-actions a:hover,
        .data-panel tbody td > a:hover {
            background: var(--accent-soft);
            color: var(--accent-dark);
        }

        .table-actions a.text-danger:hover,
        .data-panel tbody td > a.text-danger:hover {
            background: #fee2e2;
            color: #b91c1c !important;
        }

.document-number {
    background: var(--accent-soft);
    border-radius: 6px;
    color: var(--accent-dark);
    display: inline-block;
    font-weight: 800;
    padding: 5px 8px;
    overflow-wrap: normal;
    white-space: nowrap;
    word-break: normal;
}

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

.empty-state {
    align-items: center;
    color: var(--muted);
    display: grid;
    justify-items: center;
    min-height: 220px;
    padding: 34px 18px;
    text-align: center;
}

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

.entry-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 22px;
    padding: 18px;
}

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

.span-2 {
    grid-column: span 2;
}

.line-editor {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 14px;
    padding-top: 18px;
}

.line-editor-heading {
    align-items: end;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

    .line-editor-heading h3 {
        font-size: 1rem;
        font-weight: 700;
        margin: 0;
    }

    .line-editor-heading span {
        color: var(--muted);
        font-size: 0.86rem;
    }

.line-table {
    display: grid;
    gap: 10px;
}

.line-table-head,
.line-row {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(180px, 2fr) minmax(90px, 0.7fr) minmax(90px, 0.8fr) minmax(100px, 0.8fr) auto;
}

.line-table-head {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.line-table-body {
    display: grid;
    gap: 10px;
}

.line-remove {
    min-width: 84px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.delete-summary {
    display: grid;
    gap: 8px 18px;
    grid-template-columns: max-content minmax(0, 1fr);
    margin: 0;
}

    .delete-summary dt {
        color: var(--muted);
        font-weight: 700;
    }

    .delete-summary dd {
        margin: 0;
    }

@media (min-width: 992px) and (max-width: 1199.98px) {
    .app-shell {
        grid-template-columns: 220px minmax(0, 1fr);
    }

        .app-shell.menu-collapsed,
        .sidebar-collapsed .app-shell {
            grid-template-columns: 74px minmax(0, 1fr);
        }

    .app-sidebar {
        padding-left: 12px;
        padding-right: 12px;
    }

    .brand-logo {
        height: 38px;
        width: 38px;
    }

    .app-nav-link {
        gap: 8px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .topbar {
        padding-left: 22px;
        padding-right: 22px;
    }

    .content-wrap {
        padding-left: 22px;
        padding-right: 22px;
    }
}

@media (max-width: 991.98px) {
    .app-shell {
        display: block;
    }

    .app-sidebar {
        box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
        height: 100dvh;
        left: 0;
        max-width: calc(100vw - 42px);
        overflow-y: auto;
        padding: 18px 14px;
        position: fixed;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        width: 280px;
        z-index: 30;
    }

    .app-shell.menu-collapsed,
    .sidebar-collapsed .app-shell {
        display: block;
    }

        .app-shell.menu-collapsed .app-sidebar,
        .sidebar-collapsed .app-shell .app-sidebar {
            padding-left: 14px;
            padding-right: 14px;
        }

        .app-shell.menu-collapsed .sidebar-header,
        .sidebar-collapsed .app-shell .sidebar-header {
            flex-direction: row;
            gap: 10px;
        }

        .app-shell.menu-collapsed .brand-copy,
        .app-shell.menu-collapsed .app-nav-link span:not(.nav-icon),
        .sidebar-collapsed .app-shell .brand-copy,
        .sidebar-collapsed .app-shell .app-nav-link span:not(.nav-icon) {
            height: auto;
            opacity: 1;
            overflow: visible;
            position: static;
            width: auto;
        }

        .app-shell.menu-collapsed .brand-mark,
        .app-shell.menu-collapsed .app-nav-link,
        .sidebar-collapsed .app-shell .brand-mark,
        .sidebar-collapsed .app-shell .app-nav-link {
            justify-content: flex-start;
        }

        .app-shell.menu-collapsed .app-nav-link,
        .sidebar-collapsed .app-shell .app-nav-link {
            padding-left: 10px;
            padding-right: 10px;
        }

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

    .app-shell.mobile-menu-open .sidebar-backdrop {
        background: rgba(15, 23, 42, 0.42);
        display: block;
        inset: 0;
        position: fixed;
        z-index: 25;
    }

    .topbar {
        padding: 14px 18px;
    }

    .topbar-actions {
        display: none;
    }

    .content-wrap {
        padding: 18px;
    }

    .app-footer {
        padding: 14px 18px;
    }

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

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

    .page-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .entry-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .line-table {
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .line-table-head,
    .line-row {
        min-width: 720px;
    }
}

@media (max-width: 575.98px) {
    html {
        font-size: 14px;
    }

    .topbar {
        gap: 12px;
        min-height: 68px;
        padding: 12px 14px;
    }

        .topbar h1 {
            font-size: 1.25rem;
        }

    .content-wrap {
        padding: 14px;
    }

    .app-footer {
        padding: 12px 14px;
    }

    .page-toolbar {
        gap: 12px;
    }

    .document-table {
        min-width: 680px;
    }

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

    .span-2 {
        grid-column: auto;
    }

    .line-editor-heading {
        align-items: start;
        flex-direction: column;
    }
}


/*
    Data table syles for better spacing and appearance on smaller screens
*/
/* Top section spacing */
.dataTables_wrapper .dt-buttons {
    margin-bottom: 15px;
}

.dataTables_wrapper .dataTables_filter {
    margin-bottom: 15px;
}

    .dataTables_wrapper .dataTables_filter input {
        margin-left: 8px;
        border-radius: 8px;
        border: 1px solid #ced4da;
        padding: 6px 10px;
        height: 38px;
        max-width: 100%;
    }

/* Pagination buttons */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 6px 14px !important;
    margin: 0 4px;
    border-radius: 8px !important;
    border: 1px solid #dee2e6 !important;
    background: white !important;
    color: #333 !important;
}

    .dataTables_wrapper .dataTables_paginate .paginate_button.current {
        background: var(--accent) !important;
        color: white !important;
        border: 1px solid var(--accent) !important;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
        background: #e9ecef !important;
        color: black !important;
    }

/* Table footer area */
.dataTables_wrapper .dataTables_info {
    padding-top: 15px;
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 10px;
}

/* Length dropdown */
.dataTables_wrapper {
    border-radius: 8px;
    margin: 0;
    padding: 10px;
}
.dataTables_length select {
    width: 60px !important;
    display: inline-block !important;
}
/* Better alignment */
.dataTables_wrapper .row {
    align-items: center;
}
/*// End of data table styles*/
/*Dashboard*/
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(220px,1fr));
    gap: 1rem;
}

.module-card {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border-radius: 10px;
    background: #fff;
    text-decoration: none;
    border: 1px solid #ddd;
    transition: 0.3s;
}

    .module-card:hover {
        transform: translateY(-2px);
    }

.module-code {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #0d6efd;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    font-weight: bold;
}

@media(max-width:768px) {

    .dataTables_filter {
        margin-top: 10px;
    }

    .modal-dialog {
        margin: 10px;
    }

    .data-panel {
        border-radius: 8px;
    }

    .dataTables_wrapper .row {
        gap: 0.75rem;
    }

        .dataTables_wrapper .row > [class*="col-"] {
            text-align: left !important;
            width: 100%;
        }

    .dataTables_wrapper .dt-buttons,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: left !important;
        width: 100%;
    }

    .dataTables_wrapper .dt-buttons {
        display: grid;
        gap: 8px;
        margin-bottom: 6px;
    }

        .dataTables_wrapper .dt-buttons .btn {
            justify-content: center;
            min-height: 42px;
            width: 100%;
        }

    .dataTables_wrapper .dataTables_filter label {
        display: grid;
        gap: 6px;
        width: 100%;
    }

    .dataTables_wrapper .dataTables_filter input {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .dataTables_wrapper .dataTables_length label {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .dataTables_wrapper .dataTables_paginate {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
        padding-top: 6px;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        margin: 0;
        min-height: 38px;
        min-width: 38px;
        text-align: center;
    }

    .page-toolbar .btn {
        justify-content: center;
        width: 100%;
    }

    .table-actions {
        display: grid;
        justify-content: stretch;
        white-space: normal;
    }

    .table-actions a,
    .data-panel tbody td > a {
        justify-content: center;
        min-height: 40px;
    }
}

@media (max-width: 575.98px) {
    .data-panel .table-responsive {
        margin: 0 -10px;
        padding: 0 10px;
    }

    .document-table {
        min-width: 100%;
    }

    .dataTables_wrapper {
        padding: 8px;
    }

    .data-panel table thead th,
    .document-table thead th,
    .data-panel table.dataTable thead th {
        padding: 11px 12px;
    }

    .document-table tbody td,
    .data-panel table tbody td {
        padding: 12px;
    }

    .line-table {
        overflow: visible;
    }

    .line-table-head {
        display: none;
    }

    .line-row {
        background: #ffffff;
        border: 1px solid var(--line);
        border-radius: 8px;
        grid-template-columns: 1fr;
        min-width: 0;
        padding: 12px;
    }

    .line-remove,
    .form-actions .btn {
        width: 100%;
    }
}
