/* Adapt existing CMS component classes to admin-template/components.css. */
body { margin: 0; font-family: var(--font-sans); font-size: var(--fs-base); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { line-height: 1.25; font-weight: 650; }
::selection { background: var(--accent-ring); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.btn { justify-content: center; gap: 8px; padding: 8px 14px; border-radius: var(--radius-sm); border-color: var(--border-strong); font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; transition: background var(--transition),border-color var(--transition); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { background: var(--brand-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: var(--fs-xs); }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 8px; border-radius: var(--radius-sm); color: var(--text-muted); position: relative; flex: none; }
.btn-icon:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.panel { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.panel-h { padding: var(--sp-4) var(--sp-5); }
.panel-h h2,.fold-btn { font-size: var(--fs-base); }
.panel-b { padding: var(--sp-5); }
.stack { gap: var(--sp-4); }
.ph { gap: var(--sp-4); margin-bottom: var(--sp-5); }
.ph h1 { font-size: var(--fs-2xl); }
.ph .desc { margin-top: 4px; font-size: var(--fs-sm); }
.field { margin-bottom: var(--sp-4); }
.field label { font-size: var(--fs-sm); font-weight: 600; }
.input,select.input,textarea.input { border-color: var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px; transition: border-color var(--transition),box-shadow var(--transition); }
.input::placeholder { color: var(--text-faint); }
.input:focus { box-shadow: 0 0 0 3px var(--accent-ring); }
table { font-size: var(--fs-sm); }
th { background: var(--surface); font-weight: 650; font-size: 11px; letter-spacing: .07em; padding: 11px var(--sp-4); }
td { padding: 11px var(--sp-4); }
tbody tr:hover { background: var(--surface-2); }
.reference-table { min-width: 640px; }
.reference-table input[name="label"] { min-width: 280px; }
.filters { padding: var(--sp-3) var(--sp-5); gap: var(--sp-3); }
.filters .seg { flex-wrap: wrap; }
.pill { font-size: 11px; font-weight: 650; padding: 2px 9px; }
.track { grid-template-columns: repeat(8,minmax(112px,1fr)); }
.avatar { width: 36px; height: 36px; background: var(--accent-soft); color: var(--accent); font-size: var(--fs-sm); font-weight: 700; flex: none; }
.seg { background: var(--surface-2); padding: 3px; gap: 3px; border: 0; border-radius: var(--radius); }
.seg button { border: 0; border-radius: 8px; background: transparent; color: var(--text-muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.breadcrumb { flex: 1; min-width: 0; }
.breadcrumb .current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header .user-btn { padding: 3px; }
.header .bell-btn { border: 0; background: transparent; }
.header .menu { top: calc(100% + 8px); border-radius: var(--radius); }
.header .lang { flex: none; }
.sidebar .nav-link svg { flex: none; }
.nav-link.later { cursor: default; opacity: .55; }
.nav-link.later .nav-text { overflow: hidden; text-overflow: ellipsis; }
.nav-link.later .tag { margin-left: auto; font-size: 9px; }
.nav-link.later:hover { background: transparent; }
[data-sidebar="collapsed"] .nav-link.later .tag { display: none; }
.sidebar-foot .avatar { width: 32px; height: 32px; }
.sidebar-user .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-aside .brand { color: #e0e3eb; margin-bottom: 64px; }
.auth-aside .brand-text { display: inline !important; }
.auth-aside .login-facts { color: #9aa0ae; }
.auth-aside .login-foot { opacity: 1; color: #656b7a; }
.auth-card .sub { color: var(--text-muted); margin: 4px 0 24px; }
.auth-toolbar { position: absolute; top: 16px; right: 16px; display: flex; align-items: center; gap: 8px; }
.auth-main { background: var(--bg); }
.auth-card { padding: var(--sp-6); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.customizer[hidden] { display: none; }
.customizer h3 { font-size: var(--fs-lg); }
.customizer section { min-width: 0; }
.customizer .hint { color: var(--text-faint); font-size: var(--fs-xs); }
.font-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--sp-2); }
.font-option { display: grid; gap: 4px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); text-align: left; font-family: var(--font-sans); font-size: var(--fs-sm); min-width: 0; }
.font-option:hover { border-color: var(--border-strong); }
.font-option[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.font-option small { color: var(--text-muted); font-size: var(--fs-xs); }
.font-hint { margin: var(--sp-2) 0 0; }
.theme-modal-open { overflow: hidden; }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 3px solid var(--up); border-radius: var(--radius); }
.toast.err { background: var(--surface); border-left-color: var(--down); }
.toast.err svg { color: var(--down); }
.error-card { width: min(460px,100%); padding: var(--sp-6); }
.error-card p { color: var(--text-muted); margin: var(--sp-5) 0; }
.error-card .btn-row { justify-content: center; }
[data-density="compact"] td,[data-density="compact"] th { padding-top: 7px; padding-bottom: 7px; }
[data-density="compact"] .doc-row,[data-density="compact"] .nlist.big .nitem { padding-top: 8px; padding-bottom: 8px; }
@media (max-width: 992px) {
  body.sidebar-open { overflow: hidden; }
  [data-sidebar="collapsed"] .nav-link.later .tag { display: inline-flex; }
  .auth-main { min-height: 100vh; }
}
@media (max-width: 768px) {
  .header .user-meta { display: none; }
  .header-search { display: none; }
  .header-actions { gap: 2px; }
  .header .lang button { padding: 5px 7px; min-width: 0; }
  .ph h1 { font-size: 1.4rem; }
  .panel-h,.panel-b,.filters { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .filters .q { min-width: 0; flex-basis: 100%; }
  .filters .input { max-width: 100%; }
  .filters .seg { width: 100%; }
  .perm-grid { grid-template-columns: 1fr; }
  .auth-card { padding: var(--sp-5); }
  .auth-toolbar { top: 12px; right: 12px; }
  .footer { font-size: 11px; }
}
@media (max-width: 480px) {
  .header { gap: 8px; padding: 0 8px; }
  .header .btn-icon { width: 32px; height: 32px; padding: 6px; }
  .header .user-btn { gap: 0; }
  .header .user-btn > svg { display: none; }
  .header .avatar { width: 32px; height: 32px; }
  .header .lang button { padding-left: 5px; padding-right: 5px; }
}

/* fields in a two-column form row: a field without a hint must not stretch its input to match the taller neighbour */
.field { align-content: start; }
.field > input.input, .field > select.input { height: 42px; }

/* phone = country-code drop-down + number, one line */
.phone-row { display: flex; gap: 8px; }
.phone-row select.input { flex: none; width: 44%; max-width: 230px; }
.phone-row input.input { flex: 1; min-width: 0; }
.phone-row .input { height: 42px; }

/* message text boxes (onboarding step 2 window and the template editor) */
textarea.msg-text { width: 100%; font-family: inherit; line-height: 1.5; resize: vertical; }

/* pop-up windows use the admin-template modal (.modal / .modal-dialog / .modal-head, -body, -foot); only sizes are added here */
body.modal-open { overflow: hidden; }
.modal-head h3 { margin: 0; font-size: var(--fs-lg); }
.modal-foot { flex-wrap: wrap; align-items: center; }
.modal-dialog.modal-wide { width: min(760px, 100%); }
/* the person window: always 90% of the screen wide and high; the tab content scrolls inside it */
.modal-dialog.modal-90 { width: min(90vw, 100%); height: min(90vh, 100%); max-height: none; display: flex; flex-direction: column; overflow: hidden; }
.modal-90 > [data-tabpanel]:not([hidden]) { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.modal-90 > [data-tabpanel] > form:first-child { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.modal-90 > [data-tabpanel] > .modal-body:first-child, .modal-90 > [data-tabpanel] > form:first-child > .modal-body { flex: 1; min-height: 0; overflow: auto; }
.idm-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-6, 28px); margin-top: 14px; align-items: start; }
.idm-col { min-width: 0; }
@media (max-width: 900px) { .idm-cols { grid-template-columns: minmax(0, 1fr); } }
.modal-dialog.modal-full { width: min(95vw, 100%); height: min(95vh, 100%); max-height: none; display: flex; flex-direction: column; overflow: hidden; }
.modal-full .modal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: var(--sp-3) var(--sp-5); }
/* document review window */
.rv-view { flex: 1; min-height: 0; display: flex; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-3); }
.rv-view iframe { flex: 1; width: 100%; height: 100%; border: 0; background: #fff; }
.rv-view iframe[hidden], .rv-view img[hidden] { display: none; }
.rv-view img { margin: auto; display: block; background: #fff; }
.rv-view img.fit { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.rv-view img.real { max-width: none; max-height: none; }
.modal-foot.rv-actions { justify-content: space-between; }

/* case history window: calendar + board by step */
.hist-cal { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 520px) 1fr; gap: 20px; overflow: auto; }
.hc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.hc-h { text-align: center; font-size: 12px; color: var(--text-muted); padding: 4px 0; }
.hc-d { position: relative; min-height: 64px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.hc-d:hover { background: var(--surface-2); }
.hc-d.today { border-color: var(--accent); }
.hc-d.sel { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.hc-d .badge { position: absolute; right: 6px; bottom: 6px; }
.hc-d.sel .badge { background: var(--accent-contrast); color: var(--accent); }
.hist-day { overflow: auto; }
.hist-day h3 { margin: 4px 0 12px; font-size: 16px; }
.hl { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 8px; background: var(--surface); }
.hl-h { display: flex; gap: 10px; font-size: 12.5px; margin-bottom: 2px; }
.hb { flex: 1; min-height: 0; display: flex; gap: 12px; overflow: auto; align-items: flex-start; }
.hb[hidden], .hist-cal[hidden] { display: none; }
.hb-col { flex: none; width: 270px; max-height: 100%; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 10px; }
.hb-col.later { opacity: .55; }
.hb-col.cur { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.hb-h { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 13px; }
@media (max-width: 900px) { .hist-cal { grid-template-columns: 1fr; } }

/* copied verbatim from admin-template/assets/css/components.css: modal and badge */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: var(--sp-4); background: rgba(2, 8, 18, .6); }
.modal.open { display: flex; }
.modal-dialog { width: min(520px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.modal-body { padding: var(--sp-5); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--radius-full); font-size: 11px; font-weight: 650; background: var(--surface-3); color: var(--text-muted); white-space: nowrap; }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* entity details: tick-box lists */
.chk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 18px; margin-top: 6px; }
label.lbl { font-size: var(--fs-sm); font-weight: 600; }

/* shareholding structure: one donut chart per ownership group */
.dc-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-5); margin-top: var(--sp-4); }
.dc-card { flex: 1 1 400px; max-width: 560px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: var(--sp-5); }
.dc-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 16px; font-size: var(--fs-lg, 16px); }
.dc-body { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-5); }
.dc-svg { width: 220px; height: 220px; flex: none; }
.dc-bg { fill: none; stroke: var(--surface-3); stroke-width: 6; }
.dc-seg { fill: none; stroke-width: 6; }
.dc-c { fill: var(--text); font-size: 7px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }
.dc-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: var(--fs-base, 14px); min-width: 180px; flex: 0 1 260px; }
.dc-legend li { display: flex; gap: 8px; align-items: baseline; }
.dc-sw { width: 10px; height: 10px; border-radius: 3px; flex: none; position: relative; top: 1px; }
.dc-n { flex: 1; min-width: 0; overflow-wrap: anywhere; }
:root { --dc0: #2962ff; --dc1: #089981; --dc2: #ea580c; --dc3: #8b5cf6; --dc4: #ec4899; --dc5: #14b8a6; --dc6: #eab308; --dc7: #64748b; }
.dc-0 { stroke: var(--dc0); } .dc-1 { stroke: var(--dc1); } .dc-2 { stroke: var(--dc2); } .dc-3 { stroke: var(--dc3); } .dc-4 { stroke: var(--dc4); } .dc-5 { stroke: var(--dc5); } .dc-6 { stroke: var(--dc6); } .dc-7 { stroke: var(--dc7); }
.dcb-0 { background: var(--dc0); } .dcb-1 { background: var(--dc1); } .dcb-2 { background: var(--dc2); } .dcb-3 { background: var(--dc3); } .dcb-4 { background: var(--dc4); } .dcb-5 { background: var(--dc5); } .dcb-6 { background: var(--dc6); } .dcb-7 { background: var(--dc7); }

/* Persons & identity window: tabs (Info + one per document) and the document viewer */
.idm-tabs { display: flex; gap: 4px; padding: 0 var(--sp-5); border-bottom: 1px solid var(--border); overflow-x: auto; }
.idm-tab { border: 0; background: none; padding: 12px 14px; cursor: pointer; color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap; font: inherit; }
.idm-tab:hover { color: var(--text); }
.idm-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.idm-view { width: 100%; height: calc(90vh - 250px); min-height: 320px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.ocr-filled { background: var(--accent-soft); }
.idm-imgwrap { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 8px; max-height: calc(90vh - 250px); overflow: auto; text-align: center; }
.idm-img { max-width: 100%; max-height: calc(90vh - 270px); object-fit: contain; }
/* Info tab: cards */
.idm-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--sp-5); align-items: start; }
.idm-stack { display: grid; gap: var(--sp-4); min-width: 0; }
.idm-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.idm-card > h4 { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); display: flex; justify-content: space-between; gap: 8px; }
.idm-cb { padding: 14px; }
.idm-card .field { margin-bottom: var(--sp-3); }
.idm-docs { width: 100%; border-collapse: collapse; }
.idm-docs td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.idm-docs tr:last-child td { border-bottom: 0; }
@media (max-width: 900px) { .idm-grid { grid-template-columns: minmax(0, 1fr); } }
