:root {
  --bg: #f4f7fb;
  --panel: #fff;
  --ink: #172033;
  --muted: #637087;
  --line: #e3e8f0;
  --nav: #111827;
  --nav2: #202c43;
  --accent: #5261e8;
  --danger: #c73737;
  --sidebar-width: 240px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 110px; }
body { margin: 0; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.5; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
a { color: #3f50c9; text-decoration: none; overflow-wrap: anywhere; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #8792ff; outline-offset: 3px; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h2 { margin: 0 0 16px; font-size: 20px; line-height: 1.35; letter-spacing: -.3px; }
p { margin: 0 0 16px; }
p:last-child { margin-bottom: 0; }
.muted { color: var(--muted); }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; padding: 12px 18px; background: white; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { width: var(--sidebar-width); background: linear-gradient(180deg, var(--nav), #0b1220); color: white; padding: 26px 16px; position: fixed; inset: 0 auto 0 0; overflow-y: auto; overscroll-behavior: contain; z-index: 30; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-link { display: block; min-width: 0; border-radius: 10px; }
.brand-link img { display: block; width: 100%; height: auto; }
.sidebar-brand { flex: 0 0 56px; width: 56px; }
.sidebar-brand img { border-radius: 10px; }
.mobile-home { display: inline-flex; flex: 0 0 52px; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 10px; }
.mobile-home img { display: block; width: 52px; height: 52px; border-radius: 8px; }
.sidebar nav { display: flex; flex-direction: column; gap: 5px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; color: #d0d8e7; padding: 11px 12px; min-height: 46px; border-radius: 10px; font-size: 14px; }
.sidebar nav a:hover, .sidebar nav a[aria-current="page"] { background: var(--nav2); color: white; text-decoration: none; }
.sidebar nav a[aria-current="page"] { box-shadow: inset 3px 0 #929bff; }
.nav-title { font-size: 10px; font-weight: 700; letter-spacing: 1.3px; color: #91a0b7; margin: 18px 12px 3px; }
.btn.menu-toggle, .btn.menu-close, .mobile-toolbar { display: none; }
.main { margin-left: var(--sidebar-width); width: calc(100% - var(--sidebar-width)); min-width: 0; }
.topbar { min-height: 78px; background: white; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px 20px; padding: 14px 28px; position: sticky; top: 0; z-index: 10; }
.company-switch { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 330px; }
.company-switch label { white-space: nowrap; }
.company-switch select { margin: 0; width: auto; flex: 1; min-width: 0; max-width: 280px; }
.company-switch .btn { flex-shrink: 0; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; }
.language-switch { display: flex; align-items: center; gap: 2px; }
.language-switch a { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; min-width: 36px; font-size: 13px; }
.user-pill { background: #eef0ff; padding: 8px 12px; border-radius: 22px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.link-btn { border: 0; background: none; color: #3f50c9; cursor: pointer; min-height: 44px; padding: 8px; font-size: 14px; }
.content { width: 100%; padding: clamp(20px, 2.4vw, 36px); max-width: 1500px; margin: auto; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.page-head > div { min-width: 0; flex: 1; }
.page-head h1 { margin: 0; font-size: clamp(24px, 2.4vw, 32px); line-height: 1.2; letter-spacing: -.7px; }
.page-head p { margin: 8px 0 0; }
.page-head > form { max-width: 100%; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.panel-head h2 { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 18px; margin-bottom: 24px; }
.cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.cards.ticket-layout { grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); }
.stat, .panel, .vault-card { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 4px 18px rgba(17, 24, 39, .035); }
.stat { padding: 22px; }
a.stat { color: var(--ink); }
a.stat:hover, a.stat:focus-visible { text-decoration: none; border-color: var(--accent); background: #f8faff; }
.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat strong { display: block; font-size: 34px; line-height: 1.2; margin-top: 10px; }
.stat.danger strong { color: var(--danger); }
.cards.import-layout { grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); align-items: start; }
.import-templates { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.import-message { margin-bottom: 24px; border-color: var(--accent); }
.import-guide { border-top: 1px solid var(--line); padding-block: 16px; }
.import-guide summary { cursor: pointer; min-height: 44px; font-weight: 600; }
.import-guide code { overflow-wrap: anywhere; }
[data-import-status]:empty { display: none; }
.panel { padding: 24px; }
.panel.inset { box-shadow: none; margin-top: 20px; }
.vault-card { max-width: 960px; padding: 26px; }
.table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; background: #f8faff; }
th:first-child { border-radius: 8px 0 0 8px; }
th:last-child { border-radius: 0 8px 8px 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbff; }
td a { display: inline-block; padding-block: 4px; }
.badge { display: inline-block; padding: 5px 10px; background: #eef0ff; color: #394786; border-radius: 20px; font-size: 12px; max-width: 100%; overflow-wrap: anywhere; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border: 1px solid #dce2ed; background: white; border-radius: 10px; padding: 10px 15px; cursor: pointer; color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.35; text-align: center; }
.btn:hover { background: #f4f6fc; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { background: #434fc5; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.document-list { display: grid; gap: 16px; }
.document-list article { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding-block: 12px; border-bottom: 1px solid var(--line); }
.document-list article > div { min-width: 0; flex: 1 1 220px; }
.document-list p { margin-top: 6px; }
.document-downloads { padding-left: 20px; }
.document-downloads li { padding-block: 8px; overflow-wrap: anywhere; }
.rich-content { overflow-wrap: anywhere; margin-bottom: 24px; }
.rich-content blockquote { margin-inline: 0; padding: 12px 18px; border-left: 4px solid var(--accent); background: #f8faff; }
.rich-content li { margin-bottom: 6px; }
[data-document-form] .ql-toolbar { border-radius: 10px 10px 0 0; border-color: var(--line); margin-top: 8px; }
[data-document-form] .ql-container { border-radius: 0 0 10px 10px; border-color: var(--line); font-family: inherit; font-size: 16px; }
[data-document-form] .ql-editor { min-height: 260px; overflow-wrap: anywhere; }
[data-document-form] .ql-toolbar.ql-snow button { width: 44px; height: 44px; padding: 11px; }
[data-document-form] .ql-toolbar .ql-picker { height: 44px; }
[data-document-form] .ql-toolbar .ql-picker-label { padding-block: 12px; }
[data-document-form] .ql-tooltip { max-width: 100%; left: 0 !important; white-space: normal; z-index: 2; }
[data-document-form] .ql-snow .ql-tooltip input[type=text] { max-width: 100%; font-size: 16px; }
[data-document-form] .ql-snow .ql-tooltip::before { content: 'Lien :'; }
[data-document-form] .ql-snow .ql-tooltip[data-mode=link]::before { content: 'Adresse du lien :'; }
[data-document-form] .ql-snow .ql-tooltip a.ql-action::after { content: 'Modifier'; }
[data-document-form] .ql-snow .ql-tooltip.ql-editing a.ql-action::after { content: 'Enregistrer'; }
[data-document-form] .ql-snow .ql-tooltip a.ql-remove::before { content: 'Retirer'; }
[data-document-form] .ql-snow .ql-picker.ql-header .ql-picker-label::before,
[data-document-form] .ql-snow .ql-picker.ql-header .ql-picker-item::before { content: 'Normal'; }
[data-document-form] .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before,
[data-document-form] .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before { content: 'Titre 2'; }
[data-document-form] .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before,
[data-document-form] .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before { content: 'Titre 3'; }
[data-document-form] .ql-snow .ql-picker .ql-picker-item { min-height: 44px; padding-block: 10px; }
[data-document-status]:empty { display: none; }
.document-editor-heading, .document-editor-tools, .document-editor-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.document-editor-heading, .document-editor-footer { justify-content: space-between; }
.document-editor-tools .btn { padding-inline: 10px; font-size: 13px; }
.document-editor-tools .btn:disabled { opacity: .45; cursor: default; }
.document-editor-footer { padding: 12px 0; color: var(--muted); font-size: 12px; }
.document-editor-shell { min-width: 0; }
.document-editor-open { overflow: hidden; }
.document-editor-shell.is-fullscreen { position: fixed; inset: 16px; z-index: 100; display: flex; flex-direction: column; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(17,24,39,.4); overflow: auto; }
.document-editor-shell.is-fullscreen .ql-toolbar { flex-shrink: 0; }
[data-document-form] .document-editor-shell.is-fullscreen .ql-container { flex: 1 1 auto; height: 0; min-height: 180px; }
[data-document-form] .document-editor-shell.is-fullscreen .ql-editor { height: 100%; min-height: 0; }
.document-editor-shell.is-fullscreen .document-editor-help { display: none; }
[data-document-form] .ql-snow .ql-color-picker .ql-picker-options { width: 178px; padding: 6px; }
[data-document-form] .ql-snow .ql-picker.ql-color-picker,
[data-document-form] .ql-snow .ql-picker.ql-icon-picker { width: 44px; }
[data-document-form] .ql-snow .ql-picker.ql-color-picker .ql-picker-label,
[data-document-form] .ql-snow .ql-picker.ql-icon-picker .ql-picker-label { display: flex; justify-content: center; align-items: center; padding: 0; width: 44px; height: 44px; }
[data-document-form] .ql-snow .ql-picker.ql-color-picker .ql-picker-label svg,
[data-document-form] .ql-snow .ql-picker.ql-icon-picker .ql-picker-label svg { position: static; float: none; width: 22px; height: 22px; margin: 0; }
[data-document-form] .ql-snow .ql-color-picker .ql-picker-item { width: 44px; height: 44px; margin: 5px; padding: 0; border: 1px solid var(--line); }
[data-document-form] .ql-snow .ql-picker.ql-expanded .ql-picker-options { z-index: 5; }
@media (max-width: 700px) {
  .document-editor-tools { width: 100%; }
  .document-editor-tools .btn { flex: 1; }
  .document-editor-shell.is-fullscreen { inset: 0; border-radius: 0; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.form-grid > *, .stack > * { min-width: 0; }
.form-grid .full { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 18px; }
label { display: block; font-size: 13px; font-weight: 600; }
/* 16px prevents iOS focus zoom without restricting pinch-to-zoom. */
input, select, textarea { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 46px; margin-top: 8px; border: 1px solid #ccd4e2; border-radius: 10px; padding: 11px 12px; background: white; color: var(--ink); font-size: 16px; font-weight: 400; line-height: 1.4; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="hidden"] { display: none; }
textarea { resize: vertical; }
input[type="file"] { padding: 8px; overflow: hidden; }
input::file-selector-button { min-height: 36px; border: 0; border-radius: 6px; padding: 6px 10px; margin-right: 10px; background: #eef0ff; color: var(--ink); font: inherit; cursor: pointer; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.check input { width: 20px; min-height: 20px; height: 20px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.form-grid small, .stack small { display: block; font-size: 12px; font-weight: 400; margin-top: 7px; }
.form-actions, .inline-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.inline-form input { width: 180px; margin: 0; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; margin-bottom: 22px; }
.filter-bar > label { flex: 1 1 180px; min-width: 0; }
.panel.list-filters { padding: 0; margin-bottom: 22px; }
.filter-summary { position: relative; padding: 14px 48px 14px 20px; min-height: 52px; cursor: pointer; list-style: none; border-radius: 16px; }
.filter-summary::-webkit-details-marker { display: none; }
.filter-summary::after { content: ''; position: absolute; right: 22px; top: 21px; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
.list-filters[open] > .filter-summary::after { top: 25px; transform: rotate(225deg); }
.filter-summary:hover { background: #f8faff; }
.filter-summary-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; }
.filter-summary-values { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; color: var(--muted); font-size: 13px; }
.filter-summary-values > span { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-filters > .filter-bar { margin: 0; padding: 18px 20px 20px; border-top: 1px solid var(--line); }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.detail-grid dt { color: var(--muted); font-size: 13px; }
.detail-grid dd { margin: 6px 0 0; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.comment { border-top: 1px solid var(--line); padding: 18px 0; overflow-wrap: anywhere; }
.comment .muted { display: block; font-size: 12px; margin: 4px 0 10px; }
.comment p { margin: 10px 0; white-space: pre-wrap; }
.secret-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); padding: 18px 0; }
.secret-row > div { flex: 1; min-width: 140px; overflow-wrap: anywhere; }
.secret-row span, .secret-row strong { display: block; }
.secret-row .muted { font-size: 13px; margin-bottom: 5px; }
.otp-box { background: #f7f8ff; border: 1px solid #dfe3ff; border-radius: 12px; padding: 18px; margin: 22px 0; }
.otp-box strong { font-size: 34px; letter-spacing: 5px; display: block; margin: 8px 0; }
.otp-box .btn { margin-top: 10px; }
.otp-progress { height: 5px; background: #dfe3ff; border-radius: 5px; overflow: hidden; margin: 8px 0; }
.otp-progress i { display: block; height: 100%; width: 100%; background: var(--accent); }
.company-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.company-row > div { min-width: 0; overflow-wrap: anywhere; }
.company-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.company-actions > a { padding-block: 10px; }
.company-row .badge { margin: 4px 0 4px 6px; }
.section-nav { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0; }
.client-section { scroll-margin-top: 110px; margin-bottom: 24px; }
.attachment-list { list-style: none; padding: 0; }
.attachment-list li { margin: 10px 0; overflow-wrap: anywhere; }
.attachment-list a { display: inline-block; padding-block: 8px; }
.tag-badge { margin: 3px 5px 3px 0; }
.tag-entry-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.tag-entry-row input { margin: 0; flex: 1; }
.tag-entry-row button { white-space: nowrap; }
.tag-selection { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.tag-selection:empty { display: none; }
.tag-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 2px 4px 2px 12px; }
.tag-chip > span { overflow-wrap: anywhere; min-width: 0; }
.tag-chip button { border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; font-size: 20px; width: 40px; height: 40px; flex-shrink: 0; }
.tag-chip button:hover { background: #dce0ff; }
.tag-feedback { display: block; color: var(--ink); min-height: 1em; }
.login-page { min-height: 100vh; min-height: 100dvh; padding: 28px 16px; display: grid; place-items: center; background: radial-gradient(circle at top, #242e4d, #0c1321 65%); }
.login-card { width: min(440px, 100%); background: white; border-radius: 20px; padding: 36px; box-shadow: 0 25px 70px rgba(0, 0, 0, .28); }
.login-card h1 { margin: 24px 0 4px; }
.login-card .stack { margin-top: 24px; }
.login-brand { width: 200px; max-width: 100%; margin-inline: auto; }
.alert { background: #fff1f1; color: #a72828; padding: 14px; border-radius: 10px; margin: 16px 0; overflow-wrap: anywhere; }
@media (max-width: 1200px) {
  .cards.two { grid-template-columns: 1fr; }
  .topbar { padding-inline: 22px; }
}
@media (max-width: 1024px) {
  html { scroll-padding-top: calc(84px + env(safe-area-inset-top)); }
  .app-shell { display: block; }
  .main { width: 100%; margin-left: 0; }
  .sidebar { position: static; width: 100%; padding: 16px; }
  .sidebar nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar .nav-title { grid-column: 1 / -1; }
  .nav-ready .sidebar { position: fixed; inset: 0 auto 0 0; width: min(320px, 88vw); height: 100vh; height: 100dvh; padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); visibility: hidden; transform: translateX(-100%); }
  .nav-ready .sidebar nav { display: flex; }
  .nav-ready .menu-toggle, .nav-ready .menu-close { display: inline-flex; }
  .nav-ready .mobile-toolbar { display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 15; min-height: 64px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; background: var(--panel); border-bottom: 1px solid var(--line); box-shadow: 0 3px 12px rgba(17,24,39,.05); }
  .mobile-company { min-width: 0; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
  .menu-toggle { gap: 8px; flex-shrink: 0; }
  .menu-toggle svg { width: 20px; height: 20px; }
  .menu-close { background: var(--nav2); color: white; border-color: #3b4760; width: 44px; padding: 0; font-size: 24px; }
  .nav-open { overflow: hidden; }
  .nav-open .sidebar { visibility: visible; transform: translateX(0); }
  .nav-backdrop { position: fixed; inset: 0; z-index: 20; background: #0b122099; border: 0; width: 100%; height: 100%; cursor: pointer; }
  .topbar { position: static; gap: 12px; padding: 14px 20px; }
  .company-switch { order: 3; flex-basis: 100%; }
  .company-switch select { max-width: none; }
  .top-actions { margin-left: auto; }
  .client-section { scroll-margin-top: 80px; }
  .cards.ticket-layout { grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); }
}
@media (max-width: 700px) {
  .content { padding: 22px 16px max(28px, env(safe-area-inset-bottom)); }
  .topbar { padding: 10px 16px 14px; gap: 8px; }
  .top-actions { gap: 4px; }
  .top-actions .user-pill { display: none; }
  .company-switch { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; }
  .company-switch label { grid-column: 1 / -1; font-size: 12px; }
  .company-switch select { width: 100%; }
  .page-head { align-items: stretch; gap: 14px; margin-bottom: 20px; }
  .page-head > div, .page-head > h1 { flex-basis: 100%; }
  .page-head > .btn, .page-head > form { width: 100%; }
  .panel, .vault-card { padding: 18px; border-radius: 14px; }
  .panel-head { align-items: flex-start; }
  .panel-head > h2 { flex: 1 1 100%; }
  .panel-head > .form-actions { width: 100%; }
  .panel-head .form-actions > .btn { flex: 1; }
  .form-grid, .cards.two, .cards.ticket-layout, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid { gap: 20px; }
  .form-actions > .btn { flex: 1; }
  .filter-bar > label { flex-basis: 100%; }
  .list-filters .form-actions { width: 100%; }
  .filter-bar > .btn { flex: 1; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .cards:not(.two) > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat { padding: 16px; }
  .stat strong { font-size: 30px; }
  .section-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .section-nav .btn { padding: 10px 5px; font-size: 12px; }
  .table-scroll table { min-width: 540px; }
  /* Cards keep every field visible; tables retain scrolling when JS is unavailable. */
  .table-scroll .responsive-table { display: block; min-width: 0; }
  .responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .responsive-table tbody { display: grid; gap: 14px; }
  .responsive-table tr { display: block; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
  .responsive-table td { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); gap: 6px 12px; align-items: start; padding: 9px 0; border-bottom: 1px solid #edf0f5; }
  .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; padding-top: 4px; }
  .responsive-table td:first-child { font-weight: 600; padding-top: 0; }
  .responsive-table td:last-child { border-bottom: 0; padding-bottom: 0; }
  .cell-content { min-width: 0; overflow-wrap: anywhere; }
  .cell-content .inline-form input { width: 100%; }
  .cell-content .form-actions, .cell-content .inline-form { align-items: stretch; }
  .cell-content .btn { width: 100%; }
  .responsive-table td[data-actions] { grid-template-columns: 1fr; }
  .responsive-table .table-empty { display: block; }
  .responsive-table .table-empty::before { content: none; }
  .login-card { padding: 28px 22px; }
}
@media (max-width: 360px) {
  .menu-toggle { font-size: 0; gap: 0; padding-inline: 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  .nav-ready .sidebar { transition: transform .18s ease, visibility .18s; }
}
@media print {
  .sidebar, .topbar, .mobile-toolbar, .skip-link, .nav-backdrop { display: none !important; }
  .main { width: 100%; margin: 0; }
  .content { padding: 0; }
  .panel, .stat, .vault-card { box-shadow: none; }
}

.tag-suggestions { margin-top: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #f8faff; max-height: 230px; overflow-y: auto; overscroll-behavior: contain; }
.tag-suggestions button { display: block; width: 100%; border: 0; border-radius: 7px; padding: 10px 12px; min-height: 44px; text-align: left; font-size: 16px; background: transparent; color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.tag-suggestions button:hover, .tag-suggestions button[aria-selected="true"] { background: #e7eaff; color: #303e95; }
.tag-catalog-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.vault-access { display: grid; gap: 14px; min-width: 0; }
.vault-access-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.vault-access-line > div:first-child { min-width: 0; flex: 1 1 180px; }
.vault-access-line .muted { display: block; font-size: 12px; margin-bottom: 4px; }
.vault-access strong { display: block; overflow-wrap: anywhere; white-space: pre-wrap; }
.vault-access-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.vault-access .btn:disabled { opacity: .5; cursor: default; }
.vault-access-cell { min-width: 250px; }
.vault-access-cell .btn { font-size: 12px; padding: 8px 10px; }
.vault-card > .vault-access { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
@media (max-width: 700px) {
  .responsive-table td.vault-access-cell { grid-template-columns: minmax(0, 1fr); min-width: 0; }
  .responsive-table td.vault-access-cell::before { content: none; }
  .vault-access-line > div:first-child { flex-basis: 100%; }
  .vault-access-line > .btn { flex-basis: 100%; }
  .vault-access-actions { width: 100%; }
  .vault-access .btn { flex: 1; }
  .cell-content .vault-access-actions .btn { width: auto; }
}

.vault-list-table th { white-space: nowrap; }
.vault-list-table td:nth-child(4) { min-width: 100px; }
@media (max-width: 700px) { .vault-list-table td:nth-child(4) { min-width: 0; } }

.rich-content img,.ql-editor img { max-width: 100%; height: auto; vertical-align: middle; }
.document-reading .document-paper { max-width: 1000px; }
.document-reading .page-head h1 { overflow-wrap: anywhere; }
.document-editor-image-status { margin: 8px 0; }
@media print {
  @page { size: A4; margin: 16mm; }
  body:has(.document-reading) { background: white; color: #172033; }
  body:has(.document-reading) .app-shell,body:has(.document-reading) .main,body:has(.document-reading) .content { display: block; margin: 0; padding: 0; width: 100%; max-width: none; }
  .document-no-print { display: none !important; }
  .document-reading .page-head { display: block; }
  .document-reading .document-paper { border: 0; padding: 0; max-width: none; box-shadow: none; }
  .document-reading img { max-width: 100%; max-height: 230mm; object-fit: contain; break-inside: avoid; }
  .document-reading h1,.document-reading h2,.document-reading h3 { break-after: avoid; }
  .document-reading p { orphans: 3; widows: 3; }
  .document-reading a { color: inherit; text-decoration: none; }
  .document-reading .rich-content { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

.document-google-import { margin: 12px 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }

.security-panel { max-width: 760px; }
.mfa-qr { display: block; max-width: 100%; height: auto; margin-block: 16px; }
.mfa-secret { overflow-wrap: anywhere; }
.mfa-recovery { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 12px; padding: 0; list-style: none; margin-block: 24px; }
.mfa-recovery li { padding: 12px; background: var(--bg); border-radius: 8px; overflow-wrap: anywhere; }

/* Shared layout for data-entry pages and embedded administration forms. */
.form-page-head, .panel.entry-form { width: 100%; max-width: 1100px; margin-inline: auto; }
.entry-form { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.form-section { min-width: 0; border: 0; padding: 0; margin: 0; }
.form-section > legend { padding: 0; margin-bottom: 18px; color: var(--ink); font-size: 18px; font-weight: 700; }
.entry-form > .form-section + .form-section { padding-top: 24px; border-top: 1px solid var(--line); }
.entry-form .form-grid { align-items: start; }
.entry-form small { display: block; margin-top: 7px; font-size: 12px; font-weight: 400; color: var(--muted); }
.entry-form input:disabled, .entry-form select:disabled { background: var(--bg); color: var(--muted); opacity: 1; }
.form-footer { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 4px; justify-content: flex-end; }
.form-footer > .btn { flex: 0 1 auto; min-width: 140px; }
.entry-form > h2 { margin-bottom: 0; }
@media (max-width: 700px) {
  .entry-form { gap: 24px; }
  .form-footer { align-items: stretch; }
  .form-footer > .btn { flex: 1 1 150px; min-width: 0; }
}

.panel.entry-form + .panel { margin-top: 24px; }

.page-head .form-required-note { font-size: 12px; margin-top: 6px; }

.dashboard-heading .dashboard-company { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--accent); }
.dashboard-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.dashboard-stats .stat { position: relative; padding: 18px 20px; }
.dashboard-stats .stat strong { font-size: 32px; }
.dashboard-stats .stat small { display: block; margin-top: 10px; color: var(--muted); font-size: 12px; }
.dashboard-stats .stat.danger { background: #fff8f7; border-color: #f0d0cb; }
.dashboard-shortcuts { margin-bottom: 24px; }
.dashboard-shortcut-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.dashboard-columns { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.dashboard-ticket-list { display: flex; flex-direction: column; }
.dashboard-ticket { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 16px 0; color: var(--ink); border-top: 1px solid var(--line); }
.dashboard-ticket:hover { text-decoration: none; background: #f8faff; }
.dashboard-ticket > div { min-width: 0; }
.dashboard-ticket strong, .dashboard-ticket small { display: block; overflow-wrap: anywhere; }
.dashboard-ticket small { color: var(--muted); font-size: 12px; }
.dashboard-ticket strong { margin-block: 4px; font-size: 14px; }
.dashboard-ticket-badges { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; max-width: 45%; }
.priority-urgent { background: #ffebe8; color: #a52b20; }
.dashboard-empty { padding: 20px 0; color: var(--muted); }
@media (max-width: 1100px) {
  .dashboard-columns { grid-template-columns: minmax(0, 1fr); }
  .dashboard-priority { grid-row: 1; }
}
@media (max-width: 700px) {
  .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .dashboard-stats .stat { padding: 16px; }
  .dashboard-shortcut-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}

.vault-type-picker { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 18px; }
.vault-type-picker > label { flex: 1 1 260px; }
.vault-type-picker > p { flex: 1 1 100%; order: 2; margin: 0; font-size: 13px; }

/* Equipment / credential associations share the same compact layout on both sheets. */
.association-row{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:1rem 0;border-bottom:1px solid var(--line)}
.association-row>div{min-width:0;overflow-wrap:anywhere}.association-row p{margin:.25rem 0 0}
.association-form{display:flex;align-items:flex-end;gap:1rem;margin-top:1rem}
.association-form label{flex:1;min-width:0}.association-form select{width:100%}
.association-form .btn,.association-row .btn{flex-shrink:0}
@media(max-width:640px){.association-form{flex-direction:column;align-items:stretch}.association-row{align-items:flex-start}.association-row form{flex-shrink:0}}

/* Transient action feedback, shared by internal pages and the client portal. */
.notifications{position:fixed;top:90px;right:max(20px,env(safe-area-inset-right));width:min(420px,calc(100vw - 40px));display:grid;gap:10px;z-index:110;pointer-events:none}
.notification{display:flex;align-items:center;gap:12px;padding:12px 10px 12px 16px;background:var(--panel);color:var(--ink);border:1px solid var(--line);border-left:4px solid #178057;border-radius:12px;box-shadow:0 10px 35px #17203326;pointer-events:auto}
.notification-icon{display:grid;place-items:center;flex:0 0 28px;height:28px;border-radius:50%;background:#e6f5ed;color:#12643e;font-weight:700}
.notification-message{flex:1;min-width:0;overflow-wrap:anywhere;font-size:14px;line-height:1.5}
.notification-close{display:grid;place-items:center;flex:0 0 44px;width:44px;height:44px;border:0;border-radius:8px;background:transparent;color:var(--muted);font-size:24px;cursor:pointer}
.notification-close:hover{background:var(--bg)}.notification-close:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.notification--error{border-left-color:var(--danger)}.notification--error .notification-icon{background:#fcecec;color:#a52a2a}
.notification--info{border-left-color:var(--accent)}.notification--info .notification-icon{background:#eef0ff;color:#3f50c9}
@media(max-width:640px){.notifications{top:auto;bottom:max(16px,env(safe-area-inset-bottom));left:max(12px,env(safe-area-inset-left));right:max(12px,env(safe-area-inset-right));width:auto}}
@media(prefers-reduced-motion:no-preference){.notification{animation:notification-enter .18s ease-out}@keyframes notification-enter{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}}
@media print{.notifications{display:none!important}}

.storage-field{display:grid;grid-template-columns:minmax(0,1fr) 90px;gap:8px 12px;align-content:start}.storage-field>small{grid-column:1/-1}.storage-field label{min-width:0}

.ticket-updates{position:relative}.ticket-updates>summary{display:flex;align-items:center;gap:8px;cursor:pointer;min-height:44px;padding:8px 12px;border:1px solid var(--line);border-radius:10px;background:var(--panel);list-style:none}
.ticket-updates>summary::-webkit-details-marker{display:none}.ticket-updates svg{width:20px;height:20px}.reply-count{background:var(--accent);color:white;border-radius:20px;min-width:24px;padding:1px 7px;text-align:center;font-size:12px;font-weight:700}
.ticket-updates-panel{position:absolute;right:0;top:calc(100% + 8px);width:min(360px,calc(100vw - 40px));max-height:60vh;overflow:auto;padding:18px;background:var(--panel);border:1px solid var(--line);border-radius:12px;box-shadow:0 12px 36px #17203324;z-index:40}
.ticket-updates-panel a{display:block;padding:10px 0;border-bottom:1px solid var(--line);overflow-wrap:anywhere}.ticket-updates-panel>a:last-child{border:0;font-weight:600}
.ticket-unread{background:#eef2ff}.reply-badge{background:#dfe6ff;color:#263da8;font-weight:700}.comment-unread{border-left:4px solid var(--accent);padding-left:14px;background:#f5f7ff}.comment-unread>.reply-badge{display:inline-block;margin-bottom:10px}
@media(max-width:640px){.ticket-updates{position:static}.top-actions{position:relative}.ticket-updates-panel{left:0;right:auto;max-width:100%}}
@media print{.ticket-updates{display:none!important}}

.record-more { margin-top: 18px; }
.record-more > summary { display: inline-flex; align-items: center; gap: 12px; list-style: none; cursor: pointer; }
.record-more > summary::-webkit-details-marker { display: none; }
.record-more-hide, .record-more[open] > summary .record-more-show { display: none; }
.record-more[open] > summary .record-more-hide { display: inline; }
.record-more[open] > summary .record-more-arrow { transform: rotate(180deg); }
.record-more-content { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
@media print { .record-more > summary { display: none; } }

.tag-quick{margin-top:10px}.tag-quick>small{display:block;margin-bottom:6px}.tag-quick-buttons{display:flex;flex-wrap:wrap;gap:7px}.tag-quick-button{min-height:44px;max-width:100%;white-space:normal;overflow-wrap:anywhere;text-align:left;font-size:14px;padding:8px 12px}.tag-quick-button:disabled{opacity:1;background:#eef2ff;color:#4b5563;border-color:#d8def1;cursor:default}

.inventory-row-actions{gap:6px;flex-wrap:wrap;margin-top:8px}.inventory-row-actions form{margin:0}.inventory-row-actions .btn{min-height:44px}
