
.crm-container{max-width:none;width:calc(100% - 8px);margin:0 auto}
.crm-shell{display:grid;grid-template-columns:220px minmax(0,1fr);gap:12px;align-items:start}
.crm-sidebar{position:sticky;top:76px;border:1px solid var(--border);background:var(--card);border-radius:14px;padding:12px}
.crm-sidebar__title{font-weight:700;margin-bottom:12px}
.crm-content{min-width:0}
.crm-nav{display:grid;gap:6px}
.crm-nav a{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:10px;color:var(--text);border:1px solid transparent}
.crm-nav a:hover,.crm-nav a.is-active{background:var(--bg-elev);border-color:var(--border)}

.crm-page{display:grid;gap:14px}
.crm-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.crm-grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.crm-grid-3{grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.stats-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
.stats-grid--wide{grid-template-columns:repeat(6,minmax(0,1fr))}

.crm-card{border:1px solid var(--border);background:var(--card);border-radius:14px;padding:16px;min-width:0}
.crm-card--flush{padding:0}
.crm-link{font-weight:700;color:var(--text)}
.crm-title{margin:6px 0 4px;font-size:34px;line-height:1.15}
.crm-toolbar{display:flex;justify-content:space-between;gap:16px;align-items:flex-start;flex-wrap:wrap}
.crm-toolbar__actions{display:flex;gap:10px;flex-wrap:wrap}
.crm-breadcrumbs{display:flex;gap:8px;flex-wrap:wrap;font-size:14px;color:var(--muted)}
.crm-breadcrumbs a{color:var(--muted)}
.crm-breadcrumbs a:hover{color:var(--text)}
.crm-breadcrumbs__sep{color:var(--muted)}
.crm-section-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:14px}
.crm-section-head h1,.crm-section-head h2,.crm-inline-head h2{margin:0}
.crm-badge{display:inline-flex;align-items:center;justify-content:center;min-width:28px;height:28px;padding:0 10px;border-radius:999px;background:var(--bg-elev);border:1px solid var(--border);font-size:13px;color:var(--muted)}
.crm-kv-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px;margin-top:14px}
.crm-kv-grid div{display:grid;gap:4px;padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:var(--bg)}
.crm-kv-grid strong{font-size:12px;color:var(--muted);font-weight:600}
.crm-kv-grid span{min-width:0}

.crm-form{display:grid;gap:12px}
.crm-form--narrow{max-width:980px}
.crm-form label{display:grid;gap:6px;font-size:14px}
.crm-form input,.crm-form select,.crm-form textarea{width:100%;padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:var(--bg);color:var(--text)}
.crm-form__actions{display:flex;gap:8px;flex-wrap:wrap}
.crm-form-card{padding:20px}
.crm-danger-zone{border-color:#e6b8b8}
.crm-inline-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:8px}

.crm-table-wrap{overflow-x:auto;overflow-y:visible;position:relative}
.crm-table-wrap--wide{max-width:none}
.crm-table{width:100%;border-collapse:collapse}
.crm-table th,.crm-table td{padding:10px 10px;border-bottom:1px solid var(--border);text-align:left;vertical-align:top;overflow:visible}
.crm-table th{font-size:13px;color:var(--muted);font-weight:600;background:var(--card);position:sticky;top:0;z-index:1}
.crm-table input[type=number]{width:120px;max-width:100%;padding:8px 10px;border:1px solid var(--border);border-radius:8px;background:var(--bg);color:var(--text)}
.crm-table tr.is-low td{background:rgba(200,16,46,.06)}
.crm-alert{margin-top:12px;padding:10px 12px;border-radius:10px;background:#fff3cd;color:#664d03}
.crm-alert--success{background:#d1e7dd;color:#0f5132}
.crm-alert--error{background:#f8d7da;color:#842029}
.crm-row-actions{display:flex;gap:8px;flex-wrap:wrap}
.crm-col-actions{width:170px}
.stat-card__label{color:var(--muted);font-size:14px;margin-bottom:8px}
.stat-card__value{font-size:32px;font-weight:700;line-height:1}

.crm-tree-table td,.crm-tree-table th{white-space:nowrap}
.crm-tree-table td:first-child,.crm-tree-table th:first-child{width:34%}
.crm-tree-table td:nth-child(7){white-space:normal}
.crm-tree-row--category td{background:rgba(0,0,0,.015);font-weight:600}
.crm-tree-row--category.is-open td{background:rgba(200,16,46,.04)}
.crm-tree-name{display:flex;align-items:center;gap:8px;padding-left:calc(var(--level, 0) * 28px);min-width:420px}
.crm-tree-toggle{width:18px;height:18px;display:inline-flex;align-items:center;justify-content:center;color:var(--muted);border-radius:6px;border:1px solid transparent;flex:0 0 auto}
.crm-tree-toggle:hover{background:var(--bg-elev);border-color:var(--border)}
.crm-tree-toggle.is-empty{visibility:hidden}
.crm-tree-kind{flex:0 0 auto}
.crm-tree-link{color:var(--text);font-weight:700}

.crm-bom-table td:first-child{min-width:420px}
.crm-lookup{position:relative;z-index:5}
.crm-lookup__menu{position:absolute;left:0;right:0;top:calc(100% + 4px);background:var(--card);border:1px solid var(--border);border-radius:10px;box-shadow:0 8px 20px rgba(0,0,0,.08);display:none;z-index:9999;max-height:260px;overflow:auto}
.crm-lookup.is-open .crm-lookup__menu{display:block}
.crm-lookup__menu.is-open{position:fixed;right:auto;display:block;z-index:100000}
.crm-lookup__item{display:block;width:100%;text-align:left;padding:10px 12px;background:none;border:0;border-bottom:1px solid var(--border);cursor:pointer;color:var(--text)}
.crm-lookup__item:last-child{border-bottom:0}
.crm-lookup__item:hover{background:var(--bg-elev)}
.crm-lookup__meta{display:block;font-size:12px;color:var(--muted);margin-top:2px}

@media (max-width: 1400px){.stats-grid--wide{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media (max-width: 1200px){.stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.crm-grid-3{grid-template-columns:1fr}.crm-tree-name{min-width:280px}}
@media (max-width: 980px){.crm-shell{grid-template-columns:1fr}.crm-sidebar{position:static}.crm-grid,.crm-grid-2,.stats-grid,.stats-grid--wide{grid-template-columns:1fr}.crm-title{font-size:28px}.crm-container{width:calc(100% - 4px)}}

.crm-status{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;border:1px solid var(--border);font-size:13px;font-weight:600;background:var(--bg-elev)}
.crm-status--queued{background:#eef2ff;border-color:#c7d2fe;color:#3730a3}
.crm-status--assembly{background:#fff7ed;border-color:#fdba74;color:#9a3412}
.crm-status--ready{background:#ecfeff;border-color:#67e8f9;color:#155e75}
.crm-status--shipped{background:#ecfdf5;border-color:#86efac;color:#166534}
.crm-status--formed{background:#eef2ff;border-color:#c7d2fe;color:#3730a3}
.crm-status--issued{background:#fff7ed;border-color:#fdba74;color:#9a3412}
.crm-status--completed{background:#ecfdf5;border-color:#86efac;color:#166534}
.crm-status--cancelled{background:#fef2f2;border-color:#fca5a5;color:#991b1b}
.crm-filters{display:grid;gap:12px;margin-top:14px}
.crm-filters--inline{grid-template-columns:repeat(4,minmax(0,220px)) auto;align-items:end}
.crm-filters--wrap{grid-template-columns:repeat(4,minmax(0,220px)) auto}
@media (max-width: 1200px){.crm-filters--inline,.crm-filters--wrap{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width: 760px){.crm-filters--inline,.crm-filters--wrap{grid-template-columns:1fr}}
@media (max-width: 1200px){.crm-kv-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width: 760px){.crm-kv-grid{grid-template-columns:1fr}}

.crm-lookup__empty{padding:10px 12px;color:var(--muted);font-size:13px}

.crm-lookup.is-open{z-index:9999}
.crm-card,.crm-card--flush{overflow:visible}
