:root {
    --navy-950: #102747;
    --navy-900: #163763;
    --navy-800: #1f4679;
    --navy-700: #24558d;
    --blue-600: #2563eb;
    --sky-500: #38a4d8;
    --workspace: #eef4fb;
    --surface: #ffffff;
    --surface-soft: #f8fbff;
    --line: #d9e4f1;
    --line-strong: #b9cbe0;
    --text: #071529;
    --muted: #657694;
    --muted-strong: #40536f;
    --success-bg: #e8fbf0;
    --success-text: #047857;
    --warning-bg: #fff6d6;
    --warning-text: #9a5b00;
    --danger-bg: #fff0f0;
    --danger-text: #b42318;
    --shadow-soft: 0 12px 30px rgba(28, 60, 103, 0.08);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--workspace);
    letter-spacing: 0;
}

a {
    color: inherit;
}

.app-shell {
    display: flex;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: 220px;
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(180deg, var(--navy-800) 0%, var(--navy-950) 100%);
    color: rgba(255, 255, 255, 0.85);
}

.brand-card {
    display: flex;
    height: 58px;
    margin: 8px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 10px;
    background: linear-gradient(180deg, #ffffff 0%, #f2f6fb 100%);
    box-shadow: 0 8px 20px rgba(4, 15, 36, 0.16);
}

.brand-mark {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border: 2px solid #169bd5;
    border-radius: 50%;
    color: #155da8;
    font-size: 9px;
    font-weight: 800;
}

.brand-name {
    color: #1164b3;
    font-size: 12px;
    font-weight: 800;
}

.workspace-label,
.nav-heading {
    margin: 10px 9px 5px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.workspace-name {
    margin: 0 9px 12px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 800;
}

.sidebar-search {
    display: flex;
    min-height: 42px;
    margin: 0 8px 12px;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(209, 226, 249, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    padding: 0 12px;
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-search span {
    font-size: 12px;
    font-weight: 800;
}

.sidebar-search input {
    min-width: 0;
    width: 100%;
    border: 0;
    background: transparent;
    color: #ffffff;
    font-size: 13px;
    outline: 0;
}

.sidebar-search input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.side-nav {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 10px;
    scrollbar-color: rgba(255, 255, 255, 0.45) transparent;
    scrollbar-width: thin;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    min-height: 36px;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item:hover,
.nav-item.is-active {
    background: rgba(255, 255, 255, 0.11);
    color: #ffffff;
}

.nav-icon {
    display: grid;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 5px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 10px;
    font-weight: 800;
}

.sidebar-footer {
    border-top: 1px solid rgba(218, 232, 251, 0.12);
    padding: 12px 8px 10px;
}

.user-mini {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.avatar {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: #ecf5ff;
    color: var(--navy-900);
    font-size: 12px;
    font-weight: 900;
}

.user-name {
    max-width: 150px;
    overflow: hidden;
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role {
    max-width: 150px;
    overflow: hidden;
    color: #9fb8d8;
    font-size: 11px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sign-out,
.help-link {
    width: 100%;
    min-height: 32px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 800;
}

.sign-out {
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: transparent;
    color: #ffffff;
    cursor: pointer;
}

.help-link {
    display: flex;
    align-items: center;
    margin-top: 10px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.06);
    color: #d8e7fb;
}

.copyright {
    margin: 10px 0 0;
    color: #8da4c5;
    font-size: 10px;
    line-height: 1.35;
}

.app-main {
    width: calc(100% - 220px);
    min-height: 100vh;
    margin-left: 220px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    min-height: 50px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    padding: 5px 18px 7px 26px;
}

.topbar h1 {
    margin: 0 0 4px;
    color: var(--text);
    font-size: 16px;
    font-weight: 900;
    line-height: 1.1;
}

.breadcrumbs {
    color: var(--muted);
    font-size: 12px;
}

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

.notification-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #ffffff;
    cursor: pointer;
}

.notification-btn::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 12px;
    width: 12px;
    height: 14px;
    border: 1.8px solid var(--navy-800);
    border-bottom: 0;
    border-radius: 8px 8px 2px 2px;
}

.notification-btn span {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #e5484d;
}

.module-tabs {
    display: flex;
    gap: 4px;
    padding: 0 30px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    overflow-x: auto;
}

.module-tab {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 13px 16px 11px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--muted-strong);
    border-bottom: 2px solid transparent;
}

.module-tab:hover {
    color: var(--navy-900);
}

.module-tab.is-active {
    color: var(--navy-900);
    border-bottom-color: var(--sky-500);
}

.content {
    padding: 34px 30px 48px;
}

.card {
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    overflow-x: auto;
    padding: 24px;
    box-shadow: var(--shadow-soft);
}

.card h1,
.content > h1 {
    margin: 0 0 6px;
    color: var(--text);
    font-size: 22px;
    font-weight: 900;
    line-height: 1.18;
}

.card h2,
.content h2 {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 16px;
    font-weight: 850;
}

p.subtitle {
    margin: 0 0 22px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.muted {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.review-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 18px 20px;
    margin-bottom: 16px;
}

/* Groups an <a class="btn"> next to one or more single-button <form>s in a table
   action cell so they align on a common center line — a bare <form> defaults to
   display:block (stacking) and an inline-block form's baseline drifts a few px
   from a sibling <a>, both of which read as "buttons not aligned." */
.action-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.action-group form {
    display: inline-flex;
}

.notification-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 10px;
    background: var(--surface);
    transition: border-color .15s, background .15s;
}

.notification-item.is-unread {
    border-color: var(--sky-500);
    border-left-width: 3px;
    background: var(--surface-soft);
}

.btn.is-loading,
.btn-outline.is-loading,
.btn-danger.is-loading {
    cursor: default;
    opacity: .75;
}

.btn-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 7px;
    vertical-align: -2px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: btn-spin .6s linear infinite;
}

.btn-outline .btn-spinner {
    border-color: rgba(22, 55, 99, .25);
    border-top-color: var(--navy-900);
}

@keyframes btn-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn-spinner {
        animation: none;
    }
}

.review-item + .review-item {
    margin-top: 0;
}

.review-item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.review-item-section {
    margin-bottom: 12px;
}

.review-item-section > label:first-child {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: 6px;
}

.review-item-decision {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.review-item-decision label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
}

.chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.chip.good {
    background: var(--success-bg);
    color: var(--success-text);
}

.chip.warn {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.chip.crit {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.chip.neutral {
    background: var(--workspace);
    color: var(--muted-strong);
}

.btn {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--navy-900);
    border-radius: 7px;
    background: var(--navy-900);
    color: #ffffff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    padding: 0 16px;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    white-space: nowrap;
}

.btn:hover {
    background: var(--navy-800);
    border-color: var(--navy-800);
}

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

.btn-sm {
    min-height: 30px;
    padding: 0 12px;
    font-size: 12px;
}

.btn-outline {
    border-color: var(--line-strong);
    background: #ffffff;
    color: var(--navy-900);
}

.btn-outline:hover {
    border-color: #9db5d0;
    background: #f7fbff;
    color: var(--navy-900);
}

.btn-danger {
    border-color: #b42318;
    background: #b42318;
}

.flash,
.errors {
    margin-bottom: 16px;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 700;
}

.flash {
    border: 1px solid #bae8ce;
    background: var(--success-bg);
    color: var(--success-text);
}

.errors {
    border: 1px solid #ffc9c9;
    background: var(--danger-bg);
    color: var(--danger-text);
}

.errors ul {
    margin: 0;
    padding-left: 18px;
}

.status {
    display: inline-flex;
    min-height: 22px;
    align-items: center;
    border-radius: 999px;
    background: #eef5ff;
    color: var(--navy-800);
    font-size: 11px;
    font-weight: 900;
    margin: 2px 4px 2px 0;
    padding: 0 10px;
}

.status-submitted {
    background: #eaf4ff;
    color: #075985;
}

.status-approved,
.status-survey_completed {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-rejected {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.status-needs_changes {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.status-survey_not_required {
    background: #edf2f7;
    color: #475569;
}

.status-survey_sent {
    background: var(--warning-bg);
    color: var(--warning-text);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text);
    font-size: 13px;
}

.card > table,
.card form > table {
    min-width: 760px;
}

thead th {
    border-bottom: 1px solid var(--line);
    background: #f6f9fd;
    color: var(--muted-strong);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.06em;
    padding: 11px 12px;
    text-align: left;
    text-transform: uppercase;
}

tbody td {
    border-bottom: 1px solid #e8eff7;
    padding: 12px;
    vertical-align: top;
}

tbody tr:hover td {
    background: #fbfdff;
}

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

label {
    display: block;
    margin-bottom: 5px;
    color: #344863;
    font-size: 12px;
    font-weight: 800;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-height: 36px;
    margin-bottom: 14px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    outline: 0;
    padding: 8px 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

input[type="radio"],
input[type="checkbox"] {
    width: auto;
    margin: 0 6px 0 0;
    accent-color: var(--navy-800);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--sky-500);
    box-shadow: 0 0 0 3px rgba(56, 164, 216, 0.16);
}

fieldset {
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 16px;
}

legend {
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 900;
    padding: 0 6px;
}

.row {
    display: flex;
    gap: 16px;
}

.row > div {
    flex: 1;
    min-width: 0;
}

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

.app-card {
    display: flex;
    min-height: 170px;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    padding: 22px;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.app-card:hover {
    border-color: #9ed5f4;
    box-shadow: 0 18px 35px rgba(19, 69, 117, 0.11);
    transform: translateY(-1px);
}

.app-card.is-preferred {
    border-color: #a9daf7;
    background: linear-gradient(180deg, #fbfeff 0%, #f5fbff 100%);
}

.app-card-title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 900;
}

.app-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.workspace-intro {
    margin-bottom: 22px;
}

.workspace-intro h1 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 900;
}

.app-card-desc {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.pill {
    display: inline-flex;
    min-height: 22px;
    align-items: center;
    border-radius: 999px;
    background: #e8fbf0;
    color: #047857;
    font-size: 11px;
    font-weight: 900;
    padding: 0 10px;
}

.pill-blue {
    background: #eaf4ff;
    color: #1264a3;
}

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

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.table-wrap table {
    min-width: 760px;
}

@media (max-width: 1180px) {
    .app-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .sidebar {
        position: static;
        width: 100%;
        max-height: none;
    }

    .side-nav {
        display: flex;
        max-height: none;
        overflow-x: auto;
        padding: 0 8px 12px;
    }

    .nav-section {
        min-width: 190px;
        margin-bottom: 0;
    }

    .nav-heading {
        margin-top: 0;
    }

    .sidebar-footer,
    .sidebar-search {
        display: none;
    }

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

    .topbar {
        position: static;
        align-items: flex-start;
        gap: 12px;
        padding: 14px 16px;
    }

    .content {
        padding: 22px 16px 36px;
    }

    .card {
        padding: 18px;
    }

    .row,
    .card-toolbar {
        flex-direction: column;
    }

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

@media (max-width: 560px) {
    .brand-card {
        height: 48px;
        margin-bottom: 6px;
    }

    .workspace-label,
    .workspace-name {
        margin-left: 12px;
    }

    .topbar {
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .topbar-actions .btn {
        flex: 1;
    }

    .content {
        padding: 18px 12px 30px;
    }

    .card h1,
    .content > h1,
    .workspace-intro h1 {
        font-size: 19px;
    }

    .card-toolbar,
    .card > div[style*="justify-content:space-between"] {
        align-items: stretch !important;
    }

    .card > div[style*="justify-content:space-between"] {
        flex-direction: column;
        gap: 14px;
    }

    .btn {
        width: 100%;
        white-space: normal;
    }

    .btn-sm {
        width: auto;
    }

    .app-card {
        min-height: 0;
        padding: 18px;
    }

    .app-card-head {
        display: block;
    }
}

/* Survey question rendering */

.survey-question-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 16px;
    background: var(--surface);
}

.survey-question-card label:first-of-type {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 10px;
    display: block;
}

.choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.choice-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    background: var(--surface-soft);
    transition: border-color .15s, background .15s;
}

.choice-card:hover {
    border-color: var(--sky-500);
}

.choice-card input {
    width: auto;
    margin: 0;
    accent-color: var(--navy-900);
}

.choice-card:has(input:checked) {
    border-color: var(--navy-900);
    background: var(--workspace);
}

.nps-scale-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.nps-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}

.nps-btn:hover {
    border-color: var(--sky-500);
}

.nps-btn.is-selected {
    background: var(--navy-900);
    border-color: var(--navy-900);
    color: #ffffff;
}

.nps-scale-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
}

.rating-stars {
    display: flex;
    gap: 4px;
}

.star-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 30px;
    line-height: 1;
    color: var(--line-strong);
    cursor: pointer;
    transition: color .15s, transform .1s;
}

.star-btn:hover {
    transform: scale(1.1);
}

.star-btn.is-filled {
    color: #f5a623;
}

@media (max-width: 560px) {
    .nps-btn {
        width: 30px;
        height: 30px;
        font-size: 11px;
    }
}
