/* ═══════════════════════════════════════════════
   APT Legal Portal — Design System
   ═══════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:        #2563eb;
  --blue-dark:   #1d4ed8;
  --blue-light:  #dbeafe;
  --green:       #16a34a;
  --green-light: #dcfce7;
  --red:         #dc2626;
  --red-light:   #fee2e2;
  --amber:       #d97706;
  --amber-light: #fef3c7;
  --slate-50:    #f8fafc;
  --slate-100:   #f1f5f9;
  --slate-200:   #e2e8f0;
  --slate-300:   #cbd5e1;
  --slate-400:   #94a3b8;
  --slate-500:   #64748b;
  --slate-600:   #475569;
  --slate-700:   #334155;
  --slate-800:   #1e293b;
  --slate-900:   #0f172a;
  --white:       #ffffff;
  --sidebar-w:   240px;
  --header-h:    56px;
  --radius:      6px;
  --radius-lg:   10px;
  --shadow-sm:   0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow:      0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
  --shadow-md:   0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);
  --shadow-lg:   0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
  --danger:      #dc2626;
  --danger-light: #fee2e2;
  --surface:     #f8fafc;
  --transition:  150ms ease;
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 14px; line-height: 1.5; color: var(--slate-800); background: var(--slate-50); }

/* ── Layout ──────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* Login page */
#login-page { display: flex; align-items: center; justify-content: center; height: 100%; width: 100%; background: var(--slate-100); }
.login-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 40px 36px; width: 360px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--slate-800); }
.login-logo p { font-size: 13px; color: var(--slate-500); margin-top: 4px; }

/* Sidebar */
#sidebar { width: var(--sidebar-w); background: var(--slate-800); display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; }
.sidebar-brand { padding: 22px 20px 16px; }
.sidebar-brand .brand-name { font-size: 21px; font-weight: 700; color: var(--white); line-height: 1.2; letter-spacing: -0.02em; }
.sidebar-brand .brand-sub  { display: none; }
.sidebar-nav { padding: 8px 0; flex: 1; }
.nav-section { display: none; font-size: 10.5px; font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: .06em; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--slate-300); cursor: pointer; border-radius: 0; transition: background var(--transition), color var(--transition); user-select: none; border: none; background: none; width: 100%; text-align: left; font-size: 14.5px; }
.nav-item:hover { background: var(--slate-700); color: var(--white); }
.nav-item.active { background: var(--blue); color: var(--white); border-radius: 8px; margin: 0 8px; padding: 10px 12px; }
.nav-item .nav-icon { width: 20px; text-align: center; flex-shrink: 0; font-size: 18px; }
.nav-badge { margin-left: auto; background: var(--red); color: var(--white); border-radius: 99px; font-size: 10px; font-weight: 700; padding: 1px 6px; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--slate-700); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 14px; color: var(--white); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 12px; color: var(--slate-400); }
.btn-logout { background: none; border: none; color: var(--slate-400); cursor: pointer; padding: 4px; border-radius: var(--radius); transition: color var(--transition); }
.btn-logout:hover { color: var(--white); }

/* Main area */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: var(--header-h); background: var(--white); border-bottom: 1px solid var(--slate-200); display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0; }
.topbar-title { font-size: 16px; font-weight: 600; color: var(--slate-800); flex: 1; }
.topbar-search { flex: 1; max-width: 320px; }
#content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Cards & Containers ──────────────────────────── */
.card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--slate-200); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--slate-200); display: flex; align-items: center; gap: 12px; }
.card-title { font-size: 15px; font-weight: 600; color: var(--slate-800); flex: 1; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--slate-200); background: var(--slate-50); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ── Buttons ─────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); border: 1px solid transparent; font-size: 13px; font-weight: 500; cursor: pointer; transition: all var(--transition); white-space: nowrap; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: var(--white); border-color: var(--blue); }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-secondary { background: var(--white); color: var(--slate-700); border-color: var(--slate-300); }
.btn-secondary:hover:not(:disabled) { background: var(--slate-50); border-color: var(--slate-400); }
.btn-danger { background: var(--red); color: var(--white); border-color: var(--red); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }
.btn-ghost { background: none; color: var(--slate-600); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--slate-100); color: var(--slate-800); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: var(--radius); }

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--slate-700); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=url], input[type=number], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--slate-300); border-radius: var(--radius); font-size: 13.5px; color: var(--slate-800); background: var(--white); transition: border-color var(--transition), box-shadow var(--transition); outline: none; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(37 99 235 / .12); }
input::placeholder, textarea::placeholder { color: var(--slate-400); }
.form-hint { font-size: 12px; color: var(--slate-500); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Tables ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--slate-200); background: var(--slate-50); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--slate-100); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--slate-50); }
tbody td { padding: 11px 14px; font-size: 13.5px; color: var(--slate-700); vertical-align: middle; }
tbody tr.clickable { cursor: pointer; }

/* ── Search input ────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 34px; }
.search-wrap .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--slate-400); pointer-events: none; font-size: 15px; }

/* ── Badges / Pills ──────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.badge-blue   { background: var(--blue-light);  color: var(--blue-dark); }
.badge-green  { background: var(--green-light); color: #14532d; }
.badge-red    { background: var(--red-light);   color: #991b1b; }
.badge-amber  { background: var(--amber-light); color: #92400e; }
.badge-gray   { background: var(--slate-100);   color: var(--slate-600); }

/* ── Tabs ────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--slate-200); margin-bottom: 20px; }
.tab { padding: 10px 18px; font-size: 13.5px; font-weight: 500; color: var(--slate-500); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--transition); white-space: nowrap; }
.tab:hover { color: var(--slate-800); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Modals ──────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgb(0 0 0 / .45); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 500px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-lg { max-width: 680px; }
.modal-header { padding: 18px 20px 16px; border-bottom: 1px solid var(--slate-200); display: flex; align-items: center; }
.modal-title { font-size: 15px; font-weight: 600; flex: 1; }
.modal-close { background: none; border: none; color: var(--slate-400); cursor: pointer; font-size: 20px; padding: 2px 6px; border-radius: var(--radius); transition: color var(--transition); line-height: 1; }
.modal-close:hover { color: var(--slate-700); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--slate-200); display: flex; justify-content: flex-end; gap: 10px; background: var(--slate-50); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ── Toasts ──────────────────────────────────────── */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--slate-800); color: var(--white); padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow-md); font-size: 13.5px; max-width: 360px; pointer-events: auto; animation: toast-in .2s ease; display: flex; align-items: center; gap: 10px; }
.toast.toast-success { background: #15803d; }
.toast.toast-error   { background: var(--red); }
.toast.toast-warn    { background: var(--amber); color: var(--slate-900); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── Loading ─────────────────────────────────────── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--slate-200); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { text-align: center; padding: 32px; color: var(--slate-400); }
.empty-row { text-align: center; padding: 40px; color: var(--slate-400); font-size: 13px; }
.empty-row .empty-icon { font-size: 36px; margin-bottom: 12px; }

/* ── Status badges for annex / import ───────────── */
.status-pending    { color: var(--amber); }
.status-processing { color: var(--blue); }
.status-done       { color: var(--green); }
.status-error      { color: var(--red); }

/* ── Toggle switch ───────────────────────────────── */
.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { width: 34px; height: 18px; background: var(--slate-300); border-radius: 99px; transition: background var(--transition); flex-shrink: 0; }
.toggle input:checked ~ .toggle-track { background: var(--blue); }
.toggle-thumb { position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; background: var(--white); border-radius: 50%; transition: transform var(--transition); box-shadow: var(--shadow-sm); }
.toggle input:checked ~ .toggle-thumb { transform: translateX(16px); }

/* ── Progress bar ────────────────────────────────── */
.progress-bar-wrap { height: 8px; background: var(--slate-200); border-radius: 99px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--blue); border-radius: 99px; transition: width .3s ease; }

/* ── File upload zone ────────────────────────────── */
.upload-zone { border: 2px dashed var(--slate-300); border-radius: var(--radius-lg); padding: 32px 24px; text-align: center; cursor: pointer; transition: border-color var(--transition), background var(--transition); }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--blue); background: var(--blue-light); }
.upload-zone-icon { font-size: 32px; margin-bottom: 10px; color: var(--slate-400); }
.upload-zone p { font-size: 13.5px; color: var(--slate-500); }
.upload-zone strong { color: var(--blue); }
.upload-zone .file-name { margin-top: 8px; font-size: 13px; color: var(--slate-700); font-weight: 500; }

/* ── Breadcrumb ──────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--slate-500); margin-bottom: 16px; flex-wrap: wrap; }
.breadcrumb a { color: var(--blue); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--slate-300); }

/* ── Stats grid ──────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat-label { font-size: 12px; color: var(--slate-500); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--slate-800); line-height: 1.2; margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--slate-500); margin-top: 2px; }

/* ── Photo grid ──────────────────────────────────── */
.photo-list-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--slate-100); transition: background var(--transition); }
.photo-list-item:last-child { border-bottom: none; }
.photo-list-item:hover { background: var(--slate-50); }
.photo-thumb { width: 40px; height: 40px; border-radius: var(--radius); background: var(--slate-100); overflow: hidden; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--slate-400); font-size: 18px; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-info { flex: 1; min-width: 0; }
.photo-name { font-size: 13px; font-weight: 500; color: var(--slate-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-url { font-size: 12px; color: var(--slate-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ── Pagination ──────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; }

/* ── Panels ──────────────────────────────────────── */
.panel-split { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .panel-split { grid-template-columns: 1fr; } }

/* ── Util ────────────────────────────────────────── */
.text-muted { color: var(--slate-500); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.fw-600 { font-weight: 600; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cursor-pointer { cursor: pointer; }
hr.divider { border: none; border-top: 1px solid var(--slate-200); margin: 16px 0; }

/* Focus visible */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Toast ARIA */
#toast-container { role: alert; }

/* Nav divider */
.nav-divider { height: 1px; background: var(--slate-700); margin: 8px 18px; opacity: 0.5; }

/* ── Users page ──────────────────────────────────── */
.users-table td { vertical-align: middle; }
.users-table tr.row-inactive { opacity: 0.55; }
.user-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.user-avatar { flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--slate-200); color: var(--slate-600); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.user-avatar.is-admin { background: var(--blue-light); color: var(--blue-dark); }
.row-actions { display: inline-flex; gap: 2px; justify-content: flex-end; }
.row-actions .btn-ghost { padding: 5px 7px; }

/* Access chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 500; background: var(--slate-100); color: var(--slate-700); white-space: nowrap; }
.chip-full { background: var(--blue-light); color: var(--blue-dark); }
.chip-muted { background: var(--slate-100); color: var(--slate-400); }

/* Permission matrix (user modal) */
.perm-admin-note { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: var(--radius); background: var(--blue-light); color: var(--blue-dark); font-size: 13px; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.perm-group { border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 12px 14px; background: var(--slate-50); }
.perm-group-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-500); margin-bottom: 8px; }
.perm-check { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; font-size: 13px; color: var(--slate-700); cursor: pointer; }
.perm-check input { margin-top: 2px; flex-shrink: 0; cursor: pointer; width: 16px; height: 16px; }
@media (max-width: 620px) { .perm-grid { grid-template-columns: 1fr; } }
/* Flat permission list (action-based caps) */
.perm-list { border: 1px solid var(--slate-200); border-radius: var(--radius); background: var(--slate-50); padding: 2px 14px; }
.perm-list .perm-check { padding: 11px 2px; border-bottom: 1px solid var(--slate-200); font-size: 13.5px; }
.perm-list .perm-check:last-child { border-bottom: none; }

/* Signature preview thumbnail */
.sig-preview { display: block; width: fit-content; max-width: 100%; border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 10px 14px; background: var(--slate-50); transition: border-color var(--transition); }
.sig-preview:hover { border-color: var(--slate-400); }
.sig-preview img { display: block; height: 64px; max-width: 220px; object-fit: contain; }

/* Annex preview modal */
.annex-preview-frame { width: 100%; height: 72vh; border: 1px solid var(--slate-200); border-radius: var(--radius); background: var(--slate-50); }

/* Server-archive panel */
.check-inline { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--slate-700); cursor: pointer; user-select: none; }
.check-inline input { cursor: pointer; }
.arch-stats { font-size: 14px; padding-top: 4px; line-height: 1.35; }

/* Stronger drag-and-drop feedback in the import tab */
#tab-import .dz { padding: 40px 20px; }
#tab-import .dz.over {
  border-width: 2px; border-style: solid; border-color: var(--blue);
  background: var(--blue-light);
  box-shadow: 0 0 0 4px var(--blue-light), 0 8px 24px rgb(37 99 235 / .18);
}
/* ===== APT-PERM-ACCORDION ===== granular permission editor (users page) */
.perm-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.perm-presets { display: flex; gap: 6px; }

/* One bordered list; the modal body is the only scroll region (no nested scroll,
   no flex — flex columns with max-height shrink their children and overlap). */
.perm-acc { border: 1px solid var(--slate-200); border-radius: 10px; overflow: hidden; background: var(--white, #fff); }
.perm-grp { border-bottom: 1px solid var(--slate-200); }
.perm-grp:last-child { border-bottom: none; }
.perm-grp.is-full { background: var(--blue-light); }

.perm-grp-head { display: flex; align-items: center; gap: 11px; padding: 12px 14px; cursor: pointer; user-select: none; }
.perm-grp-head:hover { background: var(--slate-50); }
.perm-grp.is-full .perm-grp-head:hover { background: var(--blue-light); }

.perm-master { width: 17px; height: 17px; flex-shrink: 0; cursor: pointer; accent-color: var(--blue); }
.perm-grp-icon { font-size: 18px; color: var(--slate-500); flex-shrink: 0; width: 20px; text-align: center; }
.perm-grp.is-full .perm-grp-icon { color: var(--blue-dark); }
.perm-grp-label { font-size: 14px; font-weight: 600; color: var(--slate-700); flex: 1; }
.perm-grp.is-full .perm-grp-label { color: var(--blue-dark); }
.perm-grp-count { font-size: 12px; color: var(--slate-400); min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.perm-grp-count.has { color: var(--blue); font-weight: 600; }
.perm-chev { font-size: 16px; color: var(--slate-400); transition: transform .2s ease; }
.perm-grp.is-open .perm-chev { transform: rotate(180deg); }

/* Smooth expand via max-height (reliable in every engine; content never exceeds
   this so nothing is clipped). Collapsed groups have zero-height bodies. */
.perm-grp-body { max-height: 0; overflow: hidden; transition: max-height .25s ease; background: var(--slate-50); }
.perm-grp.is-open .perm-grp-body { max-height: 640px; }
.perm-grp-body-inner { overflow: hidden; }

.perm-leaf { display: flex; align-items: center; gap: 11px; padding: 10px 14px 10px 46px; cursor: pointer; font-size: 13.5px; color: var(--slate-700); border-top: 1px solid var(--slate-200); }
.perm-leaf:hover { background: #eef2f7; }
.perm-leaf input { width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; accent-color: var(--blue); }
.perm-leaf-label { flex: 1; }

/* ===== APT-IMPORT-REPORT ===== full per-file import outcome (nothing silent) */
.import-errors { margin-top: 12px; }
.imp-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.imp-chip { border: 1px solid var(--slate-300); background: var(--white, #fff); border-radius: 99px; padding: 3px 11px; font-size: 12px; font-weight: 600; color: var(--slate-600); cursor: pointer; }
.imp-chip:hover { background: var(--slate-50); }
.imp-chip.active { outline: 2px solid var(--blue); outline-offset: -1px; }
.imp-chip.imp-ok   { color: #15803d; border-color: #86efac; }
.imp-chip.imp-warn { color: #92400e; border-color: #fcd34d; }
.imp-chip.imp-bad  { color: #991b1b; border-color: #fca5a5; }
.imp-dl { margin-left: auto; border: 1px solid var(--slate-300); background: var(--white, #fff); border-radius: var(--radius); padding: 4px 10px; font-size: 12px; color: var(--slate-600); cursor: pointer; }
.imp-dl:hover { background: var(--slate-50); }
.imp-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--slate-200); border-radius: var(--radius); background: var(--white, #fff); }
.imp-row { display: flex; gap: 12px; padding: 7px 12px; font-size: 12.5px; border-top: 1px solid var(--slate-100); border-left: 3px solid transparent; }
.imp-row:first-child { border-top: none; }
.imp-row.imp-ok   { border-left-color: var(--green, #16a34a); }
.imp-row.imp-warn { border-left-color: var(--amber, #d97706); }
.imp-row.imp-bad  { border-left-color: var(--red, #dc2626); }
.imp-file { flex: 0 0 42%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--slate-700); }
.imp-msg { flex: 1; color: var(--slate-600); }
.imp-row.imp-ok .imp-msg   { color: #15803d; }
.imp-row.imp-warn .imp-msg { color: #92400e; }
.imp-row.imp-bad .imp-msg  { color: #991b1b; }
.imp-more { padding: 7px 12px; font-size: 12px; color: var(--slate-500); }

/* ===== APT-LINKED-ARCHIVES ===== detach a server-archive mapping from a client */
.linked-archives { margin-top: 16px; }
.linked-head { font-size: 13px; font-weight: 600; color: var(--slate-600); margin-bottom: 8px; }
.linked-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--slate-200); border-radius: var(--radius); background: var(--slate-50); margin-bottom: 6px; }
.linked-info { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
.linked-info b { color: var(--slate-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== APT-EXPORT ===== карточки выгрузок: вкладка «Экспорт» у клиента + модалка на главной */
.exp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.exp-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1px solid var(--slate-200); border-radius: var(--radius-lg); background: var(--white); transition: box-shadow .15s, border-color .15s; }
.exp-card:hover { box-shadow: var(--shadow-md); border-color: var(--slate-300); }
.exp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.exp-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.exp-blue  { background: var(--blue-light);  color: var(--blue-dark); }
.exp-green { background: var(--green-light); color: #15803d; }
.exp-amber { background: var(--amber-light); color: #92400e; }
.exp-red   { background: var(--red-light);   color: #991b1b; }
.exp-slate { background: var(--slate-100);   color: var(--slate-600); }
.exp-count { font-size: 20px; font-weight: 600; color: var(--slate-800); line-height: 1.15; text-align: right; }
.exp-unit  { display: block; font-size: 11px; font-weight: 400; color: var(--slate-400); }
.exp-title { font-size: 14px; font-weight: 600; color: var(--slate-800); }
.exp-desc  { flex: 1; font-size: 12px; color: var(--slate-500); line-height: 1.45; }
.exp-toggle { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--slate-600); cursor: pointer; }
.exp-toggle input { cursor: pointer; }
.exp-actions { display: flex; gap: 6px; margin-top: 2px; }
/* Выгружать нечего: кнопки уже disabled — гасим карточку, чтобы это читалось глазом. */
.exp-card.is-empty { opacity: .55; }
.exp-card.is-empty:hover { box-shadow: none; border-color: var(--slate-200); }

/* ===== APT-PROFILE ===== свой профиль и смена своего пароля */
/* Блок пользователя в сайдбаре стал кнопкой — снимаем дефолты браузера. */
.sidebar-user-info { flex: 1; min-width: 0; background: none; border: 0; padding: 4px 6px; margin: -4px -6px; text-align: left; cursor: pointer; border-radius: var(--radius); transition: background .15s; }
.sidebar-user-info:hover { background: rgb(255 255 255 / .08); }
.prof-head { display: flex; align-items: center; gap: 12px; }
.prof-avatar { width: 44px; height: 44px; font-size: 15px; }
.prof-sep { height: 1px; background: var(--slate-200); margin: 16px 0; }
.prof-warn { display: flex; align-items: flex-start; gap: 8px; padding: 9px 11px; border-radius: var(--radius); background: var(--amber-light); color: #92400e; font-size: 12px; line-height: 1.45; }
