:root {
  --crm-primary: #2563eb;
  --crm-primary-dark: #163f9e;
  --crm-primary-soft: #e8f0ff;
  --crm-accent: #98a2b3;
  --crm-accent-dark: #667085;
  --crm-surface: #f4f7fd;
  --crm-panel: #ffffff;
  --crm-panel-soft: #f8fbff;
  --crm-border: #dce5f5;
  --crm-text: #1f2a44;
  --crm-text-soft: #7081a8;
  --crm-success: #17b26a;
  --crm-warning: #ffb020;
  --crm-danger: #f04438;
  --crm-info: #0ea5e9;
}
html[data-bs-theme='dark'] {
  --crm-surface: #0f1728;
  --crm-panel: #131d32;
  --crm-panel-soft: #0f1a30;
  --crm-border: #243351;
  --crm-text: #ebf1ff;
  --crm-text-soft: #96a5c6;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: "Nunito", system-ui, sans-serif; background: var(--crm-surface); color: var(--crm-text); font-size: .95rem; }
a { text-decoration: none; }
.layout-shell { display: flex; min-height: 100vh; }
.sidebar-panel {
  width: 286px; flex: 0 0 286px; padding: 1.5rem 1rem; color: #fff;
  background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 0 2rem rgba(6, 18, 51, .18);
}
.sidebar-brand { display: block; padding: .35rem .6rem 1rem; }
.brand-logo { width: 154px; max-width: 100%; }
.sidebar-section-label { color: rgba(255,255,255,.58); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; padding: 1rem .85rem .45rem; font-weight: 800; }
.sidebar-nav { display: grid; gap: .35rem; }
.sidebar-link { display: flex; align-items: center; gap: .75rem; color: rgba(255,255,255,.84); padding: .85rem .95rem; border-radius: 1rem; font-weight: 800; transition: all .15s ease; }
.sidebar-link:hover, .sidebar-link.active { color: #fff; background: rgba(255,255,255,.11); transform: translateX(2px); }
.sidebar-footer { margin-top: 1.5rem; padding: .85rem 1rem; border-radius: 1rem; background: rgba(255,255,255,.09); }
.page-shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: color-mix(in srgb, var(--crm-panel) 92%, transparent); backdrop-filter: blur(14px); padding: 1rem 1.5rem; position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--crm-border); }
.topbar-search { flex: 1; max-width: 560px; }
.topbar-search .form-control { border: 0; border-radius: 999px; background: color-mix(in srgb, var(--crm-panel-soft) 90%, white); min-height: 48px; padding-left: 2.75rem; box-shadow: inset 0 0 0 1px rgba(36,92,255,.08); }
.topbar-search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--crm-text-soft); }
.topbar-actions { display: flex; align-items: center; gap: .85rem; }
.topbar-pill { border-radius: 999px; padding: .7rem 1rem; }
.topbar-user { display: flex; align-items: center; gap: .75rem; background: var(--crm-panel); border-radius: 999px; padding: .35rem .75rem .35rem .35rem; border: 1px solid var(--crm-border); }
.avatar-circle { width: 2.5rem; height: 2.5rem; border-radius: 50%; background: linear-gradient(135deg, var(--crm-primary-soft), #b7c8ff); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: var(--crm-primary-dark); }
.page-content { padding: 1.6rem; }
.card, .list-group-item { background: var(--crm-panel); color: var(--crm-text); border-color: var(--crm-border); }
.card { border: 1px solid var(--crm-border); border-radius: 1.35rem; box-shadow: 0 .35rem 1rem rgba(15, 23, 42, .06); }
.card-header { background: color-mix(in srgb, var(--crm-panel) 94%, var(--crm-panel-soft)); border-bottom: 1px solid var(--crm-border); padding: 1rem 1.25rem; border-radius: 1.35rem 1.35rem 0 0 !important; }
.card-body { padding: 1.25rem; }
.table { --bs-table-bg: transparent; --bs-table-border-color: var(--crm-border); color: var(--crm-text); }
.table th { white-space: nowrap; color: var(--crm-text-soft); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }
.table > :not(caption) > * > * { padding: 1rem 1.1rem; }
.form-control, .form-select { border-radius: 1rem; border-color: var(--crm-border); min-height: 48px; background: var(--crm-panel); color: var(--crm-text); }
.form-control:focus, .form-select:focus { border-color: rgba(36,92,255,.4); box-shadow: 0 0 0 .2rem rgba(36,92,255,.13); }
textarea.form-control { min-height: 160px; }
.btn { border-radius: .95rem; font-weight: 800; padding: .72rem 1rem; }
.btn-primary { background: linear-gradient(135deg, var(--crm-primary), #4475ff); border-color: var(--crm-primary); }
.btn-primary:hover { background: linear-gradient(135deg, #1746d8, var(--crm-primary-dark)); border-color: var(--crm-primary-dark); }
.btn-outline-primary { color: var(--crm-primary); border-color: rgba(36,92,255,.3); }
.alert { border-radius: 1rem; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.page-subtitle, .soft-muted { color: var(--crm-text-soft); }
.badge-soft, .status-pill { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .75rem; border-radius: 999px; font-weight: 800; font-size: .78rem; }
.badge-soft { background: rgba(36,92,255,.09); color: var(--crm-primary-dark); }
.status-open { background: rgba(14,165,233,.16); color: #0c7aa7; }
.status-progress { background: rgba(36,92,255,.14); color: #1f4fe0; }
.status-pending { background: rgba(255,176,32,.18); color: #a86200; }
.status-resolved, .status-done { background: rgba(23,178,106,.16); color: #0b8a4d; }
.status-closed { background: rgba(112,129,168,.18); color: #53627f; }
.status-neutral { background: rgba(112,129,168,.14); color: #60708f; }
.priority-low { background: rgba(112,129,168,.14); color: #60708f; }
.priority-medium { background: rgba(14,165,233,.13); color: #0b7aa7; }
.priority-high { background: rgba(245,124,0,.16); color: #b45b00; }
.priority-urgent { background: rgba(240,68,56,.16); color: #c72f27; }
.stat-card { overflow: hidden; position: relative; }
.stat-card::after { content: ''; position: absolute; inset: auto -20% -35% auto; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle, rgba(255,174,43,.18), transparent 68%); }
.stat-icon { width: 3.25rem; height: 3.25rem; border-radius: 1rem; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, rgba(36,92,255,.14), rgba(255,174,43,.16)); color: var(--crm-primary-dark); font-size: 1.25rem; }
.kanban-column { min-height: 420px; background: linear-gradient(180deg, color-mix(in srgb, var(--crm-panel) 96%, white), color-mix(in srgb, var(--crm-panel-soft) 96%, white)); }
.kanban-column.drop-hover, .folder-tree-link.drop-hover, .upload-dropzone.is-dragover { outline: 2px dashed var(--crm-primary); outline-offset: -4px; background: rgba(36,92,255,.08); }
.kanban-ticket, .document-card { border: 1px solid var(--crm-border); border-radius: 1rem; box-shadow: 0 .15rem .7rem rgba(58,59,69,.06); background: var(--crm-panel); }
[data-kanban-card], [data-draggable-item] { cursor: grab; }
.dragging { opacity: .55; }
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--crm-surface); }
.login-card { width: min(460px, 100%); background: rgba(255,255,255,.95); border-radius: 1.5rem; box-shadow: 0 1rem 3rem rgba(31,41,55,.12); overflow: hidden; }
.login-hero { padding: 2rem 2rem 1rem; background: linear-gradient(135deg, var(--crm-primary), #6f8df3); color: #fff; }
.login-body { padding: 2rem; }
.folder-tree-panel { background: linear-gradient(180deg, color-mix(in srgb, var(--crm-panel) 96%, white), color-mix(in srgb, var(--crm-panel-soft) 96%, white)); }
.tree-scroll { max-height: calc(100vh - 240px); overflow: auto; padding-right: .4rem; }
.folder-tree, .folder-tree ul { list-style: none; margin: 0; padding: 0; }
.folder-tree ul { margin: .35rem 0 0 1rem; padding-left: .85rem; border-left: 1px dashed rgba(36,92,255,.25); }
.folder-tree details { margin-bottom: .35rem; }
.folder-tree summary { list-style: none; }
.folder-tree summary::-webkit-details-marker { display: none; }
.folder-tree-link { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .68rem .8rem; border-radius: .95rem; color: var(--crm-text); transition: all .15s ease; }
.folder-tree-link:hover, .folder-tree-link.active { background: rgba(36,92,255,.1); color: var(--crm-primary-dark); }
.folder-tree-meta { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.folder-tree-meta i { color: var(--crm-accent-dark); }
.folder-tree-title { min-width: 0; }
.folder-tree-title span { display: block; }
.folder-tree-title small { color: var(--crm-text-soft); }
.document-card { padding: 1rem; height: 100%; }
.document-card-title { font-weight: 800; color: var(--crm-text); }
.document-toolbar, .page-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.upload-dropzone { border: 2px dashed rgba(36,92,255,.2); border-radius: 1.2rem; background: linear-gradient(135deg, rgba(36,92,255,.04), rgba(255,174,43,.05)); }
.breadcrumb.crm-breadcrumb { --bs-breadcrumb-divider: '›'; padding: .8rem 1rem; background: var(--crm-panel); border: 1px solid var(--crm-border); border-radius: 1rem; }
.preview-frame { width: 100%; min-height: 72vh; border: 0; border-radius: 1rem; background: #fff; }
.preview-thumb { width: 100%; height: 160px; border-radius: 1rem; object-fit: cover; background: var(--crm-panel-soft); }
html[data-bs-theme='dark'] .topbar-search .form-control,
html[data-bs-theme='dark'] .topbar-user,
html[data-bs-theme='dark'] .dropdown-menu,
html[data-bs-theme='dark'] .breadcrumb.crm-breadcrumb { background: var(--crm-panel); color: var(--crm-text); }
html[data-bs-theme='dark'] .btn-light { background: var(--crm-panel); color: var(--crm-text); }
html[data-bs-theme='dark'] .text-secondary, html[data-bs-theme='dark'] .small { color: var(--crm-text-soft) !important; }
@media (max-width: 1200px) {
  .sidebar-panel { width: 98px; flex-basis: 98px; }
  .sidebar-brand img { width: 50px; }
  .sidebar-link span, .sidebar-section-label, .sidebar-footer { display: none; }
  .sidebar-link { justify-content: center; }
}
@media (max-width: 991.98px) {
  .layout-shell { display: block; }
  .sidebar-panel { width: 100%; flex-basis: auto; }
  .page-content, .topbar { padding: 1rem; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar-actions { justify-content: space-between; flex-wrap: wrap; }
}


.page-header { margin-bottom: 1.5rem; }
.page-eyebrow { color: var(--crm-primary); font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; margin-bottom: .4rem; }
.page-title { font-size: clamp(1.9rem, 2.4vw, 2.5rem); font-weight: 800; }
.customer-overview-grid { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 1rem; }
.entity-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.crm-card { border: 1px solid var(--crm-border); border-radius: 1.25rem; box-shadow: 0 10px 30px rgba(31,42,68,.06); overflow: hidden; background: color-mix(in srgb, var(--crm-panel) 96%, white); }
.crm-card .card-header { background: transparent; border-bottom: 1px solid var(--crm-border); padding: 1rem 1.25rem; font-weight: 800; }
.crm-card .card-body { padding: 1.25rem; }
.crm-stat-card .card-body, .crm-detail-card .card-body { min-height: 100%; }
.info-stack { display: grid; gap: 1.15rem; }
.field-label { color: var(--crm-text-soft); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .35rem; }
.field-value { color: var(--crm-text); font-weight: 700; line-height: 1.6; }
.pre-wrap { white-space: pre-wrap; }
.icon-btn { width: 2.6rem; height: 2.6rem; display: inline-flex; align-items: center; justify-content: center; border-radius: .9rem; border: 1px solid var(--crm-border); background: #fff; color: var(--crm-primary-dark); box-shadow: 0 .35rem 1rem rgba(31,42,68,.06); }
.icon-btn:hover { background: var(--crm-primary-soft); color: var(--crm-primary-dark); border-color: color-mix(in srgb, var(--crm-primary) 40%, var(--crm-border)); }
.icon-btn-danger { color: var(--crm-danger); }
.icon-btn-danger:hover { background: color-mix(in srgb, var(--crm-danger) 10%, white); border-color: color-mix(in srgb, var(--crm-danger) 30%, var(--crm-border)); color: var(--crm-danger); }
.list-group-item { padding: 1rem 1.25rem; border-color: var(--crm-border); background: transparent; }
.list-group-item-action:hover { background: color-mix(in srgb, var(--crm-primary-soft) 55%, white); }
.topbar-pill, .btn-outline-secondary.rounded-pill { border-radius: 999px !important; }
.login-wordmark { font-size: 1.4rem; font-weight: 800; color: var(--crm-primary-dark); letter-spacing: .01em; }
@media (max-width: 1200px) { .customer-overview-grid { grid-template-columns: 1fr; } }
@media (max-width: 991.98px) { .entity-grid { grid-template-columns: 1fr; } }
