:root {
    color-scheme: dark;
    --ink: #ecf6f4;
    --muted: #9aaeb5;
    --green: #60dfb5;
    --line: #28414a;
    --bg: #0b151b;
    --surface: #14232b;
    --surface-raised: #1a2d36;
    --surface-soft: #102028;
}
* {
    box-sizing: border-box;
}
::selection {
    background: #387c69;
    color: #fff;
}
body {
    margin: 0;
    background: radial-gradient(circle at 85% -15%, #173b3b 0, transparent 38%), var(--bg);
    color: var(--ink);
    font:
        15px/1.55 system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}
a {
    color: var(--green);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 18px 5%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    font-size: 26px;
    font-weight: 750;
    letter-spacing: -1px;
}
.brand-icon {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #65e8bc, #23a987);
    color: #09221f;
    width: 37px;
    height: 37px;
    border-radius: 11px;
    font-size: 23px;
}
.brand-sub {
    letter-spacing: 1px;
    font-size: 9px;
    color: var(--muted);
    margin-left: 9px;
}
nav {
    display: flex;
    align-items: center;
    gap: 24px;
}
nav a {
    color: var(--ink);
    font-size: 14px;
}
nav form {
    margin: 0;
}
.container {
    max-width: 1220px;
    margin: 0 auto;
    padding: 44px 24px;
    min-height: 80vh;
}
h1 {
    font-size: 32px;
    line-height: 1.2;
    letter-spacing: -1px;
    margin: 8px 0 12px;
}
h2 {
    font-size: 19px;
    margin: 12px 0;
}
p {
    margin: 8px 0 18px;
}
.muted,
small {
    color: var(--muted);
}
small {
    display: block;
    font-size: 12px;
    margin-top: 6px;
}
.small {
    font-size: 13px;
}
.eyebrow {
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--green);
    font-weight: 750;
    margin: 0;
}
.page-heading,
.row,
.actions,
.save-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.page-heading {
    margin-bottom: 28px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 26px;
    box-shadow: 0 12px 32px #020b1040;
}
.org-card {
    transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}
.org-card:hover {
    border-color: #397768;
    box-shadow: 0 18px 40px #020b1060;
    transform: translateY(-2px);
}
.org-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}
.org-card .row {
    margin-bottom: 18px;
}
.org-icon {
    display: grid;
    place-items: center;
    background: #183c37;
    color: var(--green);
    width: 44px;
    height: 44px;
    border-radius: 13px;
    font-size: 22px;
    font-weight: 700;
}
.badge {
    display: inline-block;
    background: #263941;
    color: #b3c4ca;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 11px;
}
.badge.active {
    background: #164336;
    color: #8af1bf;
}
.org-card dl {
    font-size: 13px;
    margin: 22px 0;
}
.org-card dl div {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}
.org-card dt {
    color: var(--muted);
}
.org-card dd {
    margin-left: 12px;
    overflow-wrap: anywhere;
}
.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-raised);
    color: var(--ink);
    font: 600 13px system-ui;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 150ms ease, border-color 150ms ease, filter 150ms ease, transform 150ms ease;
}
.button:hover,
button:hover {
    filter: brightness(1.12);
    transform: translateY(-1px);
    text-decoration: none;
}
.primary {
    background: linear-gradient(135deg, #67e6bc, #37cda5);
    border-color: #57dbb2;
    color: #09221f;
}
.quiet {
    border: 0;
    color: var(--muted);
    background: transparent;
}
.full {
    width: 100%;
}
button:disabled {
    opacity: 0.5;
    cursor: wait;
}
.login-card {
    max-width: 440px;
    margin: 40px auto;
}
.login-card form {
    margin: 30px 0;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 18px 0;
}
input,
select,
textarea {
    display: block;
    width: 100%;
    border: 1px solid #36515a;
    background: var(--surface-soft);
    border-radius: 8px;
    padding: 11px 12px;
    margin-top: 6px;
    color: var(--ink);
    font: 14px system-ui;
    transition: border-color 150ms ease, background 150ms ease;
}
input::placeholder,
textarea::placeholder {
    color: #8199a2;
    opacity: 1;
}
input:hover,
select:hover,
textarea:hover {
    border-color: #4f766d;
}
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--green);
    outline-offset: 1px;
}
input[readonly] {
    background: #1d3037;
    color: var(--muted);
}
input[type="file"] {
    padding: 13px;
    font-size: 12px;
}
.save-bar {
    padding: 25px 0;
}
.save-bar p {
    margin: 0;
}
.notice {
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 25px;
}
.notice.success {
    background: #174334;
    color: #b9f5d7;
}
.notice.error {
    background: #43282b;
    color: #ffc2b9;
}
.notice ul {
    margin-bottom: 0;
}
.empty {
    grid-column: 1/-1;
    text-align: center;
    padding: 60px;
}
.filters {
    display: flex;
    gap: 14px;
    margin-bottom: 20px;
    align-items: center;
}
.filters select {
    max-width: 280px;
    margin: 0;
}
.table-wrap {
    overflow: auto;
    padding: 0;
}
table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
    white-space: nowrap;
}
th,
td {
    padding: 17px 20px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}
th {
    background: #1b3038;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
tbody tr:hover {
    background: #1b3038;
}
pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #0d1d25;
    border-radius: 8px;
    padding: 16px;
    font:
        13px/1.65 ui-monospace,
        monospace;
    max-height: 600px;
    overflow: auto;
}
.pagination {
    margin-top: 20px;
}
.pagination svg {
    width: 20px;
    height: 20px;
}
.pagination nav {
    display: block;
}
footer {
    text-align: center;
    color: var(--muted);
    padding: 25px;
    font-size: 12px;
}
.chat-shell {
    max-width: 900px;
    margin: auto;
}
.chat-settings {
    margin-bottom: 20px;
}
.chat-settings summary {
    cursor: pointer;
    font-weight: 600;
}
.chat-settings label {
    margin: 12px 0;
}
.chat-feed {
    min-height: 300px;
    max-height: 60vh;
    overflow: auto;
    padding: 12px 0;
}
.bubble {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 16px 20px;
    margin: 12px 0;
    max-width: 90%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.bubble.user {
    background: #164437;
    margin-left: auto;
    border-color: #2a715b;
}
.bubble.error {
    color: #ffc2b9;
    border-color: #a45458;
}
.compose {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    align-items: end;
}
.compose textarea {
    resize: vertical;
    min-height: 54px;
    max-height: 200px;
    margin: 0;
}
.confirmation {
    border: 1px solid #8e7649;
    background: #30291e;
    border-radius: 12px;
    padding: 20px;
    margin: 15px 0;
}
.confirmation .actions {
    justify-content: flex-start;
}
.confirmation pre {
    background: #211e1a;
}
.prose {
    max-width: 850px;
}
.prose h2 {
    margin-top: 30px;
}
@media (max-width: 700px) {
    .topbar {
        align-items: flex-start;
        padding: 16px 20px;
        flex-direction: column;
    }
    nav {
        gap: 14px;
        flex-wrap: wrap;
    }
    .brand-sub {
        display: none;
    }
    .container {
        padding: 28px 16px;
    }
    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }
    h1 {
        font-size: 27px;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .save-bar {
        align-items: flex-start;
        flex-direction: column;
    }
    .org-grid {
        grid-template-columns: 1fr;
    }
    .filters {
        flex-wrap: wrap;
    }
    .card {
        padding: 20px;
    }
    .table-wrap {
        padding: 0;
    }
    .compose {
        gap: 8px;
    }
    .bubble {
        max-width: 96%;
    }
}

/* Administration */
.app-shell {
    display: grid;
    grid-template-columns: 258px minmax(0, 1fr);
    min-height: 100vh;
}
.sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: #101f27;
    border-right: 1px solid var(--line);
    padding: 29px 17px 20px;
}
.sidebar-brand,
.login-brand,
.mobile-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    font-size: 25px;
    font-weight: 760;
    letter-spacing: -1px;
}
.sidebar-brand {
    margin: 0 10px 52px;
}
.sidebar-brand:hover {
    text-decoration: none;
}
.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.08;
}
.sidebar-brand-text span {
    margin-top: 6px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
}
.sidebar-content {
    flex: 1;
    overflow-y: auto;
}
.sidebar-label {
    margin: 0 13px 13px;
    color: #8299a2;
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 1.5px;
}
.sidebar-label-spaced {
    margin-top: 33px;
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}
.sidebar-link,
.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 13px;
    width: 100%;
    min-height: 44px;
    padding: 10px 13px;
    border: 0;
    border-radius: 10px;
    color: #a8bac0;
    background: transparent;
    font-size: 13px;
    font-weight: 650;
    white-space: normal;
    transition: background 150ms ease, color 150ms ease;
}
.sidebar-link:hover,
.sidebar-logout:hover {
    background: #20373e;
    color: var(--ink);
    text-decoration: none;
    filter: none;
}
.sidebar-link.is-active {
    background: #174438;
    color: #9cf4c8;
    font-weight: 750;
}
.sidebar-link.is-active::after {
    content: "";
    width: 6px;
    height: 6px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--green);
}
.sidebar-link svg,
.sidebar-logout svg,
.mobile-menu-toggle svg {
    flex: none;
    width: 19px;
    height: 19px;
}
.sidebar-bottom {
    padding-top: 17px;
    border-top: 1px solid var(--line);
}
.sidebar-account {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 10px 13px;
    min-width: 0;
}
.account-avatar {
    display: grid;
    flex: none;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    color: #9cf4c8;
    background: #174438;
    font-weight: 750;
}
.account-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}
.account-meta strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}
.account-meta small {
    margin-top: 3px;
    font-size: 11px;
}
.sidebar-bottom form {
    margin: 0;
}
.sidebar-logout {
    cursor: pointer;
}
.workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.admin-page .container {
    width: 100%;
    max-width: 1320px;
    flex: 1;
    margin: 0 auto;
    min-height: 0;
    padding: 46px clamp(24px, 4vw, 64px);
}
.workspace-footer {
    padding: 20px 24px 28px;
    color: #8299a2;
    font-size: 11px;
}
.mobile-topbar,
.mobile-menu-toggle,
.sidebar-overlay {
    display: none;
}

/* Connexion sans navigation */
.login-page {
    background: radial-gradient(circle at 50% -30%, #24534b 0, #0b151b 55%);
}
.login-shell {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: min(100% - 32px, 460px);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: 36px 0;
}
.login-brand {
    justify-content: center;
    margin-bottom: 29px;
}
.login-brand .brand-icon {
    width: 42px;
    height: 42px;
}
.login-page .login-card {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 34px;
    border-radius: 18px;
    box-shadow: 0 28px 65px #020b1080;
}
.login-page .login-card h1 {
    margin-top: 10px;
}
.login-page .login-card form {
    margin: 27px 0 19px;
}
.login-page .login-card label {
    margin: 15px 0;
}
.login-page .login-card .full {
    margin-top: 22px;
    min-height: 46px;
}
.login-footer {
    margin: 25px 0 0;
    color: #8299a2;
    text-align: center;
    font-size: 11px;
}
.admin-page :focus-visible,
.login-page :focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
    .org-card,
    .button,
    button,
    input,
    select,
    textarea {
        transition: none;
    }
    .org-card:hover,
    .button:hover,
    button:hover {
        transform: none;
    }
}
.sample-files {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: -5px 0 24px;
    padding: 16px 20px;
    border: 1px solid #2c6255;
    border-radius: 12px;
    background: #17372f;
}
.sample-files strong {
    font-size: 13px;
}
.sample-files p {
    margin: 3px 0 0;
}
.sample-files .actions {
    flex: none;
    flex-wrap: wrap;
    justify-content: flex-start;
}
.sample-files .button {
    border-color: #3c7967;
    color: #a2efc9;
}

@media (max-width: 850px) {
    .app-shell {
        display: block;
    }
    .workspace {
        min-height: 100vh;
        min-height: 100dvh;
    }
    .sidebar {
        position: fixed;
        width: min(280px, 86vw);
        box-shadow: 12px 0 35px #020b1080;
        transform: translateX(-105%);
        transition: transform 200ms ease;
    }
    .sidebar-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 20;
        width: 100%;
        height: 100%;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: #020b10b8;
    }
    .sidebar-open .sidebar-overlay {
        display: block;
    }
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 66px;
        padding: 10px 24px;
        background: #101f27;
        border-bottom: 1px solid var(--line);
    }
    .mobile-menu-toggle {
        display: inline-flex;
        width: 38px;
        height: 38px;
        padding: 0;
    }
    .mobile-brand {
        font-size: 20px;
    }
    .mobile-brand .brand-icon {
        width: 30px;
        height: 30px;
        border-radius: 8px;
        font-size: 18px;
    }
    .admin-page .container {
        padding: 30px 24px;
    }
    .sample-files {
        align-items: flex-start;
        flex-direction: column;
    }
}
@media (max-width: 480px) {
    .mobile-topbar {
        padding: 10px 16px;
    }
    .admin-page .container {
        padding: 26px 16px;
    }
    .login-page .login-card {
        padding: 26px 22px;
    }
    .org-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .empty {
        min-width: 0;
        padding: 28px 18px;
    }
    .empty h2,
    .empty p {
        overflow-wrap: anywhere;
    }
}
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-link,
    .sidebar-logout {
        transition: none;
    }
}
