:root { --sidebar-width: 270px; --mobile-sidebar-width: min(82vw, 320px); }
html, body { max-width: 100%; overflow-x: hidden; }
body { background: #f5f7fb; color: #20293a; letter-spacing: 0; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef3fb; }
.login-panel { width: min(430px, 100%); background: #fff; border: 1px solid #dfe6f1; border-radius: 8px; padding: 32px; box-shadow: 0 .7rem 2rem rgba(23,32,51,.08); }
.login-panel h1 { font-size: 1.7rem; margin: 0 0 .25rem; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 8px; background: #0d6efd; color: #fff; font-size: 1.45rem; margin-bottom: 18px; }
.code-input { font-size: 1.2rem; letter-spacing: .18em; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); max-width: 100vw; background: #172033; color: #fff; overflow-y: auto; z-index: 1030; }
.sidebar .brand { min-height: 72px; }
.sidebar .nav-link { color: #aeb8ca; border-radius: 6px; margin: .15rem .75rem; }
.sidebar .nav-link:hover, .sidebar .nav-link.active { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(17, 24, 39, .48); z-index: 1025; }
.main { margin-left: var(--sidebar-width); min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 1020; backdrop-filter: blur(8px); background: rgba(255,255,255,.92); }
.database-picker { width: min(390px, 36vw); flex: 0 1 390px; }
.database-picker .form-select { min-width: 210px; }
.content-band, .stat-card { background: #fff; border: 1px solid #e4eaf3; border-radius: 8px; box-shadow: 0 .35rem 1.4rem rgba(23,32,51,.06); padding: 20px; }
.icon-box { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 8px; flex: 0 0 auto; }
.status-dot { width: .55rem; height: .55rem; display: inline-block; border-radius: 50%; }
.quick-card { border: 1px solid #e4eaf3; border-radius: 8px; background: #fff; height: 100%; transition: box-shadow .15s ease, transform .15s ease; }
.quick-card:hover { transform: translateY(-2px); box-shadow: 0 .5rem 1rem rgba(23,32,51,.08); }
.resource-table, .logs-table { overflow-x: visible; }
.resource-table .table, .logs-table .table { width: 100%; table-layout: fixed; }
.resource-table th, .resource-table td, .logs-table th, .logs-table td { vertical-align: top; overflow-wrap: anywhere; }
.cell-preview { max-width: 100%; overflow: visible; text-overflow: clip; white-space: normal; }
.json-textarea { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; min-height: 120px; }
.modal-dialog-scrollable .modal-content { max-height: calc(100vh - 3.5rem); }
.modal-dialog-scrollable .modal-body { overflow-y: scroll; max-height: calc(100vh - 12rem); scrollbar-gutter: stable; }
.array-editor { border: 1px solid #d8e1ee; border-radius: 8px; padding: 12px; background: #fbfdff; }
.array-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.array-row { border: 1px solid #e4eaf3; border-radius: 8px; padding: 10px; background: #fff; margin-top: 8px; }
.array-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.array-empty { border: 1px dashed #cfd8e6; border-radius: 8px; padding: 12px; background: #fff; }
.array-json-panel .json-textarea { display: block; min-height: 180px; }
.detail-hero { background: #f6f9ff; border: 1px solid #e4eaf3; border-radius: 8px; padding: 16px; }
.detail-field { min-height: 86px; border: 1px solid #e4eaf3; border-radius: 8px; padding: 12px; background: #fff; }
.detail-label { color: #6c757d; font-size: .78rem; text-transform: uppercase; margin-bottom: .35rem; }
.detail-value { font-weight: 500; overflow-wrap: anywhere; }
.detail-json { margin: 0; white-space: pre-wrap; font-size: .84rem; font-weight: 400; color: #20293a; }
.table th { white-space: nowrap; }
.clickable-action { white-space: nowrap; }
.clickable-action .btn { min-width: 38px; }
.action-text { display: none; }
@media (max-width: 1399.98px) {
  .resource-table, .logs-table { overflow-x: visible; }
  .resource-table table,
  .resource-table thead,
  .resource-table tbody,
  .resource-table th,
  .resource-table td,
  .resource-table tr,
  .logs-table table,
  .logs-table thead,
  .logs-table tbody,
  .logs-table th,
  .logs-table td,
  .logs-table tr {
    display: block;
  }
  .resource-table thead, .logs-table thead { display: none; }
  .resource-table tbody, .logs-table tbody { display: grid; gap: 12px; }
  .resource-table tr, .logs-table tr {
    border: 1px solid #e4eaf3;
    border-radius: 8px;
    background: #fff;
    padding: 10px 12px;
  }
  .resource-table .table > :not(caption) > * > *,
  .logs-table .table > :not(caption) > * > * {
    border-bottom-width: 0;
    padding: 8px 0;
  }
  .resource-table td, .logs-table td {
    display: grid;
    grid-template-columns: minmax(120px, 32%) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    border-bottom: 1px solid #eef2f7;
  }
  .resource-table td::before, .logs-table td::before {
    content: attr(data-label);
    color: #6c757d;
    font-size: .78rem;
    text-transform: uppercase;
    overflow-wrap: anywhere;
  }
  .logs-table td:nth-child(1)::before { content: "Agent"; }
  .logs-table td:nth-child(2)::before { content: "Journal"; }
  .logs-table td:nth-child(3)::before { content: "Date"; }
  .logs-table td:nth-child(4)::before { content: "Erreurs"; }
  .logs-table td:nth-child(5)::before { content: "Resultat"; }
  .logs-table td:nth-child(6)::before { content: "Actions"; }
  .logs-table td[colspan]::before { content: ""; }
  .resource-table td:last-child, .logs-table td:last-child { border-bottom: 0; }
  .resource-table .clickable-action, .logs-table .clickable-action {
    text-align: left !important;
    white-space: normal;
  }
  .resource-table .clickable-action .btn, .logs-table .clickable-action .btn {
    width: auto;
    min-width: 42px;
    margin-right: 6px;
    margin-bottom: 6px;
  }
}
@media (max-width: 575.98px) {
  .topbar .container-fluid {
    align-items: flex-start !important;
  }
  .database-picker {
    width: 100%;
    flex-basis: 100%;
    order: 3;
  }
  .database-picker .form-select { min-width: 0; }
  .topbar h2 {
    font-size: 1.35rem;
  }
  .topbar .badge {
    max-width: 100%;
    white-space: normal;
  }
  .resource-table td, .logs-table td {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .resource-table .clickable-action .btn, .logs-table .clickable-action .btn {
    width: 100%;
    margin-right: 0;
  }
  .clickable-action .action-text {
    display: inline;
  }
  #prevPageButton,
  #nextPageButton {
    min-width: 44px;
  }
}
@media (max-width: 991.98px) {
  .topbar .container-fluid { flex-wrap: wrap; }
  .database-picker { width: min(100%, 390px); flex-basis: 390px; }
  body.sidebar-open { overflow: hidden; }
  .sidebar { width: var(--mobile-sidebar-width); transform: translateX(-100%); transition: transform .2s ease; box-shadow: .7rem 0 1.6rem rgba(15, 23, 42, .22); }
  .sidebar.show { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .main { margin-left: 0; }
}
