:root {
    /* Palette reprise des design tokens Kintai (--light-primary etc.) pour une
       identite visuelle coherente entre les deux apps. */
    --bg: #f6f5fa;
    --surface: #ffffff;
    --border: #e7e5f0;
    --text: #1d1b2e;
    --text-muted: #6e6b85;
    --primary: #ff9f4a;
    --primary-dark: #5b4a3a;
    --primary-light: #fff5e6;
    --sidebar-bg: #1d1b2e;
    --sidebar-text: #c7c3d6;
    --success: #1fae6b;
    --success-bg: #e2f6ec;
    --warning: #c97a12;
    --warning-bg: #fbedd9;
    --danger: #e5484d;
    --danger-bg: #fce3e4;
    --neutral-bg: #f1eff8;
    --radius: 10px;
    --shadow: 0 2px 6px rgba(29, 27, 46, .06), 0 1px 2px rgba(29, 27, 46, .04);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    padding: 6px 10px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar .brand-mascot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(255, 159, 74, .35);
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.sidebar a.nav-link {
    color: var(--sidebar-text);
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
}

.sidebar a.nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.sidebar a.nav-link.active {
    background: var(--primary);
    color: #fff;
}

.sidebar .sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, .1);
    padding-top: 12px;
    font-size: 12.5px;
    color: #8a8d99;
}

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

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar h1 {
    font-size: 18px;
    margin: 0;
    font-weight: 650;
}

.topbar .subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

.content {
    padding: 24px 28px 60px;
    flex: 1;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 26px;
    font-weight: 700;
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 12.5px;
    margin-top: 2px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h2 {
    font-size: 15px;
    margin: 0;
    font-weight: 650;
}

.card-body {
    padding: 20px;
}

.card-body.no-pad {
    padding: 0;
}

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

th,
td {
    text-align: left;
    padding: 11px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    vertical-align: middle;
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

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

tbody tr:hover {
    background: #fafafa;
}

.table-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.badge-active {
    background: var(--success-bg);
    color: var(--success);
}

.badge-expired {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-suspended {
    background: var(--neutral-bg);
    color: var(--text-muted);
}

.badge-revoked {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-type {
    background: #eef2ff;
    color: var(--primary-dark);
}

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

.badge-limit {
    background: var(--neutral-bg);
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: normal;
    font-weight: 500;
    font-family: monospace;
    font-size: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    background: #f8f8f9;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-danger {
    color: var(--danger);
    border-color: #f5c2c2;
}

.btn-danger:hover {
    background: var(--danger-bg);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12.5px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin: 14px 0 6px;
}

label:first-of-type {
    margin-top: 0;
}

input[type=text],
input[type=password],
input[type=email],
input[type=number],
input[type=date],
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 159, 74, .20);
}

.form-hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.limits-editor .limits-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.limits-row {
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--neutral-bg);
    padding: 0.5rem;
    display: flex;
    gap: 8px;
    align-items: center;
}

.limits-row input[data-limits-key] {
    flex: 1;
}

.limits-row input[data-limits-value] {
    width: 130px;
}

.limits-editor [data-limits-add] {
    margin-top: 8px;
}

.limits-key-label {
    flex: 1;
    font-size: 13.5px;
    color: var(--text);
}

.alert {
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 16px;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.alert-info {
    background: #eff6ff;
    color: #1d4ed8;
}

.key-box {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background: #f6f7f9;
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 14px;
    letter-spacing: .03em;
    word-break: break-all;
}

code.inline-key {
    font-family: 'SFMono-Regular', Consolas, monospace;
    background: #f6f7f9;
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 12.5px;
}

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

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #14161f, #23263a);
}

.auth-card {
    width: 340px;
    background: var(--surface);
    border-radius: 14px;
    padding: 32px 28px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}

.auth-card h1 {
    font-size: 19px;
    margin: 0 0 2px;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 0 18px;
}

.auth-mascot {
    display: block;
    width: 96px;
    height: auto;
    margin: 0 auto 12px;
}

.error-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 24px;
}

.error-page .mascot {
    width: 200px;
    height: auto;
    margin-bottom: 4px;
}

.error-page .code {
    font-size: 56px;
    font-weight: 800;
    color: var(--primary);
}

.empty-state {
    padding: 32px 20px 28px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state .mascot {
    width: 130px;
    height: auto;
    margin: 0 auto 10px;
    display: block;
}

.empty-state p {
    margin: 0 0 4px;
}