@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
    --bg-top: #e8f2f9;
    --bg-bottom: #f7fafc;
    --surface: #ffffff;
    --surface-soft: #f4f8fc;
    --surface-strong: #ebf2f9;
    --text: #102131;
    --text-muted: #465b70;
    --line: #d7e3ef;
    --brand: #0b6fa4;
    --brand-hover: #095983;
    --brand-soft: #e6f3fb;
    --success-bg: #e8f8ee;
    --success-text: #1d6a3f;
    --danger-bg: #ffeceb;
    --danger-text: #9b2f2f;
    --shadow: 0 16px 40px rgba(7, 31, 56, 0.1);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #0a6ca0;
    outline-offset: 2px;
}

body {
    margin: 0;
    padding: 30px 18px 46px;
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--text);
    line-height: 1.5;
    background:
        radial-gradient(circle at 0% 0%, #ffffff 8%, transparent 45%),
        radial-gradient(circle at 100% 20%, #d4e8f6 0%, transparent 32%),
        linear-gradient(165deg, var(--bg-top), var(--bg-bottom));
    min-height: 100vh;
}

body > * {
    max-width: 1160px;
    margin-left: auto;
    margin-right: auto;
}

body.has-app-sidebar {
    padding-left: 286px;
}

body.has-app-sidebar.app-sidebar-collapsed {
    padding-left: 18px;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 120;
    max-width: none;
    margin: 0 0 14px;
}

.app-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(6px);
    box-shadow: 0 8px 20px rgba(7, 31, 56, 0.08);
}

.app-topbar-left,
.app-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.app-topbar-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.app-topbar-nav-link {
    display: inline-block;
    padding: 8px 11px;
    border-radius: 9px;
    border: 1px solid transparent;
    color: #234359;
    font-weight: 700;
    background: transparent;
}

.app-topbar-nav-link:hover {
    text-decoration: none;
    background: var(--surface-soft);
    border-color: var(--line);
}

.app-topbar-nav-link.is-active {
    background: var(--brand-soft);
    border-color: #b9d9ef;
    color: #0a5c88;
}

.app-page-title {
    font-weight: 700;
    color: #274155;
}

.app-sidebar-toggle {
    padding: 8px 11px;
    border: 1px solid #c8d9ea;
    border-radius: 9px;
    background: #f2f8fd;
    color: #1f4056;
    font-weight: 700;
    box-shadow: none;
}

.app-sidebar-toggle:hover {
    background: #e6f1fa;
}

.app-global-search {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    max-width: none;
}

.app-global-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-search-toggle {
    padding: 7px 10px;
    border: 1px solid #c8d9ea;
    border-radius: 9px;
    background: #f2f8fd;
    color: #1f4056;
    font-weight: 700;
    box-shadow: none;
    line-height: 1;
}

.app-search-toggle:hover {
    background: #e6f1fa;
}

.app-global-search input[type="text"] {
    width: min(260px, 50vw);
    margin: 0;
    padding: 9px 11px;
}

.app-global-search-wrap:not(.is-open) .app-global-search {
    display: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.app-sidebar {
    position: fixed;
    top: 18px;
    left: 18px;
    bottom: 18px;
    display: flex;
    flex-direction: column;
    width: 248px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow);
    z-index: 130;
    overflow-y: auto;
    transition: transform 140ms ease-out;
}

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

.app-sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.app-sidebar-link {
    display: block;
    padding: 9px 11px;
    border-radius: 9px;
    border: 1px solid transparent;
    color: #234359;
    font-weight: 700;
}

.app-sidebar-link:hover {
    text-decoration: none;
    background: var(--surface-soft);
    border-color: var(--line);
}

.app-sidebar-link.is-active {
    background: var(--brand-soft);
    border-color: #b9d9ef;
    color: #0a5c88;
}

.app-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    border: 0;
    background: rgba(15, 32, 47, 0.35);
    z-index: 125;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 8px;
    z-index: 999;
    padding: 9px 12px;
    border-radius: 8px;
    background: #0f2d43;
    color: #fff;
    font-weight: 700;
}

.skip-link:focus {
    left: 10px;
}

.app-brand {
    display: inline-block;
    padding: 7px 11px;
    border-radius: 10px;
    background: linear-gradient(180deg, #0f7ab4 0%, #0b6fa4 100%);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.app-brand:hover {
    color: #fff;
    text-decoration: none;
    background: linear-gradient(180deg, #0e6a9d 0%, #095983 100%);
}

.app-user-wrap {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-notification-link {
    display: inline-block;
    padding: 7px 11px;
    border-radius: 9px;
    border: 1px solid #c8d9ea;
    background: #f2f8fd;
    color: #1f4056;
    font-weight: 700;
}

.app-notification-link.icon-only {
    min-width: 38px;
    text-align: center;
    padding: 7px 9px;
}

.app-notification-link:hover {
    text-decoration: none;
    background: #e6f1fa;
}

.app-notification-badge {
    display: inline-block;
    min-width: 20px;
    padding: 1px 6px;
    margin-left: 6px;
    border-radius: 999px;
    background: #d83a3a;
    color: #fff;
    font-size: 0.78rem;
    line-height: 1.4;
    text-align: center;
    font-weight: 800;
}

.app-user-chip {
    display: inline-block;
    padding: 8px 11px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: #274155;
    font-weight: 700;
}

.app-account-menu {
    position: relative;
}

.app-account-menu summary {
    list-style: none;
    cursor: pointer;
    padding: 8px 11px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: #274155;
    font-weight: 700;
}

.app-account-menu[open] summary {
    border-color: #b9d9ef;
    background: #eaf4fb;
}

.app-account-menu summary::-webkit-details-marker {
    display: none;
}

.app-account-dropdown {
    position: absolute;
    right: 0;
    margin-top: 6px;
    min-width: 160px;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 10px 22px rgba(10, 38, 67, 0.12);
    z-index: 140;
}

.app-account-dropdown a {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    font-weight: 700;
}

.app-account-dropdown a:hover {
    text-decoration: none;
    background: var(--surface-soft);
}

.app-user-chip:hover {
    text-decoration: none;
    background: #eaf4fb;
}

.app-logout-link {
    display: inline-block;
    padding: 8px 11px;
    border-radius: 9px;
    border: 1px solid #e7c4c4;
    background: #fff5f5;
    color: #943030;
    font-weight: 700;
}

.app-logout-link:hover {
    text-decoration: none;
    background: #ffecec;
}

h2,
h3,
h4 {
    margin: 0 0 14px;
    color: #0e2335;
    letter-spacing: 0.1px;
}

h2 {
    font-size: clamp(1.55rem, 2vw, 1.95rem);
    font-weight: 800;
}

h3 {
    font-size: 1.15rem;
    margin-top: 24px;
}

h3:first-of-type {
    margin-top: 14px;
}

p {
    margin: 0 0 12px;
    color: var(--text-muted);
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 28px auto;
    max-width: 1160px;
}

a {
    color: var(--brand);
    text-decoration: none;
    font-weight: 700;
}

a:hover {
    text-decoration: underline;
}

p > a,
li > a {
    display: inline-block;
    padding: 7px 11px;
    border-radius: 9px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    margin-right: 8px;
    margin-bottom: 6px;
}

p > a:hover,
li > a:hover {
    background: var(--brand-soft);
    text-decoration: none;
}

form {
    margin: 10px auto 14px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, #ffffff 0%, #fdfefe 100%);
    box-shadow: var(--shadow);
    max-width: 1160px;
}

.form-grid {
    display: grid;
    gap: 12px;
}

.form-field {
    display: grid;
    gap: 6px;
}

.form-field label {
    margin: 0;
}

.hint-text {
    margin: 0;
    font-size: 0.9rem;
    color: #51697e;
}

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

.form-compact {
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    max-width: none;
}

form[method="get"] {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

form[method="get"] input[type="text"] {
    width: min(380px, 100%);
}

label {
    display: inline-block;
    margin: 8px 0 6px;
    font-weight: 700;
    color: #1d3548;
}

input,
textarea,
select,
button {
    font-family: inherit;
    font-size: 0.96rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
input[type="file"],
textarea,
select {
    width: min(680px, 100%);
    padding: 11px 12px;
    border: 1px solid #c8d9ea;
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    margin-bottom: 10px;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #86b7d7;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(11, 111, 164, 0.18);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

button,
input[type="submit"] {
    background: linear-gradient(180deg, #0f7ab4 0%, #0b6fa4 100%);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(11, 111, 164, 0.24);
}

button:hover,
input[type="submit"]:hover {
    background: linear-gradient(180deg, #0e6a9d 0%, #095983 100%);
    text-decoration: none;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 12px auto 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.responsive-table {
    table-layout: fixed;
    margin-left: auto;
    margin-right: auto;
}

.users-table .col-email,
.users-table .col-phone {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.section-card {
    margin: 10px auto 14px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    box-shadow: 0 10px 24px rgba(10, 38, 67, 0.08);
}

.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.toolbar-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: #4b6176;
    font-size: 0.94rem;
}

.toolbar-links a {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
}

.toolbar-links a:hover {
    text-decoration: none;
    background: var(--brand-soft);
}

.toolbar-form {
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    max-width: none;
    flex: 1;
    min-width: 260px;
}

.toolbar-form input[type="text"] {
    margin-bottom: 0;
}

.users-toolbar {
    justify-content: space-between;
}

.users-toolbar .toolbar-form {
    flex: 1;
}

.users-toolbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.departments-toolbar {
    justify-content: flex-end;
}

.departments-toolbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.form-grid input[type="text"],
.form-grid input[type="email"],
.form-grid input[type="password"],
.form-grid input[type="datetime-local"],
.form-grid input[type="file"],
.form-grid textarea,
.form-grid select {
    width: 100%;
    margin-bottom: 0;
}

.audit-filter-form .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px 10px;
}

.audit-toolbar {
    margin-bottom: 6px;
}

.audit-filter-toggle {
    padding: 7px 10px;
    font-size: 0.86rem;
}

.audit-filter-panel {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition: max-height 220ms ease, opacity 180ms ease, transform 180ms ease;
}

.audit-filter-panel.is-open {
    max-height: 520px;
    opacity: 1;
    transform: translateY(0);
    margin-bottom: 8px;
}

.audit-filter-form .form-field {
    gap: 4px;
}

.audit-filter-form .form-field label {
    font-size: 0.84rem;
}

.audit-filter-form input[type="text"],
.audit-filter-form input[type="date"],
.audit-filter-form select {
    width: 100%;
    padding: 7px 9px;
    margin-bottom: 0;
    font-size: 0.88rem;
}

.audit-filter-form .form-actions {
    align-self: end;
    margin-top: 0;
    gap: 8px;
}

.audit-filter-form .form-actions button,
.audit-filter-form .form-actions a {
    padding: 7px 10px;
    font-size: 0.86rem;
}

.table-shell {
    margin: 0 0 12px;
    align-self: center;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}

.table-meta {
    margin: 0 0 8px;
    color: #587084;
    font-size: 0.9rem;
    font-weight: 600;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    max-width: none;
}

.inline-form button {
    padding: 7px 10px;
    font-size: 0.86rem;
    border-radius: 8px;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px 12px;
}

.meta-item {
    margin: 0;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #e4edf5;
    background: #f9fcff;
    color: #355067;
}

.meta-item.description {
    grid-column: 1 / -1;
}

.timeline-list li {
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid #e3ebf3;
    border-radius: 10px;
    background: #fbfdff;
}

.page-back {
    margin-top: 8px;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid #e6edf4;
    vertical-align: top;
    text-align: left;
}

th {
    background: var(--surface-strong);
    color: #203a4d;
    font-weight: 800;
    letter-spacing: 0.2px;
}

tr:hover td {
    background: #f9fcff;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin: 12px 0 20px;
}

.stat-card {
    display: block;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 10px 22px rgba(10, 38, 67, 0.08);
}

.stat-card:hover {
    text-decoration: none;
    border-color: #bfd8ea;
    transform: translateY(-1px);
}

.stat-label {
    display: block;
    font-size: 0.84rem;
    color: #4d6478;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.stat-value {
    display: block;
    margin-top: 6px;
    font-size: 1.8rem;
    line-height: 1.1;
    color: #0f2d43;
}

.page-actions {
    margin-top: 12px;
}

ul {
    padding-left: 20px;
}

ul li {
    margin-bottom: 9px;
}

small {
    color: #4a6074;
}

.alert {
    padding: 11px 13px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: #294155;
    margin: 10px auto 14px;
    max-width: 1160px;
}

.alert-success {
    background: var(--success-bg);
    border-color: #b7e5c7;
    color: var(--success-text);
}

.alert-error {
    background: var(--danger-bg);
    border-color: #f0c4c1;
    color: var(--danger-text);
}

.analytics-bars {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    gap: 10px;
    align-items: end;
    min-height: 180px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdff;
}

.analytics-bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.analytics-bar {
    width: 34px;
    min-height: 6%;
    border-radius: 8px 8px 4px 4px;
    background: linear-gradient(180deg, #18a3e7 0%, #0b6fa4 100%);
    box-shadow: 0 6px 14px rgba(11, 111, 164, 0.2);
}

.analytics-heat-cell {
    text-align: center;
    font-weight: 700;
}

@media (max-width: 760px) {
    body {
        padding: 20px 12px 34px;
    }

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

    .app-topbar-inner {
        padding: 9px;
        gap: 7px;
    }

    .app-global-search input[type="text"] {
        width: min(220px, 65vw);
    }

    .app-page-title {
        font-size: 0.92rem;
    }

    .app-topbar-right {
        width: 100%;
    }

    .app-topbar-nav {
        width: 100%;
    }

    h2 {
        font-size: 1.4rem;
    }

    form {
        padding: 14px;
    }

    .section-card {
        padding: 12px;
    }

    .toolbar-form {
        width: 100%;
        min-width: 0;
    }

    .table-shell table {
        min-width: 720px;
    }

    th,
    td {
        padding: 10px 8px;
        font-size: 0.9rem;
    }

    p > a,
    li > a {
        margin-right: 6px;
    }
}

@media (max-width: 980px) {
    .app-sidebar {
        transform: translateX(-120%);
    }

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

    body.app-sidebar-open-mobile .app-sidebar-overlay {
        display: block;
    }
}

@media (min-width: 981px) {
    body.app-sidebar-collapsed .app-sidebar {
        transform: translateX(-120%);
    }
}

@media print {
    @page {
        margin: 12mm;
    }

    body {
        padding: 0;
        background: #fff;
        color: #000;
    }

    .app-topbar,
    .app-sidebar,
    .app-sidebar-overlay,
    .skip-link,
    .no-print {
        display: none !important;
    }

    .section-card {
        margin: 0 0 12px;
        padding: 10px;
        border: 1px solid #ccc;
        box-shadow: none;
        background: #fff;
    }

    a {
        color: #000;
        text-decoration: none;
    }
}

body.print-mode {
    background: #fff;
}

body.print-mode > * {
    max-width: 900px;
}

.print-meta {
    margin: 0 0 10px;
    color: #445a6f;
    font-size: 0.9rem;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    max-width: none;
    width: 100vw;
    height: 100vh;
    margin: 0;
    z-index: 200;
    background: rgba(13, 29, 45, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.is-open {
    display: flex;
}

.modal-card {
    width: min(100%, 460px);
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 14px 36px rgba(7, 31, 56, 0.22);
    padding: 16px;
}

.modal-card h3 {
    margin: 0 0 8px;
}

body > .section-card,
body > .alert,
body > .page-back {
    max-width: none;
}

.login-page .app-topbar {
    margin-bottom: 24px;
}

.login-main {
    min-height: calc(100vh - 150px);
    display: grid;
    place-items: center;
    padding: 8px 0 24px;
}

.login-card {
    width: min(100%, 390px);
    margin: 0 auto;
    padding: 26px 22px 22px;
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 1.6rem;
    font-weight: 800;
    color: #0e2335;
}

.login-subtitle {
    margin: 0 0 16px;
    color: #587084;
}

.login-field {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
}

.login-field label {
    margin: 0;
}

.login-field input[type="text"],
.login-field input[type="password"] {
    width: 100%;
    margin: 0;
}

.login-submit {
    width: 100%;
    margin-top: 4px;
}

.login-help-link {
    margin: 10px 0 0;
    text-align: center;
}

.login-help-link a {
    display: inline-block;
    padding: 0;
    border: 0;
    background: transparent;
    margin: 0;
}

.login-help-links {
    margin: 10px 0 0;
    text-align: center;
}

.login-help-links a {
    display: inline-block;
    padding: 0;
    border: 0;
    background: transparent;
    margin: 0 8px;
}
