/* Charte Komgo (tokens repris du design system GTK : couleurs, Roboto,
   header blanc à ombre légère, accent bleu). Structure de classes inchangée. */
:root {
    --primary: #242e3e;
    --primary-hover: #1c2636;
    --accent: #4279d5;
    --accent-hover: #3567bd;
    --bg: #f2f5f8;
    --card: #ffffff;
    --text: #242e3e;
    --muted: #667085;
    --danger: #b42318;
    --success: #067647;
    --border: #e4e9f0;
    --hover-bg: #e8edf5;
    --input-shadow: 0 1px 4px rgba(36, 46, 62, 0.2);
    --header-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.11);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Roboto', BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--accent);
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card {
    background: var(--card);
    border: none;
    border-radius: 8px;
    box-shadow: var(--header-shadow);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.card .login-logo {
    height: 44px;
    margin-bottom: 1rem;
    display: block;
}

.card h1 {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--primary);
}

.card .subtitle {
    margin: 0 0 1.5rem;
    color: var(--muted);
    font-size: 0.875rem;
}

label {
    display: block;
    margin: 0.75rem 0 0.25rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="date"] {
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--card);
    box-shadow: var(--input-shadow);
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}

input:disabled {
    background: var(--bg);
    box-shadow: none;
    border-color: var(--border);
    color: var(--muted);
}

button.primary {
    margin-top: 1.25rem;
    width: 100%;
    padding: 0.55rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
}

button.primary:hover {
    background: var(--accent-hover);
}

.alert {
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert.error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert.success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

.topbar {
    background: var(--card);
    box-shadow: var(--header-shadow);
    min-height: 55px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 10;
}

.topbar .brand {
    font-weight: 500;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.brand-logo {
    height: 28px;
    display: block;
}

.topbar .user {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.topbar .user a {
    color: var(--primary);
    text-decoration: none;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
}

.topbar .user a:hover {
    background: var(--hover-bg);
}

.topbar form {
    margin: 0;
}

.topbar button.link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    padding: 0;
}

main.content {
    padding: 2rem 1.5rem;
    max-width: 960px;
    margin: 0 auto;
}

main.content.narrow {
    max-width: 680px;
}

.topbar .brand a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.page-head h2 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0.5rem 0;
    font-weight: 500;
}

h2, h3 {
    font-weight: 500;
    color: var(--primary);
}

.kb-logo {
    height: 32px;
    max-width: 96px;
    object-fit: contain;
}

a.button {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

a.button:hover {
    background: var(--accent-hover);
}

button.secondary,
button.danger {
    padding: 0.45rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
}

button.secondary:hover {
    background: var(--hover-bg);
}

button.danger {
    border-color: #fecaca;
    color: var(--danger);
}

button.danger:hover {
    background: #fef2f2;
}

.actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.actions form {
    margin: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--input-shadow);
    font-size: 0.875rem;
}

th, td {
    text-align: left;
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid var(--border);
}

th {
    background: #f4f8fb;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

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

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge.active {
    background: #ecfdf3;
    color: var(--success);
    border: 1px solid #abefc6;
}

.badge.suspended {
    background: #fef3f2;
    color: var(--danger);
    border: 1px solid #fecdca;
}

.badge.draft {
    background: #eff8ff;
    color: var(--accent);
    border: 1px solid #b2ddff;
}

.hint {
    color: var(--muted);
    font-size: 0.8125rem;
}

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

section {
    background: var(--card);
    border: none;
    border-radius: 8px;
    box-shadow: var(--input-shadow);
    padding: 1.25rem 1.5rem;
    margin: 1.25rem 0;
}

section h3 {
    margin-top: 0;
}

section table {
    box-shadow: none;
    border: 1px solid var(--border);
}

.secret-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 1.25rem 0;
}

.secret-box h3 {
    margin-top: 0;
    color: #92400e;
    font-size: 0.9375rem;
}

dl {
    margin: 0;
}

dt {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    margin-top: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

dd {
    margin: 0.1rem 0 0;
}

code {
    background: var(--hover-bg);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    word-break: break-all;
}

.secret-box code {
    background: #fef3c7;
}

.tenant-chip {
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border);
    font-weight: 400;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.tenant-logo {
    height: 20px;
    max-width: 60px;
    object-fit: contain;
}

.tenant-switch select,
td select {
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--card);
}

.tenant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.tenant-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 1rem;
    background: var(--card);
    border: none;
    border-radius: 8px;
    box-shadow: var(--input-shadow);
    cursor: pointer;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text);
}

.tenant-card:hover {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.tenant-card-logo {
    height: 48px;
    max-width: 140px;
    object-fit: contain;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.menu-card {
    display: block;
    background: var(--card);
    border: none;
    border-radius: 8px;
    box-shadow: var(--input-shadow);
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    color: var(--text);
}

.menu-card h3 {
    margin: 0 0 0.4rem;
    color: var(--primary);
    font-size: 1rem;
}

.menu-card:hover:not(.disabled) {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.menu-card.disabled {
    opacity: 0.55;
}

.menu-card.new-card {
    box-shadow: none;
    border: 1px dashed var(--border);
}

.counts {
    margin: 0.5rem 0 0;
    font-size: 0.8125rem;
}

button.primary.small {
    margin-top: 0;
    width: auto;
    padding: 0.45rem 0.8rem;
    font-size: 0.8125rem;
}

textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    resize: vertical;
    background: var(--card);
    box-shadow: var(--input-shadow);
}

form select {
    width: 100%;
    padding: 0.5rem 0.4rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--card);
    box-shadow: var(--input-shadow);
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.inline-form > div {
    flex: 1;
    min-width: 160px;
}

.inline-form label {
    margin-top: 0;
}

.inline-form button.primary {
    margin-top: 0;
    width: auto;
    padding: 0.55rem 1.2rem;
}

td .actions {
    display: inline-flex;
    gap: 0.5rem;
}

td form {
    margin: 0;
}

.fields-builder input[type="text"] {
    width: 100%;
}

.fields-builder select {
    width: auto;
}

.fields-builder td {
    vertical-align: middle;
}
