:root {
  --bg: #10131a;
  --panel: #171c25;
  --panel-muted: #202736;
  --text: #edf2ff;
  --text-muted: #a6b0c3;
  --border: #2c3446;
  --primary: #4c8dff;
  --primary-hover: #3d79de;
  --danger-bg: #3a1f28;
  --danger-text: #ffc8d5;
  --success-bg: #1d3527;
  --success-text: #b9f5c6;
}

:root[data-theme='light'] {
  --bg: #f1f4fa;
  --panel: #ffffff;
  --panel-muted: #f6f8fc;
  --text: #1b2433;
  --text-muted: #5f6b7c;
  --border: #dbe2ee;
  --primary: #2f6fe9;
  --primary-hover: #1f5fcf;
  --danger-bg: #ffe5ea;
  --danger-text: #7c2239;
  --success-bg: #e4f7e8;
  --success-text: #245b32;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, Arial, sans-serif; background: var(--bg); color: var(--text); }

.auth-wrapper { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; }
.auth-brand h1 { margin: 0; }
.auth-brand p { margin: 0.4rem 0 1rem; color: var(--text-muted); }
.auth-form { display: grid; gap: 0.6rem; }
label { font-size: 0.9rem; color: var(--text-muted); }
input { padding: 0.72rem 0.85rem; border: 1px solid var(--border); background: var(--panel-muted); color: var(--text); border-radius: 10px; }
input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.primary-btn { margin-top: 0.5rem; border: 0; border-radius: 10px; padding: 0.8rem 1rem; background: var(--primary); color: #fff; cursor: pointer; }
.primary-btn:hover { background: var(--primary-hover); }
.error-message, .status-message { border-radius: 10px; padding: 0.65rem 0.75rem; margin: 0 0 1rem; }
.error-message { background: var(--danger-bg); color: var(--danger-text); }
.status-message { background: var(--success-bg); color: var(--success-text); }

.dashboard-layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 1.25rem; }
.sidebar-brand { font-size: 1.2rem; font-weight: 700; margin-bottom: 1rem; }
.sidebar-placeholder { color: var(--text-muted); }
.topbar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--panel); }
.action-bar { display: flex; align-items: center; gap: 0.5rem; }
.icon-btn, .user-menu-toggle { background: var(--panel-muted); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 0.45rem 0.65rem; cursor: pointer; }
.icon-btn:hover, .user-menu-toggle:hover { border-color: var(--primary); }
.user-menu { position: relative; }
.user-menu-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 0.3rem; }
.user-menu-dropdown.open { display: block; }
.menu-item { display: block; width: 100%; text-align: left; text-decoration: none; color: var(--text); background: transparent; border: 0; padding: 0.6rem 0.75rem; border-radius: 8px; font: inherit; }
.menu-item:hover { background: var(--panel-muted); }
.menu-item:disabled { color: var(--text-muted); cursor: not-allowed; }
.dashboard-content { padding: 1.25rem; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; }
.placeholder-response { color: var(--text-muted); min-height: 1.2rem; }

@media (max-width: 900px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .topbar { flex-wrap: wrap; }
}


.crm-page { background: var(--bg); }
.crm-page-content { width: min(1500px, 100%); margin: 0 auto; padding: 1rem 1rem 6.5rem; }
.crm-breadcrumb { display: flex; gap: 0.4rem; align-items: center; margin-bottom: 0.8rem; font-size: 0.86rem; color: var(--text-muted); }
.crm-breadcrumb a { color: var(--text); text-decoration: none; }
.crm-breadcrumb a:hover { color: var(--primary); }

.crm-form-container { display: grid; gap: 0.7rem; width: 100%; }
.crm-section { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); overflow: hidden; }
.crm-section-header { display: flex; justify-content: space-between; align-items: center; min-height: 38px; padding: 0.45rem 0.75rem; background: var(--panel-muted); border-bottom: 1px solid var(--border); }
.crm-section-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.crm-section-toggle { color: var(--text-muted); font-size: 0.85rem; }
.crm-section-body { padding: 0.7rem 0.75rem; background: var(--panel); }

.crm-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.5rem 1rem; }
.crm-form-grid-single { grid-template-columns: 1fr; }
.crm-form-row { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 0.5rem; align-items: center; min-height: 36px; }
.crm-form-label { margin: 0; font-size: 0.86rem; text-align: right; color: var(--text-muted); }
.crm-required { color: #d43737; margin-right: 0.2rem; font-weight: 700; }
.crm-form-field { width: 100%; }

.crm-form-control { width: 100%; height: 34px; padding: 0.38rem 0.55rem; border-radius: 5px; border: 1px solid var(--border); background: var(--panel-muted); color: var(--text); }
.crm-form-control:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.crm-description { min-height: 120px; height: auto; resize: vertical; }
.crm-subsection-title { margin: 0.35rem 0 0.45rem; font-size: 0.9rem; color: var(--text); }
.crm-address-copy { margin: 0.25rem 0 0.5rem; }
.crm-address-copy label { color: var(--text-muted); font-size: 0.85rem; }
.crm-address-copy input[type="checkbox"] { width: auto; height: auto; padding: 0; border-radius: 4px; vertical-align: middle; }

.crm-currency { text-align: right; }

.crm-form-actions {
  position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: center; gap: 0.6rem;
  padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}
.crm-primary-button {
  border: 0; border-radius: 7px; padding: 0.55rem 1rem; background: var(--primary); color: #fff; cursor: pointer;
}
.crm-primary-button:hover { background: var(--primary-hover); }
.crm-secondary-button {
  display: inline-flex; align-items: center; text-decoration: none; border: 1px solid var(--border);
  border-radius: 7px; padding: 0.55rem 1rem; color: var(--text); background: var(--panel-muted);
}
@media (max-width: 860px) {
  .crm-form-grid { grid-template-columns: 1fr; }
  .crm-form-row { grid-template-columns: 1fr; }
  .crm-page-content { padding: 0.8rem 0.7rem 6rem; }
  .crm-form-label { text-align: left; }
}

.app-shell { display:grid; grid-template-columns:260px 1fr; min-height:100vh; }
.app-shell.app-shell-no-sidebar { grid-template-columns:1fr; }
.app-shell.sidebar-collapsed { grid-template-columns:78px 1fr; }
.app-shell.app-shell-no-sidebar.sidebar-collapsed { grid-template-columns:1fr; }
.sidebar-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:.8rem}
.sidebar-nav{display:grid;gap:.45rem}
.menu-group{border:1px solid var(--border);border-radius:8px;background:var(--panel-muted)}
.menu-group-header{width:100%;display:flex;justify-content:space-between;align-items:center;background:transparent;border:0;color:var(--text);padding:.45rem .6rem;cursor:pointer}
.menu-group-list{list-style:none;margin:0;padding:0 .35rem .45rem;display:grid;gap:.2rem}
.menu-group.collapsed .menu-group-list{display:none}
.menu-link{display:block;padding:.35rem .45rem;border-radius:6px;color:var(--text);text-decoration:none}
.menu-link:hover{background:var(--panel)}
.menu-link.active{background:var(--primary);color:#fff}
.menu-link.disabled{color:var(--text-muted);cursor:not-allowed}
.workspace-content{padding:1rem;overflow:auto}
.accounts-fields-panel{border:1px solid var(--border);border-radius:8px;background:var(--panel-muted)}
.accounts-fields-body{display:none;padding:.4rem .65rem;max-height:280px;overflow:auto}
.accounts-fields-panel.open .accounts-fields-body{display:block}
.accounts-fields-body h4{margin:.4rem 0 .2rem;font-size:.82rem}
.accounts-fields-body ul{margin:.1rem 0 .45rem;padding-left:1rem}
@media (max-width: 900px){.app-shell{grid-template-columns:1fr}.sidebar{border-right:0;border-bottom:1px solid var(--border)}}

.inline-form{display:inline}
.crm-view-actions{display:flex;justify-content:flex-end;gap:.55rem;margin:0 0 .7rem}
.crm-record-content{max-width:none;width:calc(100% - 30px);margin-left:15px;margin-right:15px;padding-left:0;padding-right:0}
.crm-record-header-row{display:flex;justify-content:space-between;align-items:center;gap:.8rem;margin-bottom:.7rem}
.crm-record-breadcrumb{margin-bottom:0}
.crm-record-header-actions{display:flex;justify-content:flex-end;align-items:center}
.crm-edit-icon-btn{padding:.45rem .7rem;font-size:.95rem;line-height:1}
.crm-view-value{font-size:.9rem;color:var(--text);word-break:break-word}
.accounts-filter-form{display:flex;gap:.5rem;flex-wrap:wrap;margin:.75rem 0}
.accounts-filter-form input,.accounts-filter-form select{max-width:220px}

.crm-list-page{padding:.85rem}.crm-list-breadcrumb{display:flex;align-items:center;gap:.35rem;font-size:.84rem;color:var(--text-muted);margin-bottom:.7rem}.crm-list-breadcrumb a{text-decoration:none;color:var(--text-muted)}.crm-list-breadcrumb a:hover{color:var(--primary)}.crm-list-breadcrumb strong{color:var(--text);font-weight:600}.crm-breadcrumb-sep{opacity:.75}
.crm-list-toolbar{display:flex;justify-content:space-between;align-items:center;gap:.7rem;flex-wrap:wrap;margin-bottom:.7rem}.crm-list-toolbar-left{display:flex;align-items:center;gap:.45rem;flex-wrap:wrap}.crm-list-toolbar-right{display:flex;align-items:center}.crm-record-count{font-size:.86rem;color:var(--text-muted)}
.crm-dropdown{position:relative}.crm-dropdown-button,.crm-primary-action{display:inline-flex;align-items:center;justify-content:center;min-height:34px;padding:.45rem .75rem;border-radius:7px;border:1px solid var(--border);background:var(--panel-muted);color:var(--text);text-decoration:none;cursor:pointer;font-size:.86rem}.crm-dropdown-button::after{content:'▾';margin-left:.4rem;font-size:.7rem}.crm-dropdown-button:hover,.crm-primary-action:hover{border-color:var(--primary)}.crm-primary-action{background:var(--primary);border-color:var(--primary);color:#fff}.crm-primary-action:hover{background:var(--primary-hover);border-color:var(--primary-hover)}
.crm-dropdown-menu{display:none;position:absolute;top:calc(100% + 4px);left:0;min-width:170px;background:var(--panel);border:1px solid var(--border);border-radius:8px;padding:.25rem;z-index:20}.crm-dropdown-menu.open{display:block}.crm-dropdown-item{display:block;width:100%;text-align:left;padding:.42rem .55rem;border:0;background:transparent;color:var(--text);border-radius:6px;font-size:.84rem}.crm-dropdown-item:disabled{color:var(--text-muted);cursor:not-allowed}
.crm-data-table-wrap{overflow:auto;border:1px solid var(--border);border-radius:10px}.crm-data-table{width:100%;border-collapse:collapse;border-spacing:0}.crm-data-table th,.crm-data-table td{padding:.5rem .6rem;border-left:0;border-right:0;border-top:0;border-bottom:1px solid var(--border);font-size:.85rem;text-align:left;vertical-align:middle}.crm-data-table tbody tr:last-child td{border-bottom:0}.crm-table-header-row th{background:var(--panel-muted);font-weight:600}.crm-table-filter-row th{background:color-mix(in srgb,var(--panel-muted) 65%,var(--panel) 35%);padding:.35rem .5rem}.crm-table-filter-input{width:100%;height:30px;padding:.3rem .45rem;border:1px solid var(--border);border-radius:6px;background:var(--panel);color:var(--text);font-size:.8rem}
.crm-clickable-row{cursor:pointer}.crm-clickable-row:hover td{background:color-mix(in srgb,var(--panel-muted) 75%, transparent)}.crm-empty-state{text-align:center;color:var(--text-muted)}
.visually-hidden{position:absolute !important;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0}

.sidebar{height:100vh;display:flex;flex-direction:column;overflow:hidden}
.sidebar-nav{min-height:0;display:flex;flex-direction:column;gap:.45rem;flex:1}
.sidebar-nav-scroll{overflow-y:auto;overflow-x:hidden;min-height:0;display:grid;gap:.45rem;padding-right:.2rem}
.sidebar-nav-scroll::-webkit-scrollbar{width:8px}.sidebar-nav-scroll::-webkit-scrollbar-thumb{background:var(--border);border-radius:8px}
.menu-link{display:flex;align-items:center;gap:.45rem}
.menu-link-icon{display:inline-flex;align-items:center;justify-content:center;width:1.1rem;flex:0 0 1.1rem}
.crm-dropdown-item{text-decoration:none}
.crm-checkbox-col{width:42px;text-align:center}
.crm-checkbox-col input[type='checkbox']{width:auto;height:auto;padding:0}
.app-shell.sidebar-collapsed .menu-link-label,.app-shell.sidebar-collapsed .menu-group-title,.app-shell.sidebar-collapsed .sidebar-brand{display:none}
.app-shell.sidebar-collapsed .menu-link{justify-content:center}
.crm-export-type{max-width:280px}

.crm-table-header-row .crm-checkbox-col,.crm-table-filter-row .crm-checkbox-col{text-align:center}

.crm-settings-page{padding:1rem}
.crm-settings-header h2{margin:0 0 .75rem;font-size:1.2rem}
.crm-settings-layout{display:grid;grid-template-columns:minmax(260px,320px) minmax(0,1fr);gap:.9rem;align-items:start}
.crm-settings-sidebar{border:1px solid var(--border);border-radius:10px;background:var(--panel-muted);padding:.7rem;max-height:calc(100vh - 220px);overflow:auto}
.crm-settings-section{margin-bottom:.65rem}
.crm-settings-section:last-child{margin-bottom:0}
.crm-settings-section-title{margin:0 0 .35rem;font-size:.82rem;text-transform:uppercase;letter-spacing:.04em;color:var(--text-muted)}
.crm-settings-section ul{list-style:none;margin:0;padding:0;display:grid;gap:.2rem}
.crm-settings-link{display:block;padding:.36rem .5rem;border-radius:6px;color:var(--text);text-decoration:none;font-size:.88rem}
.crm-settings-link:hover{background:var(--panel)}
.crm-settings-link.active{background:var(--primary);color:#fff}
.crm-settings-link.disabled{color:var(--text-muted);cursor:not-allowed}
.crm-settings-content{border:1px solid var(--border);border-radius:10px;background:var(--panel);padding:1rem;min-height:300px;min-width:0}
@media (max-width: 900px){.crm-settings-layout{grid-template-columns:1fr}.crm-settings-sidebar{max-height:none}}

.crm-record-tabs-wrap{display:flex;align-items:center;gap:.5rem;border:1px solid var(--border);background:var(--panel);border-radius:10px;padding:.4rem .45rem;margin-bottom:.7rem;overflow:hidden}
.crm-record-tabs{display:flex;align-items:center;gap:.35rem;min-width:0;flex:1;overflow:hidden}
.crm-record-tab{display:inline-flex;align-items:center;padding:.35rem .6rem;border:1px solid transparent;border-radius:7px;color:var(--text);text-decoration:none;white-space:nowrap;font-size:.84rem;background:transparent}
.crm-record-tab:hover{border-color:var(--border);background:var(--panel-muted)}
.crm-record-tab-active{background:var(--primary);color:#fff;border-color:var(--primary)}
.crm-tab-hidden{display:none}
.crm-record-tab-more{position:relative;flex:0 0 auto}
.crm-record-tab-dropdown{display:none;position:absolute;right:0;top:calc(100% + 4px);min-width:200px;background:var(--panel);border:1px solid var(--border);border-radius:8px;padding:.25rem;z-index:30}
.crm-record-tab-dropdown.open{display:grid;gap:.2rem}
.crm-tab-content{display:grid;gap:.7rem}
.crm-comments-panel .crm-section-body{display:grid;gap:.8rem}
.crm-comment-form{display:grid;grid-template-columns:4fr 1fr;gap:.6rem;align-items:stretch}
.crm-comment-textarea{width:100%;min-height:88px;resize:none;padding:.55rem .65rem;border:1px solid var(--border);border-radius:8px;background:var(--panel-muted);color:var(--text);font:inherit;line-height:1.35}
.crm-comment-post-button{min-height:88px;border-radius:8px}
.crm-comment-list{display:grid;gap:.65rem}
.crm-comment-bubble{border:1px solid var(--border);border-radius:10px;padding:.6rem .7rem;background:var(--panel-muted)}
.crm-comment-meta{display:flex;align-items:center;gap:.35rem;flex-wrap:wrap;margin-bottom:.35rem}
.crm-comment-actions{display:inline-flex;align-items:center;gap:.3rem;margin-left:.25rem}
.crm-comment-action{border:1px solid var(--border);background:var(--panel);color:var(--text);border-radius:6px;padding:.2rem .35rem;cursor:pointer}
.crm-comment-body{white-space:normal;word-break:break-word}
.crm-comment-edit-form{display:grid;gap:.45rem;margin-top:.55rem}
.crm-comment-edit-form[hidden]{display:none}
.crm-comment-edit-actions{display:flex;gap:.4rem}
@media (max-width: 760px){.crm-comment-form{grid-template-columns:1fr}.crm-comment-post-button{min-height:44px}}
@media (max-width: 760px){.crm-record-header-row{flex-wrap:wrap}}
.crm-updates-list{display:grid;gap:.65rem}
.crm-update-bubble{border:1px solid var(--border);border-radius:10px;padding:.6rem .7rem;background:var(--panel-muted)}
.crm-update-meta{margin:0 0 .35rem;font-size:.85rem;color:var(--text)}
.crm-update-lines{display:grid;gap:.3rem}
.crm-update-line{margin:0;white-space:normal;word-break:break-word;line-height:1.35}
.crm-field-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.6rem;min-height:52px}
.crm-field-item{border:1px solid var(--border);border-radius:8px;padding:.5rem .6rem;background:var(--panel-muted);display:flex;justify-content:space-between;gap:.5rem;align-items:center}
.crm-field-title{font-weight:600;color:var(--text);display:flex;align-items:center;gap:.35rem}
.crm-drag-handle{color:var(--text-muted);font-size:.9rem;cursor:grab;user-select:none}
.crm-drag-handle:active{cursor:grabbing}
.crm-field-dropzone-active{outline:2px dashed var(--primary);outline-offset:-4px}
.crm-drag-placeholder{border:1px dashed var(--primary);border-radius:8px;min-height:42px;background:color-mix(in srgb,var(--primary) 12%,transparent)}
.crm-field-badges{display:flex;gap:.3rem;flex-wrap:wrap}
.crm-badge{font-size:.74rem;line-height:1;padding:.18rem .5rem;border-radius:999px;background:var(--panel);border:1px solid var(--border);color:var(--text-muted)}
.crm-badge-type{color:var(--text)}
.crm-field-group-head{display:flex;align-items:center;gap:.35rem}
.crm-field-editor-header{position:relative;display:flex;align-items:center;min-height:2.75rem;margin-bottom:.75rem}
.crm-field-editor-header h2{margin:0}
.crm-field-editor-module-form{position:absolute;left:50%;display:flex;align-items:center;gap:.5rem;max-width:min(100%,420px);margin:0;transform:translateX(-50%);white-space:nowrap}
.crm-field-editor-module-form select{width:min(280px,52vw);max-width:100%}
@media (max-width:760px){.crm-field-editor-header{display:grid;gap:.6rem}.crm-field-editor-module-form{position:static;justify-self:center;width:100%;flex-wrap:wrap;justify-content:center;transform:none}.crm-field-editor-module-form select{width:min(280px,100%)}}
.crm-small-button{padding:.2rem .45rem;font-size:.78rem}
.is-dragging{opacity:.45}
@media (max-width:900px){.crm-field-grid{grid-template-columns:1fr}}

.crm-settings-breadcrumb{margin:0 0 .45rem;color:var(--text-muted);font-size:.84rem}
.crm-picklist-manager h2{margin:.1rem 0 .85rem}
.crm-picklist-selectors{display:grid;gap:.75rem;margin-bottom:1rem;max-width:720px}
.crm-picklist-selector-row{display:grid;gap:.3rem}
.crm-picklist-selector-row label{font-weight:600;color:var(--text)}
.crm-picklist-selector-row select{width:100%;height:36px;padding:.35rem .55rem;border:1px solid var(--border);border-radius:7px;background:var(--panel-muted);color:var(--text)}
.crm-picklist-actions{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;margin:.3rem 0 .75rem}
.crm-picklist-actions form{margin:0}
.crm-picklist-list{display:grid;gap:.35rem;max-width:780px}
.crm-picklist-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto auto;gap:.55rem;align-items:center;min-height:42px;padding:.5rem .6rem;border:1px solid var(--border);border-radius:9px;background:var(--panel-muted)}
.crm-picklist-row:hover{border-color:color-mix(in srgb,var(--primary) 55%,var(--border))}
.crm-picklist-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text)}
.crm-icon-action{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;border:1px solid var(--border);border-radius:7px;background:var(--panel);color:var(--text);cursor:pointer;text-decoration:none}
.crm-icon-action:hover{border-color:var(--primary);color:var(--primary)}
.crm-icon-danger:hover{border-color:var(--danger-text);color:var(--danger-text)}
.crm-picklist-delete-form{margin:0;display:inline-flex}
.crm-picklist-dialog{border:1px solid var(--border);border-radius:12px;background:var(--panel);color:var(--text);padding:1rem;min-width:min(420px,calc(100vw - 2rem))}
.crm-picklist-dialog::backdrop{background:rgba(0,0,0,.45)}
.crm-picklist-dialog form{display:grid;gap:.55rem}
.crm-picklist-dialog h3{margin:0 0 .25rem}
.crm-picklist-dialog input{width:100%}
.crm-alert-success{border-radius:10px;padding:.65rem .75rem;background:var(--success-bg);color:var(--success-text);margin:0 0 .75rem}
.crm-alert-error{border-radius:10px;padding:.65rem .75rem;background:var(--danger-bg);color:var(--danger-text);margin:0 0 .75rem}
@media (max-width:640px){.crm-picklist-row{grid-template-columns:auto minmax(0,1fr) auto auto}.crm-picklist-actions{align-items:stretch}.crm-picklist-actions .crm-primary-button,.crm-picklist-actions .crm-secondary-button{width:100%}}


.crm-settings-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}
.crm-settings-title-row h2 { margin: 0; font-size: 1.28rem; }
.crm-settings-title-row p { margin: 0.25rem 0 0; color: var(--text-muted); font-size: 0.88rem; }
.crm-role-tree-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-muted) 72%, var(--panel) 28%), var(--panel));
  padding: 1rem;
  min-height: 260px;
}
.crm-role-tree { min-width: max-content; }
.crm-role-tree-list { position: relative; list-style: none; margin: 0; padding-left: 1.45rem; }
.crm-role-tree > .crm-role-tree-list { padding-left: 0; }
.crm-role-tree-list .crm-role-tree-list { margin-left: 1.15rem; padding-left: 1.45rem; }
.crm-role-tree-list .crm-role-tree-list::before {
  content: "";
  position: absolute;
  top: -0.35rem;
  bottom: 0.85rem;
  left: 0.42rem;
  width: 1px;
  background: var(--border);
}
.crm-role-tree-item { position: relative; margin: 0.38rem 0; padding-left: 1rem; }
.crm-role-tree > .crm-role-tree-list > .crm-role-tree-item { padding-left: 0; }
.crm-role-tree-list .crm-role-tree-list > .crm-role-tree-item::before {
  content: "";
  position: absolute;
  top: 1.05rem;
  left: -1.02rem;
  width: 1.02rem;
  height: 1px;
  background: var(--border);
}
.crm-role-node-row { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 34px; }
.crm-role-node {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  padding: 0.42rem 0.72rem;
  box-shadow: 0 7px 18px color-mix(in srgb, #000 18%, transparent);
  font-size: 0.88rem;
  line-height: 1.1;
  white-space: nowrap;
}
.crm-role-node-system {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  background: color-mix(in srgb, var(--primary) 10%, var(--panel));
}
.crm-role-node-locked {
  border-style: dashed;
}
.crm-role-system-badge,
.crm-role-lock-badge {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  border-radius: 999px;
  padding: 0.12rem 0.35rem;
}
.crm-role-lock-badge {
  color: var(--muted);
  background: var(--panel-muted);
  border-color: var(--border);
}
.crm-role-node-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  opacity: 0;
  transform: translateX(-0.25rem);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}
.crm-role-node-row:hover .crm-role-node-actions,
.crm-role-node-row:focus-within .crm-role-node-actions {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.crm-role-delete-form { display: inline; margin: 0; }
.crm-role-icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}
.crm-role-icon-action:hover { border-color: var(--primary); color: #fff; background: var(--primary); }
.crm-role-delete-action:hover { border-color: var(--danger-text); background: var(--danger-bg); color: var(--danger-text); }
.crm-role-add-form,
.crm-role-move-form {
  display: inline-grid;
  grid-template-columns: minmax(180px, 260px) auto auto;
  gap: 0.35rem;
  align-items: center;
  margin: 0.3rem 0 0.2rem 2rem;
}
.crm-role-add-form[hidden],
.crm-role-move-form[hidden] { display: none; }
.crm-role-move-form {
  grid-template-columns: auto minmax(210px, 310px) auto auto;
}
.crm-role-move-form label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}
.crm-role-name-input,
.crm-role-move-form select {
  height: 32px;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}
.crm-role-small-button { min-height: 32px; padding: 0.35rem 0.65rem; font-size: 0.82rem; }
.crm-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 700px) {
  .crm-role-tree-wrap { padding: 0.75rem; }
  .crm-role-add-form,
  .crm-role-move-form { grid-template-columns: minmax(190px, 1fr); margin-left: 1rem; }
  .crm-role-tree-list .crm-role-tree-list { margin-left: 0.7rem; padding-left: 1.15rem; }
  .crm-role-node { font-size: 0.84rem; padding: 0.38rem 0.62rem; }
}

.crm-date-input-wrap{position:relative;display:flex;align-items:center}
.crm-date-input-wrap .crm-form-control{padding-right:2.1rem}
.crm-date-icon{position:absolute;right:.6rem;pointer-events:none;color:var(--text-muted);font-size:.9rem;line-height:1}
.crm-status-badge{display:inline-flex;align-items:center;min-height:24px;padding:.18rem .52rem;border-radius:999px;font-size:.78rem;border:1px solid var(--border);background:var(--panel-muted);color:var(--text)}
.crm-status-active{background:var(--success-bg);color:var(--success-text);border-color:color-mix(in srgb,var(--success-text) 35%,var(--border))}
.crm-status-inactive{background:var(--danger-bg);color:var(--danger-text);border-color:color-mix(in srgb,var(--danger-text) 35%,var(--border))}
