:root{
  --bg:#edf2f8;
  --surface:#ffffff;
  --surface-alt:#f5f8fc;
  --surface-soft:#eef4fb;
  --line:#d7e1ec;
  --text:#18212c;
  --muted:#68788b;
  --blue:#145bc6;
  --blue-deep:#0f2e63;
  --orange:#f28c28;
  --orange-deep:#d86e0f;
  --green:#1f9251;
  --yellow:#c99115;
  --red:#c63f3f;
  --shadow:0 18px 42px rgba(15,35,67,.1);
  --radius:18px;
}

*{box-sizing:border-box}

html,body{
  margin:0;
  padding:0;
  min-height:100%;
  font-family:"Segoe UI",sans-serif;
  background:linear-gradient(180deg,#f8fbff 0%,#eff4fa 100%);
  color:var(--text);
  scroll-behavior:smooth;
}

body.drawer-open{
  overflow:hidden;
}

a{
  color:inherit;
  text-decoration:none;
}

button,input,select,textarea{
  font:inherit;
}

[hidden]{
  display:none !important;
}

.auth-shell{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
  background:
    radial-gradient(circle at top left,rgba(20,91,198,.08) 0%,transparent 28%),
    radial-gradient(circle at bottom right,rgba(242,140,40,.1) 0%,transparent 22%),
    linear-gradient(180deg,#f8fbff 0%,#eff4fa 100%);
}

.auth-card,.hero-card,.overview-card,.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}

.auth-card{
  width:min(100%,480px);
  padding:28px;
}

.auth-eyebrow,.eyebrow{
  color:var(--blue);
  font-size:.78rem;
  text-transform:uppercase;
  letter-spacing:.14em;
  font-weight:700;
  margin-bottom:8px;
}

h1,h2,h3{
  margin:0;
}

.auth-copy,.hero-copy,.muted,.reports-meta,.viewer-meta,.progress-copy,.workspace-subtitle{
  color:var(--muted);
}

.auth-form,.page-stack{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.auth-form{
  margin-top:22px;
}

.field{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.field span{
  font-size:.92rem;
  font-weight:700;
}

.field input,.field select,.field textarea{
  width:100%;
  border:1px solid var(--line);
  background:var(--surface-alt);
  border-radius:14px;
  padding:12px 14px;
  color:var(--text);
}

.primary-button,.ghost-button,.drawer-primary-link,.drawer-secondary-link,.drawer-close,.report-link-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:14px;
  border:1px solid var(--line);
  padding:12px 16px;
  cursor:pointer;
  transition:transform .18s ease,box-shadow .18s ease,background .18s ease;
}

.primary-button,.drawer-primary-link{
  background:linear-gradient(135deg,var(--blue) 0%,#0d4aa5 100%);
  border-color:transparent;
  color:#fff;
  font-weight:700;
}

.ghost-button{
  background:var(--surface);
}

.primary-button:hover,.ghost-button:hover,.drawer-primary-link:hover,.drawer-secondary-link:hover,.drawer-close:hover,.menu-trigger:hover,.report-link-btn:hover{
  transform:translateY(-1px);
}

.alert{
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--line);
}

.alert.error{
  background:rgba(198,63,63,.08);
  border-color:rgba(198,63,63,.2);
  color:var(--red);
}

.alert.success{
  background:rgba(31,146,81,.08);
  border-color:rgba(31,146,81,.2);
  color:var(--green);
}

.workspace-shell{
  min-height:100vh;
  position:relative;
}

.workspace-topbar{
  position:sticky;
  top:0;
  z-index:20;
  display:flex;
  align-items:center;
  gap:16px;
  min-height:78px;
  padding:16px 24px;
  border-bottom:1px solid rgba(215,225,236,.9);
  backdrop-filter:blur(18px);
  background:rgba(255,255,255,.78);
}

.workspace-branding{
  display:flex;
  flex-direction:column;
  gap:3px;
  min-width:0;
}

.workspace-title{
  font-size:1.05rem;
  font-weight:800;
  letter-spacing:.03em;
}

.workspace-subtitle{
  font-size:.88rem;
}

.workspace-topbar-right{
  margin-left:auto;
  display:flex;
  align-items:center;
}

.topbar-pill{
  border-radius:999px;
}

.menu-trigger{
  display:inline-flex;
  align-items:center;
  gap:10px;
  min-height:50px;
  padding:0 18px;
  border:0;
  border-radius:999px;
  background:linear-gradient(135deg,var(--orange) 0%,var(--orange-deep) 100%);
  color:#fff;
  font-weight:800;
  box-shadow:0 14px 30px rgba(242,140,40,.32);
  cursor:pointer;
}

.menu-trigger-lines{
  position:relative;
  width:18px;
  height:12px;
  border-top:2px solid currentColor;
  border-bottom:2px solid currentColor;
}

.menu-trigger-lines::before{
  content:"";
  position:absolute;
  top:4px;
  left:0;
  right:0;
  border-top:2px solid currentColor;
}

.workspace-overlay{
  position:fixed;
  inset:0;
  background:rgba(12,24,42,.18);
  opacity:0;
  pointer-events:none;
  transition:opacity 180ms ease,backdrop-filter 180ms ease;
  z-index:29;
}

.workspace-overlay.open{
  opacity:1;
  pointer-events:auto;
  backdrop-filter:blur(10px);
}

.workspace-drawer{
  position:fixed;
  top:0;
  left:0;
  z-index:30;
  width:min(92vw,360px);
  height:100vh;
  padding:22px;
  overflow:auto;
  background:linear-gradient(180deg,#0f4ea9 0%,var(--blue-deep) 100%);
  color:#fff;
  box-shadow:0 28px 60px rgba(10,31,66,.32);
  transform:translateX(-105%);
  transition:transform 220ms ease;
}

.workspace-drawer.open{
  transform:translateX(0);
}

.drawer-head{
  display:flex;
  justify-content:flex-end;
}

.drawer-close{
  border:1px solid rgba(255,255,255,.16);
  background:rgba(255,255,255,.1);
  color:#fff;
  border-radius:999px;
  padding:10px 14px;
}

.drawer-profile{
  display:flex;
  gap:14px;
  align-items:center;
  margin-top:18px;
  padding:14px;
  border-radius:20px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.1);
}

.drawer-avatar{
  width:56px;
  height:56px;
  position:relative;
  display:grid;
  place-items:center;
  border-radius:50%;
  background:rgba(255,255,255,.12);
}

.drawer-avatar-head,.drawer-avatar-body{
  position:absolute;
  display:block;
  background:rgba(255,255,255,.92);
}

.drawer-avatar-head{
  top:12px;
  width:16px;
  height:16px;
  border-radius:50%;
}

.drawer-avatar-body{
  bottom:10px;
  width:28px;
  height:18px;
  border-radius:999px 999px 12px 12px;
}

.drawer-profile-name{
  font-weight:800;
}

.drawer-profile-meta,.drawer-label,.drawer-empty,.module-item-subtitle,.module-item-progress-meta{
  color:rgba(255,255,255,.78);
}

.drawer-actions,.drawer-section{
  margin-top:22px;
}

.drawer-primary-link,.drawer-secondary-link{
  width:100%;
  min-height:48px;
  font-weight:800;
}

.drawer-primary-link{
  background:linear-gradient(135deg,var(--orange) 0%,var(--orange-deep) 100%);
  color:#fff;
}

.drawer-secondary-link{
  margin-top:10px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(255,255,255,.08);
  color:#fff;
}

.drawer-label{
  font-size:.8rem;
  text-transform:uppercase;
  letter-spacing:.12em;
  margin-bottom:12px;
}

.drawer-list,.module-list,.stack-list{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.module-item{
  width:100%;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.08);
  color:#fff;
  border-radius:16px;
  padding:12px 14px;
  text-align:left;
  cursor:pointer;
  transition:transform .2s ease,background .2s ease;
}

.module-item:hover,.module-item.active{
  background:rgba(255,255,255,.16);
  transform:translateY(-1px);
}

.module-item-top{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  margin-bottom:6px;
}

.module-item-title{
  font-weight:700;
  font-size:.98rem;
}

.module-item-progress{
  margin-top:12px;
}

.module-item-progress-track{
  height:8px;
  border-radius:999px;
  background:rgba(255,255,255,.16);
  overflow:hidden;
}

.module-item-progress-fill{
  height:100%;
  border-radius:999px;
  background:#ffe08a;
}

.module-item-progress-fill.ok{
  background:#8bf0b4;
}

.module-item-progress-fill.warn{
  background:#ffe08a;
}

.module-item-progress-meta{
  margin-top:8px;
  display:flex;
  justify-content:space-between;
  gap:8px;
  font-size:.74rem;
}

.status-dot{
  min-width:28px;
  height:28px;
  border-radius:999px;
  display:grid;
  place-items:center;
  font-weight:800;
  font-size:.88rem;
  background:rgba(255,255,255,.12);
}

.status-dot.ok{color:#b7ffd4}
.status-dot.warn{color:#ffe08a}
.status-dot.bad{color:#ffb6b6}

.workspace-main{
  padding:24px;
}

.page-stack{
  gap:18px;
}

.hero-card{
  padding:22px;
  display:flex;
  justify-content:space-between;
  gap:18px;
  align-items:flex-start;
}

.dashboard-hero{
  background:
    radial-gradient(circle at top right,rgba(242,140,40,.12),transparent 26%),
    linear-gradient(180deg,#ffffff 0%,#f7fafc 100%);
}

.hero-copy-wrap{
  max-width:780px;
}

.hero-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:48px;
  padding:0 18px;
  border-radius:999px;
  background:rgba(20,91,198,.08);
  border:1px solid rgba(20,91,198,.12);
  color:var(--blue);
  font-weight:800;
}

.overview-card{
  padding:22px;
}

.overview-top{
  display:flex;
  justify-content:space-between;
  gap:18px;
  align-items:flex-start;
  margin-bottom:16px;
}

.progress-figure{
  font-size:2rem;
  font-weight:800;
  color:var(--blue-deep);
}

.progress-bar{
  height:14px;
  border-radius:999px;
  background:var(--surface-alt);
  border:1px solid var(--line);
  overflow:hidden;
}

.progress-bar.compact{
  height:10px;
}

.progress-fill{
  height:100%;
  border-radius:999px;
  background:linear-gradient(90deg,#f0c655 0%,#d39e00 100%);
  transition:width .25s ease;
}

.progress-fill.ok{
  background:linear-gradient(90deg,#24bd67 0%,#16874a 100%);
}

.progress-fill.warn{
  background:linear-gradient(90deg,#f0c655 0%,#d39e00 100%);
}

.progress-fill.bad{
  background:linear-gradient(90deg,#e46565 0%,#cf3d3d 100%);
}

.overview-metrics{
  margin-top:16px;
}

.hero-left{
  display:flex;
  gap:16px;
  align-items:center;
}

.avatar-circle{
  width:58px;
  height:58px;
  border-radius:18px;
  background:linear-gradient(180deg,#2f80ed,#1559c3);
  color:#fff;
  display:grid;
  place-items:center;
  font-size:1.3rem;
  font-weight:800;
}

.hero-right{
  display:flex;
  flex-direction:column;
  gap:12px;
  align-items:flex-end;
}

.status-chip{
  padding:10px 14px;
  border-radius:999px;
  font-weight:700;
  background:var(--surface-alt);
  border:1px solid var(--line);
}

.status-chip.ok{
  color:var(--green);
  background:#eefbf3;
  border-color:#cbeed7;
}

.status-chip.warn{
  color:#8a6700;
  background:#fff7df;
  border-color:#f2df9c;
}

.status-chip.bad{
  color:var(--red);
  background:#fff0f0;
  border-color:#f4c7c7;
}

.mini-metrics{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.metric-box{
  background:var(--surface-alt);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px 14px;
  min-width:108px;
}

.metric-label{
  display:block;
  color:var(--muted);
  font-size:.8rem;
  margin-bottom:6px;
}

.module-progress-card{
  width:min(360px,100%);
  padding:14px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--surface-alt);
}

.module-progress-head{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  margin-bottom:10px;
  font-weight:700;
}

.dashboard-grid,.reports-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(280px,1fr));
  gap:18px;
}

.card.wide,.report-viewer-card{
  grid-column:span 2;
}

.card-header{
  padding:16px 18px 10px;
  border-bottom:1px solid var(--line);
}

.card-body,.list-grid,.two-col-stat,.report-viewer-empty,.report-viewer-content{
  padding:18px;
}

.two-col-stat{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:14px;
}

.stat-panel{
  background:var(--surface-alt);
  border:1px solid var(--line);
  border-radius:14px;
  padding:14px;
}

.stat-panel-label{
  color:var(--muted);
  font-size:.82rem;
  margin-bottom:8px;
}

.stat-panel-value{
  font-size:1.05rem;
  font-weight:700;
}

.list-grid{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:12px;
}

.list-item,.stack-item,.file-item,.report-item{
  background:var(--surface-alt);
  border:1px solid var(--line);
  border-radius:14px;
  padding:14px;
}

.list-item-head,.stack-item-head,.file-item-head,.report-item-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:8px;
}

.list-item-title,.stack-item-title,.file-item-title,.report-item-title{
  font-weight:700;
}

.list-item p,.stack-item p,.file-item p,.report-item p,.card-body p{
  margin:0;
  color:var(--muted);
  line-height:1.5;
}

.badge{
  border-radius:999px;
  padding:5px 10px;
  font-size:.76rem;
  font-weight:700;
  border:1px solid var(--line);
  background:#fff;
}

.badge.ok{
  color:var(--green);
  background:#eefbf3;
  border-color:#cbeed7;
}

.badge.warn{
  color:#8a6700;
  background:#fff7df;
  border-color:#f2df9c;
}

.badge.bad{
  color:var(--red);
  background:#fff0f0;
  border-color:#f4c7c7;
}

.warning-zone{
  border-color:#f2df9c;
  background:linear-gradient(180deg,#fffef8 0%,#fffaf0 100%);
}

.section-heading{
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:flex-end;
  margin:10px 0 0;
}

.reports-card .stack-list{
  min-height:200px;
}

.report-link-btn{
  width:100%;
  text-align:left;
  justify-content:flex-start;
  background:#fff;
}

.report-link-btn.active{
  border-color:#a6c6f6;
  background:var(--surface-soft);
  box-shadow:inset 0 0 0 1px rgba(21,101,216,.08);
}

.report-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:12px;
}

.report-pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  background:#fff;
  border:1px solid var(--line);
  font-size:.78rem;
  font-weight:700;
  color:var(--muted);
}

.file-link,.inline-link-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color:var(--blue);
  font-weight:700;
}

.viewer-header{
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:flex-start;
}

.report-viewer-card{
  min-height:520px;
}

.report-viewer-empty{
  color:var(--muted);
}

.report-viewer-content{
  background:linear-gradient(180deg,#f9fbfe 0%,#f4f8fc 100%);
  font-family:"SFMono-Regular","Consolas","Liberation Mono",monospace;
  white-space:pre-wrap;
  line-height:1.6;
  overflow:auto;
  border-bottom-left-radius:var(--radius);
  border-bottom-right-radius:var(--radius);
  min-height:420px;
}

.loading-state{
  color:var(--muted);
}

.section-anchor{
  scroll-margin-top:110px;
}

.crm-overview-metrics{
  justify-content:flex-start;
  margin-bottom:14px;
}

.crm-card-body{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.compact-form{
  margin-top:0;
}

.customer-list{
  max-height:520px;
  overflow:auto;
}

.customer-item{
  width:100%;
  text-align:left;
  display:flex;
  flex-direction:column;
  gap:6px;
  padding:14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:var(--surface-alt);
  cursor:pointer;
  transition:transform .18s ease,background .18s ease,border-color .18s ease;
}

.customer-item:hover,.customer-item.active{
  transform:translateY(-1px);
  background:var(--surface-soft);
  border-color:#a6c6f6;
}

.customer-item-title{
  font-weight:700;
}

.customer-item-meta{
  color:var(--muted);
  font-size:.9rem;
}

.crm-detail-empty{
  color:var(--muted);
}

.crm-detail-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(280px,1fr));
  gap:18px;
}

.crm-detail-panel{
  display:flex;
  flex-direction:column;
  gap:14px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--surface-alt);
  padding:16px;
}

.crm-kv-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}

.crm-summary-row{
  justify-content:flex-start;
}

.compact-header{
  padding:0;
  border:0;
}

@media (max-width:1180px){
  .dashboard-grid,.reports-grid,.list-grid,.two-col-stat,.crm-detail-grid,.crm-kv-grid{
    grid-template-columns:1fr;
  }

  .card.wide,.report-viewer-card{
    grid-column:span 1;
  }

  .hero-card,.overview-top{
    flex-direction:column;
    align-items:stretch;
  }

  .hero-right{
    align-items:stretch;
  }
}

@media (max-width:720px){
  .workspace-topbar,.workspace-main{
    padding:16px;
  }

  .auth-shell{
    padding:16px;
  }

  .hero-left{
    align-items:flex-start;
  }

  .viewer-header{
    flex-direction:column;
  }

  .mini-metrics{
    justify-content:flex-start;
  }
}
