:root {
    --bg: #f4f7fb;
    --surface: rgba(255, 255, 255, 0.94);
    --surface-strong: #ffffff;
    --border: rgba(79, 92, 148, 0.14);
    --text: #1f2a44;
    --muted: #667089;
    --primary: #4358d8;
    --primary-dark: #3346b6;
    --secondary: #8457d8;
    --accent: #d95a9a;
    --success: #198754;
    --danger: #c73763;
    --warning-bg: #fff3cf;
    --warning-text: #8c6300;
    --shadow-lg: 0 24px 54px rgba(31, 42, 68, 0.14);
    --shadow-md: 0 10px 28px rgba(31, 42, 68, 0.10);
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(217, 90, 154, 0.08), transparent 24%),
        radial-gradient(circle at top right, rgba(67, 88, 216, 0.10), transparent 30%),
        linear-gradient(180deg, #f8fbff 0%, #f2f6fb 100%);
    color: var(--text);
}

body.modal-open { overflow: hidden; }

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

.sidebar {
    width: 248px;
    padding: 22px 16px;
    background: linear-gradient(180deg, #32406f 0%, #40539b 58%, #596cc6 100%);
    color: #fff;
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 18px;
}

.sidebar-brand strong,
.sidebar-brand span,
.app-footer-brand strong,
.app-footer-brand span {
    display: block;
}

.sidebar-brand strong {
    font-size: 18px;
    line-height: 1.1;
}

.sidebar-brand span {
    font-size: 11px;
    opacity: 0.78;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sidebar-logo,
.topbar-logo,
.footer-logo,
.login-logo {
    object-fit: contain;
    display: block;
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    padding: 4px;
}

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

.sidebar a {
    display: block;
    color: #fff;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 12px;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 14px;
    font-weight: 500;
    transition: transform 0.18s ease, background 0.18s ease;
}

.sidebar a:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateX(3px);
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: space-between;
    padding: 14px 18px;
    margin: 16px 16px 0;
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-lg);
}

.topbar-primary,
.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-primary {
    flex: 1;
    min-width: 0;
}

.topbar-user {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.topbar-logo {
    width: 218px;
    height: 62px;
}

.topbar-brand h1,
.view-title {
    margin: 0;
}

.topbar-brand h1 {
    font-size: 22px;
    line-height: 1.1;
}

.eyebrow {
    display: block;
    margin-bottom: 2px;
    color: var(--secondary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.user-chip {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: right;
    padding: 8px 12px;
    border-radius: 12px;
    background: #f6f8fc;
    border: 1px solid #e6ebf3;
}

.user-chip span {
    font-size: 11px;
    color: var(--muted);
}

.page-shell {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.container {
    padding: 18px 16px 0;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.col-4 {
    width: 33.3333%;
    padding: 10px;
}

.card,
table {
    background: var(--surface-strong);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid #e7ecf4;
}

.card {
    padding: 18px;
    margin-bottom: 16px;
}

.section-subtitle {
    color: var(--muted);
    font-size: 14px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 12px;
}

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

.form-grid-single { grid-template-columns: 1fr; }

.form-grid label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

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

.form-submit {
    display: flex;
    align-items: end;
}

.input-control {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d7deea;
    border-radius: 10px;
    background: #fcfdff;
    color: var(--text);
}

.input-control:focus {
    outline: none;
    border-color: rgba(78, 91, 255, 0.55);
    box-shadow: 0 0 0 4px rgba(162, 63, 226, 0.10);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--secondary) 55%, var(--primary));
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, #18a67d, #198754);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #ef476f, #b42355);
    color: #fff;
    text-decoration: none;
}

.btn-light {
    background: #eef2f8;
    color: var(--text);
    text-decoration: none;
}

.btn-xs {
    padding: 7px 10px;
    font-size: 12px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat-card {
    padding: 16px;
    border-radius: 14px;
    background: linear-gradient(180deg, #f8fbff, #eef3fb);
    border: 1px solid #dfe7f3;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

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

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.detail-grid h3 {
    margin: 0 0 12px;
}

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

table th,
table td {
    padding: 11px 12px;
    border-bottom: 1px solid #edf1f7;
    text-align: left;
    white-space: nowrap;
}

table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
}

.toolbar .col { flex: 1 1 220px; }
.toolbar-button { flex: 0 0 180px; }
.toolbar-inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    color: #fff;
}

.b-green { background: #1c9d67; }
.b-red { background: #de4f6d; }
.b-gray { background: #7d86aa; }
.b-blue { background: #4e5bff; }

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

.actions-users {
    min-width: 420px;
}

.actions button {
    width: auto;
    padding: 7px 10px;
    font-size: 12px;
}

.accordion-toggle {
    min-width: 120px;
}

.accordion-row > td {
    background: #f8fbff;
    padding: 0;
}

.accordion-panel {
    padding: 14px;
    border-top: 1px solid #e4ebf4;
}

.nested-table {
    width: 100%;
}

.nested-table th,
.nested-table td {
    white-space: normal;
}

.nested-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.report-shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: #1f2a44;
    background: #fff;
}

.report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 2px solid #e8edf6;
    padding-bottom: 18px;
    margin-bottom: 22px;
}

.report-logo {
    width: 220px;
    height: auto;
    object-fit: contain;
}

.report-title {
    text-align: right;
}

.report-title h1,
.report-section h2,
.report-section h3 {
    margin: 0;
}

.report-subtitle {
    color: var(--muted);
    margin-top: 4px;
}

.report-section {
    margin-top: 24px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    background: #fff;
}

.report-table th,
.report-table td {
    border: 1px solid #dfe6f1;
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

.report-table th {
    background: #f5f8fc;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.report-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.report-meta-card {
    border: 1px solid #dfe6f1;
    border-radius: 12px;
    padding: 14px;
    background: #fbfdff;
}

.report-meta-card strong,
.report-meta-card span {
    display: block;
}

.report-meta-card span {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

@media print {
    body {
        background: #fff;
    }
    .report-shell {
        padding: 0;
        max-width: none;
    }
}

.modal-bg {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(27, 18, 63, 0.5);
    z-index: 1000;
    padding: 20px;
    overflow: auto;
}

.modal-bg.is-visible {
    display: grid;
    place-items: center;
}

.modal {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,249,253,0.98));
    max-width: 900px;
    width: 100%;
    border-radius: 18px;
    padding: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid #e5ebf3;
}

.modal-small { max-width: 480px; }

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

.modal-header h2 { margin: 0; }

.modal-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: #eef2f8;
    color: var(--text);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.modal-copy {
    display: grid;
    gap: 2px;
    margin-bottom: 16px;
    color: var(--muted);
}

.msg {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    display: none;
}

.msg.show,
.msg.ok,
.msg.error { display: block; }

.msg.ok {
    background: #d9f6e7;
    color: #0f5132;
}

.msg.error {
    background: #ffe0e8;
    color: #8b1e44;
}

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

.inline-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 11px 12px;
    border: 1px solid #d7deea;
    border-radius: 10px;
    background: #fcfdff;
}

.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--text);
    font-size: 14px;
    text-transform: none;
    letter-spacing: normal;
}

.alert-strip {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 1100;
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid #f2cf66;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.app-footer,
.login-footer {
    margin: 16px;
    margin-top: auto;
    padding: 12px 16px;
    border-radius: 14px;
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid #e6ebf3;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.app-footer-brand,
.app-footer-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-footer-brand span,
.app-footer-meta {
    color: var(--muted);
    font-size: 12px;
}

.footer-logo {
    width: 172px;
    height: 48px;
}

.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(217, 90, 154, 0.18), transparent 26%),
        radial-gradient(circle at top right, rgba(67, 88, 216, 0.18), transparent 32%),
        linear-gradient(rgba(19, 27, 52, 0.86), rgba(29, 37, 68, 0.82)),
        url('../img/login-bg.svg') center center / cover no-repeat;
    display: block;
    padding: 24px;
}

.login-shell {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
}

.login-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) 390px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.45);
}

.login-hero {
    min-height: 560px;
    padding: 40px;
    display: flex;
    align-items: flex-end;
    background:
        linear-gradient(180deg, rgba(217, 90, 154, 0.10), rgba(67, 88, 216, 0.18)),
        linear-gradient(135deg, rgba(15, 23, 42, 0.10), rgba(15, 23, 42, 0.52));
}

.login-hero-content {
    max-width: 560px;
    color: #fff;
}

.login-logo-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.login-logo {
    width: 240px;
    height: 68px;
}

.login-hero h1 {
    margin: 0 0 14px;
    font-size: 36px;
    line-height: 1.12;
}

.login-brand {
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #d9e0ff;
    margin-bottom: 0;
}

.login-brand-inline {
    color: var(--primary);
    margin-bottom: 8px;
}

.login-copy {
    color: #d7dff6;
    margin-bottom: 18px;
}

.login-card .login-copy { color: #6b7280; }

.login-feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 24px;
}

.login-feature-card {
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 14px;
    padding: 14px;
    display: grid;
    gap: 6px;
}

.login-feature-card strong {
    font-size: 15px;
    line-height: 1.35;
}

.login-feature-label {
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #bfdbfe;
}

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

.login-card-header h2 {
    margin: 0 0 10px;
    font-size: 28px;
    color: #0f172a;
}

.login-form {
    display: grid;
    gap: 10px;
}

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

.card-highlight {
    background: linear-gradient(135deg, rgba(67, 88, 216, 0.12), rgba(217, 90, 154, 0.08));
}

.field-help {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.system-selector {
    margin-bottom: 20px;
    padding: 16px;
    border: 1px solid #e7ecf4;
    border-radius: 14px;
    background: #f8fbff;
}

.system-selector-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.selection-counter,
.muted-inline {
    color: var(--muted);
    font-size: 12px;
}

.empty-state-inline {
    color: var(--muted);
    font-size: 13px;
    padding: 12px 0;
}

.system-checklist {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}

.system-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid #d9e2f1;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
}

.system-check input {
    margin-top: 3px;
}

.system-check strong,
.system-check span {
    display: block;
}

.system-check span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.tag-chip {
    display: inline-block;
    margin: 2px 6px 2px 0;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4150a8;
    font-size: 12px;
    font-weight: 600;
}

@media (max-width: 991px) {
    .col-4 { width: 50%; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid-span-2 { grid-column: span 1; }
    .stats-grid,
    .detail-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .app { display: block; }
    .sidebar { display: none; width: 100%; }
    .sidebar.show { display: block; }
    .col-4 { width: 100%; }
    .topbar {
        flex-wrap: wrap;
        margin: 12px 12px 0;
        padding: 14px;
    }
    .topbar-primary,
    .topbar-user {
        width: 100%;
    }
    .topbar-brand h1 {
        font-size: 20px;
    }
    .topbar-logo {
        width: 180px;
        height: 52px;
    }
    .topbar-user { justify-content: flex-start; }
    .user-chip { text-align: left; }
    .alert-strip { left: 16px; right: 16px; bottom: 16px; }
    .login-layout { grid-template-columns: 1fr; }
    .login-hero { min-height: auto; padding: 28px 24px; }
    .login-hero h1 { font-size: 30px; }
    .login-feature-grid { grid-template-columns: 1fr; }
    .login-card { padding: 28px 24px; }
    .login-logo {
        width: 210px;
        height: 60px;
    }
    .container { padding: 18px 12px 0; }
    .stats-grid,
    .detail-grid { grid-template-columns: 1fr; }
    .app-footer,
    .login-footer {
        margin: 12px;
        padding: 12px 14px;
    }
    .footer-logo {
        width: 146px;
        height: 42px;
    }
    .app-footer-meta { width: 100%; justify-content: space-between; }
}
