/* Shaafi Corporate Journey — application styles */
:root{
  --ink: #1c1f72;
  --ink-soft: #2b2f8d;
  --sand: #f4f7fb;
  --sand-deep: #e7edf6;
  --paper: #f8fbff;
  --gold: #2f88ea;
  --gold-soft: #8bc8ff;
  --coral: #f67f97;
  --coral-soft: #ffdbe3;
  --seaglass: #39c9a8;
  --charcoal: #1b2238;
  --line: #d6dff0;
  --white: #ffffff;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --radius: 12px;
  --surface-shadow: 0 10px 28px rgba(28, 31, 114, 0.08);
  --surface-shadow-soft: 0 4px 14px rgba(28, 31, 114, 0.06);
}
*{box-sizing:border-box;}
html{
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
}
body{
  margin:0;
  font-family: var(--font-body);
  background: var(--sand);
  color: var(--charcoal);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
::selection{ background: #cfe6ff; }

.shell{
  display:grid;
  grid-template-columns: clamp(180px, 18vw, 258px) minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
}
.sidebar{
  background:
    linear-gradient(170deg, rgba(57, 201, 168, 0.16) 0%, transparent 32%),
    linear-gradient(160deg, #15185f 0%, #1c1f72 65%, #242a85 100%);
  color: var(--paper);
  padding: 22px 18px 16px;
  display:flex;
  flex-direction:column;
  gap: 0;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.06);
}
.brand{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.2px;
  color: var(--paper);
  margin: 0 8px 2px;
}
.brand small{
  display:block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #9be6d2;
  margin-top: 4px;
}
.nav-group{
  margin-bottom: 2px;
}
.nav-group-label{
  font-size: 10.5px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #b4c4ff;
  margin: 10px 8px 4px;
  font-weight: 600;
}
.nav-group:first-child .nav-group-label{
  margin-top: 8px;
}
.nav-item{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: #e4eaff;
  font-size: 13.5px;
  line-height:1.25;
  transition: background .15s ease, color .15s ease;
  border: 1px solid transparent;
}
.nav-item:hover{
  background: rgba(255,255,255,0.11);
  color: var(--paper);
  border-color: rgba(255,255,255,0.18);
}
.nav-item.active{
  background: rgba(255,255,255,0.18);
  color: var(--paper);
  border-color: rgba(139,200,255,0.45);
}
.nav-num{
  font-family: var(--font-body);
  font-size: 13px;
  width: 22px; height: 22px;
  border-radius: 50%;
  display:flex; align-items:center; justify-content:center;
  background: rgba(255,255,255,0.16);
  color: #b8dbff;
  flex-shrink:0;
}
.nav-item.active .nav-num{
  background: linear-gradient(140deg, var(--seaglass), var(--gold));
  color: #ffffff;
  font-weight:700;
}

.main{
  padding: clamp(16px, 2vw, 24px) clamp(16px, 2.5vw, 30px) clamp(24px, 3vw, 40px);
  max-width: 100%;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.topbar{
  margin-bottom: 20px;
}

.page-container{
  min-height: calc(100vh - 120px);
  min-width: 0;
  width: 100%;
}

.page-section{
  margin-bottom: 20px;
}

.page-section-head{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.page-section-head h2{
  margin: 0;
  font-size: 18px;
}

.panel-header{
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.panel-heading{ max-width: 72%; }

.panel-actions-bar{ display:flex; gap: 10px; flex-wrap: wrap; }

.panel-toolbar{
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 10px;
}
.panel-toolbar-title{
  flex: 1 1 240px;
  min-width: 0;
}
.panel-toolbar-title h2{
  margin: 0 0 2px;
  font-size: 18px;
}
.panel-toolbar-title .hint{
  margin: 0;
}
.panel-toolbar-title--row{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.panel-toolbar-title--row h2{
  margin: 0;
}
.panel-toolbar-actions{
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
  margin-left: auto;
}
.panel-toolbar--actions-only .panel-toolbar-actions{
  margin-left: 0;
  width: 100%;
}
.panel-toolbar-search{
  flex: 1 1 180px;
  width: auto;
  min-width: min(220px, 100%);
  max-width: 280px;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  font-family: var(--font-body);
  font-size: 13px;
  background: var(--white);
}
.panel-toolbar-search:focus{
  outline: none;
  border-color: rgba(47, 136, 234, 0.55);
  box-shadow: 0 0 0 2px rgba(47, 136, 234, 0.12);
}
button.btn.btn-create,
.panel-toolbar-actions > .btn{
  white-space: nowrap;
  flex-shrink: 0;
  width: auto;
  min-width: max-content;
}

.nav-label{ display:inline-block; max-width: calc(100% - 42px); }

.rail-wrap{
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px 16px;
  margin-bottom: 28px;
  overflow-x: auto;
  box-shadow: var(--surface-shadow-soft);
}
.rail{
  display:flex;
  align-items:flex-start;
  min-width: min(920px, 100%);
}
.rail-step{
  flex:1;
  text-align:center;
  position:relative;
  font-size: 11.5px;
  color: #7d86a8;
  font-weight: 600;
}
.rail-dot{
  width: 13px; height:13px;
  border-radius:50%;
  background: #e2e8f7;
  border: 2px solid var(--line);
  margin: 0 auto 8px;
  position:relative;
  z-index:2;
}
.rail-step.done .rail-dot{ background: var(--seaglass); border-color: var(--seaglass); }
.rail-step.current .rail-dot{
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(139,200,255,0.35);
}
.rail-step::before{
  content:"";
  position:absolute;
  top:6px; left:-50%; width:100%; height:2px;
  background: var(--line);
  z-index:1;
}
.rail-step:first-child::before{ display:none; }
.rail-step.done::before, .rail-step.current::before{ background: var(--seaglass); }
.rail-label{ padding: 0 6px; color: var(--ink-soft); }
.rail-step.current .rail-label{ color: var(--gold); }

.page-eyebrow{
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 6px;
  display: none;
}
h1.page-title{
  font-family: var(--font-display);
  font-size: clamp(24px, 2.4vw, 30px);
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
}
.page-sub{
  color: #5c5646;
  font-size: clamp(13px, 1.2vw, 14.5px);
  max-width: min(640px, 100%);
  margin: 0 0 26px;
  line-height:1.55;
}

.panel{
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--surface-shadow-soft);
  max-width: 100%;
  overflow-x: auto;
}
.panel h2{
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0 0 4px;
  color: var(--ink);
}
.panel .hint{ font-size: 12.5px; color: #707a9c; margin: 0 0 16px; }

.grid-2{ display:grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3{ display:grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 900px){ .grid-2, .grid-3{ grid-template-columns: 1fr; } }

label{
  display:block;
  font-size: 12px;
  font-weight: 600;
  color: #3d4a7d;
  margin-bottom: 5px;
}
input, select, textarea{
  width:100%;
  padding: 9px 11px;
  border: 1px solid #cad7ee;
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 13.5px;
  background: #f9fbff;
  color: var(--charcoal);
}
input:focus, select:focus, textarea:focus{
  outline: 2px solid rgba(47, 136, 234, 0.35);
  outline-offset: 1px;
  background: var(--white);
  border-color: rgba(47, 136, 234, 0.55);
}
.field{ margin-bottom: 14px; }

button.btn{
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  background: linear-gradient(140deg, var(--ink-soft), var(--ink));
  color: var(--paper);
  transition: transform .1s ease, background .15s ease, box-shadow .15s ease;
  box-shadow: 0 8px 18px rgba(28, 31, 114, 0.22);
  white-space: nowrap;
}
button.btn:hover{
  background: linear-gradient(140deg, #2d3498, #1d2178);
  box-shadow: 0 10px 20px rgba(28, 31, 114, 0.27);
}
button.btn:active{ transform: scale(0.98); }
button.btn.secondary{
  background: transparent;
  color: var(--ink);
  border: 1.5px solid rgba(28, 31, 114, 0.32);
  box-shadow: none;
}
button.btn.secondary:hover{ background: #eef3ff; }
button.btn.gold{
  background: linear-gradient(140deg, #4da3f7, #2f88ea);
  color: #ffffff;
}
button.btn.gold:hover{
  background: linear-gradient(140deg, #3f98f0, #257bda);
  color: #ffffff;
}
button.btn.danger{
  background: linear-gradient(140deg, #f58fa4, #ee6f8d);
  color: #ffffff;
}
button.btn.danger:hover{ background: linear-gradient(140deg, #f27f97, #e96183); }
button.btn.link{ background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.btn:disabled{ opacity:0.45; cursor:not-allowed; }
button.btn-sm{
  font-size: 12px; padding: 6px 12px; border-radius: 6px;
  white-space: nowrap;
}
.table-actions{
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  max-width: 100%;
}
th.actions-col,
td.actions-cell{
  min-width: 220px;
  width: 1%;
  text-align: right;
  vertical-align: middle;
}
.table-scroll-wrap{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -2px;
  padding-bottom: 2px;
}
.table-scroll-wrap table{
  min-width: min(980px, 100%);
}
@media (max-width: 768px){
  td.actions-cell .table-actions{
    flex-direction: column;
    align-items: stretch;
  }
  td.actions-cell .table-actions .btn-sm{
    width: 100%;
    text-align: center;
  }
}
table{
  width:100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
th{
  text-align:left;
  font-size: 10.5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #7a83a4;
  padding: 8px 10px;
  border-bottom: 1.5px solid var(--line);
  background: #f8faff;
}
td{
  padding: 10px 10px;
  border-bottom: 1px solid #e3eaf8;
  color: var(--charcoal);
  vertical-align: middle;
}
tr:nth-child(even) td{ background: #fbfdff; }
tr:last-child td{ border-bottom:none; }
.empty-row td{ color:#a39c86; font-style: italic; text-align:center; padding: 22px; }

.badge{
  display:inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 100px;
  letter-spacing: 0.3px;
}
.badge.pending{ background:#F3E3C7; color:#8a5b0c; }
.badge.referred{ background:#d9ecff; color:#1e6ec2; }
.badge.completed{ background:#daf4ed; color:#1b8a73; }
.badge.settled{ background:#e8f4ff; color:#2e67ac; }
.badge.unsettled{ background:#ffe3ea; color:#b74a64; }
.badge.audit-badge.audit-create{ background:#daf4ed; color:#1b8a73; }
.badge.audit-badge.audit-edit{ background:#e8f4ff; color:#2e67ac; }
.badge.audit-badge.audit-delete{ background:#ffe3ea; color:#b74a64; }
.badge.audit-badge.audit-other{ background:#f3e3c7; color:#8a5b0c; }
.page-subtitle{
  margin: -8px 0 16px;
  color: #5f6880;
  font-size: 14px;
}
.audit-log-panel{
  padding-top: 14px;
}
.audit-panel-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0 2px;
}
.audit-panel-head h2{
  margin: 0;
  font-size: 17px;
}
.audit-count{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  margin-left: 6px;
  border-radius: 999px;
  background: #e8f0fb;
  color: #2e67ac;
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}
.audit-filter-bar{
  display: grid;
  grid-template-columns:
    minmax(180px, 1.4fr)
    minmax(140px, 1fr)
    minmax(130px, 0.9fr)
    minmax(120px, 0.8fr)
    auto;
  gap: 8px 10px;
  align-items: end;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.audit-filter-bar .field{
  margin-bottom: 0;
  min-width: 0;
}
.audit-filter-bar label{
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #6b7288;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.audit-filter-bar input,
.audit-filter-bar select{
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  font-size: 13px;
}
.audit-filter-search input{
  padding-left: 32px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='16.65' y1='16.65' x2='21' y2='21'/%3E%3C/svg%3E") no-repeat 10px center;
}
.audit-filter-actions{
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding-bottom: 1px;
}
.audit-filter-actions .btn{
  min-height: 36px;
  padding: 0 14px;
  white-space: nowrap;
}
.audit-log-scroll{
  max-height: calc(100vh - 280px);
  min-height: 320px;
}
.audit-log-table td.audit-time{
  white-space: nowrap;
  font-size: 13px;
}
.audit-user-cell{
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.audit-detail-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
}
.audit-detail-grid .hint{
  display: block;
  margin-bottom: 4px;
}
.audit-detail-pre{
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  overflow: auto;
  max-height: 320px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
@media (max-width: 1100px){
  .audit-filter-bar{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .audit-filter-search{
    grid-column: 1 / -1;
  }
  .audit-filter-actions{
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
@media (max-width: 640px){
  .audit-filter-bar{
    grid-template-columns: 1fr;
  }
  .audit-filter-search,
  .audit-filter-actions{
    grid-column: auto;
  }
  .audit-detail-grid{
    grid-template-columns: 1fr;
  }
  .audit-log-scroll{
    max-height: none;
  }
}

.kpi-row{ display:grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 900px){ .kpi-row{ grid-template-columns: 1fr 1fr; } }
.kpi{
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi .num{
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--ink);
  font-weight: 600;
}
.kpi .lbl{ font-size: 11.5px; color: #8c8570; margin-top: 3px; }

.split-bar{
  display:flex; height: 30px; border-radius: 7px; overflow:hidden; margin: 10px 0 8px;
  border: 1px solid var(--line);
}
.split-bar div{ display:flex; align-items:center; justify-content:center; font-size:11.5px; font-weight:700; color:white; }
.split-legend{ display:flex; gap:18px; font-size:12px; color:var(--ink-soft); flex-wrap:wrap; }
.split-legend span{ display:inline-flex; align-items:center; gap:6px; }
.swatch{ width:10px; height:10px; border-radius:3px; display:inline-block; }

.flow-diagram{
  display:flex; flex-wrap:wrap; gap: 10px; align-items:center;
}
.flow-node{
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.flow-arrow{ color: var(--coral); font-size: 16px; }

.callout{
  background: var(--sand-deep);
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.kpi-row{ display:grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
@media (max-width: 900px){ .kpi-row{ grid-template-columns: 1fr 1fr; } }
.kpi{
  display:grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items:center;
  gap: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--surface-shadow-soft);
}
.kpi.primary{ border-color: rgba(47, 136, 234, 0.22); background: rgba(47, 136, 234, 0.08); }
.kpi.secondary{ border-color: rgba(57, 201, 168, 0.22); background: rgba(57, 201, 168, 0.09); }
.kpi.tertiary{ border-color: rgba(246, 127, 151, 0.28); background: rgba(246, 127, 151, 0.09); }
.kpi.quaternary{ border-color: rgba(28, 31, 114, 0.2); background: rgba(28, 31, 114, 0.08); }
.kpi-icon{
  width: 38px; height: 38px;
  display:flex; align-items:center; justify-content:center;
  border-radius: 12px;
  background: rgba(255,255,255,0.85);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(18, 54, 50, 0.06);
}
.kpi .num{
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--ink);
  font-weight: 700;
}
.kpi .lbl{ font-size: 12px; color: #5c5b55; margin-top: 2px; }

.kpi-row-compact{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.kpi-compact{
  padding: 10px 12px;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.kpi-compact .kpi-icon{
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 15px;
}
.kpi-compact .num{
  font-size: 20px;
  line-height: 1.15;
}
.kpi-compact .lbl{
  font-size: 11px;
  margin-top: 1px;
  line-height: 1.25;
}
@media (max-width: 900px){
  .kpi-row-compact{ grid-template-columns: 1fr; }
}

.financial-split-panel h2{
  margin-bottom: 4px;
  font-size: 17px;
}
.financial-split-panel .hint{
  margin-bottom: 8px;
  font-size: 12px;
}
.financial-split-panel .split-bar{
  margin: 6px 0 4px;
  height: 24px;
}

.financial-table-panel h2{
  margin-bottom: 10px;
  font-size: 17px;
}
.financial-filter-row{
  display: grid;
  grid-template-columns:
    minmax(170px, 1.1fr)
    minmax(150px, 1.2fr)
    minmax(130px, 1fr)
    minmax(130px, 1fr)
    minmax(130px, 1fr)
    auto;
  gap: 10px 12px;
  align-items: end;
  margin-bottom: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.financial-filter-row .field{
  margin-bottom: 0;
  min-width: 0;
}
.financial-filter-row label{
  font-size: 11px;
  font-weight: 600;
  color: #6b7288;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.financial-filter-row input,
.financial-filter-row select{
  width: 100%;
  min-width: 0;
}
.financial-filter-actions{
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: flex-end;
}
.financial-filter-actions .btn{
  white-space: nowrap;
  flex-shrink: 0;
}
.financial-table-panel table th:nth-child(5),
.financial-table-panel table th:nth-child(6),
.financial-table-panel table th:nth-child(7),
.financial-table-panel table th:nth-child(8),
.financial-table-panel table th:nth-child(9),
.financial-table-panel table td.num-cell{
  text-align: right;
}
.financial-table-panel table td.num-cell{
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.financial-table-scroll{
  width: 100%;
}
.financial-table-scroll .financial-table{
  width: 100%;
  min-width: 960px;
  table-layout: auto;
}
.financial-table-panel .financial-table th,
.financial-table-panel .financial-table td{
  padding: 10px 8px;
}
.financial-table-panel .financial-table th:nth-child(2),
.financial-table-panel .financial-table td:nth-child(2),
.financial-table-panel .financial-table th:nth-child(3),
.financial-table-panel .financial-table td:nth-child(3),
.financial-table-panel .financial-table th:nth-child(4),
.financial-table-panel .financial-table td:nth-child(4){
  min-width: 0;
}
.financial-end-col,
.financial-end-cell{
  width: 1%;
  white-space: nowrap;
  text-align: right;
  vertical-align: middle;
}
.financial-end-wrap{
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
  max-width: 100%;
}
.financial-table-actions{
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}
.financial-table-actions .btn-sm{
  flex-shrink: 0;
}
@media (max-width: 768px){
  .financial-table-scroll .financial-table{
    min-width: 880px;
  }
  .financial-end-wrap{
    gap: 6px;
  }
  .financial-table-actions{
    flex-direction: row;
  }
}
@media (max-width: 1100px){
  .financial-filter-row{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .financial-filter-actions{
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
@media (max-width: 700px){
  .financial-filter-row{
    grid-template-columns: 1fr 1fr;
  }
}

.pipeline-row{
  display:grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 14px;
  margin-top: 18px;
}
@media (max-width: 900px){ .pipeline-row{ grid-template-columns: 1fr; } }
.pipeline-card{
  background: #f7faff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--surface-shadow-soft);
}
.pipeline-card strong{
  font-family: var(--font-display);
  font-size: 24px;
  display:block;
  color: var(--ink);
}
.pipeline-card span{
  font-size: 13px;
  color: var(--ink-soft);
}

.overview-grid{
  display:grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 16px;
}
@media (max-width: 1000px){
  .overview-grid{ grid-template-columns: 1fr; }
}
.workflow-steps{
  display:flex;
  justify-content: space-between;
  gap: 6px;
  margin: 8px 0 14px;
  flex-wrap: nowrap;
}
.workflow-step{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 6px;
  min-width: 76px;
  position: relative;
  flex: 1;
}
.workflow-step:not(:last-child)::after{
  content: "";
  position: absolute;
  top: 20px;
  right: -24%;
  width: 48%;
  border-top: 2px dashed #d9ccac;
}
.workflow-step span{
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #61719d;
  font-weight: 700;
}
.workflow-icon{
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #d7c7a1;
  background: #f8fbff;
  display:flex;
  align-items:center;
  justify-content:center;
  color: #7f7f7f;
  font-weight: 700;
}
.workflow-step.done .workflow-icon{
  border-color: #6aa89d;
  color: #2f7d70;
  background: #ecf7f3;
}
.workflow-step.active .workflow-icon{
  border-color: #c08a2e;
  color: #b57916;
  background: #fff8eb;
}
.workflow-step.done span{
  color: #3f8a7a;
}
.workflow-step.active span{
  color: #b57916;
}
.workflow-step.active:not(:last-child)::after,
.workflow-step.done:not(:last-child)::after{
  border-top-color: #cbb88f;
}
.workflow-header{
  display:flex;
  align-items:center;
  gap: 8px;
}
.workflow-header h2{ margin: 0; }
.workflow-accent{
  color: var(--coral);
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
}
.workflow-pipeline-box{
  margin-top: 10px;
  background: #f5f2eb;
  border: 1px solid #e5dbc6;
  border-radius: 12px;
  padding: 12px 14px;
}
.pipeline-stats{
  display:flex;
  justify-content: space-between;
  gap: 10px;
  color: #5e6790;
  font-size: 12px;
  font-weight: 600;
}
.workflow-bar{
  margin-top: 8px;
  display:flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #d8cbb1;
  background: #f6f1e5;
}
.workflow-bar div{ height: 100%; }
.action-panel .action-item{
  border: 1px solid #d6dff0;
  background: #f9fbff;
  border-left: 3px solid var(--coral);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.action-panel .action-item strong{
  display:block;
  font-size: 14px;
  color: var(--ink);
}
.action-panel .action-item span{
  display:block;
  margin-top: 2px;
  color: #6e78a0;
  font-size: 12px;
}

.role-card-row{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 980px){
  .role-card-row{ grid-template-columns: 1fr; }
}
.role-card{
  margin-bottom: 0;
  padding: 16px 18px;
}
.permission-user-card{
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: var(--white);
}
.permission-user-card.active{
  border-color: rgba(47, 136, 234, 0.5);
  box-shadow: 0 0 0 2px rgba(47, 136, 234, 0.12), var(--surface-shadow-soft);
}

#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#modal-overlay.open { display: flex; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 80, 0.45);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  width: min(94vw, 720px);
  max-height: min(92vh, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  background: #fbfdff;
  border-radius: 16px;
  box-shadow: 0 20px 44px rgba(28, 31, 114, 0.22);
  border: 1px solid #d8e2f4;
  padding: clamp(20px, 2.5vw, 28px) clamp(22px, 3vw, 32px);
  transform: translateY(16px);
  opacity: 0;
  animation: modalIn .2s forwards cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-card.modal-lg{
  width: min(96vw, 860px);
}
.modal-card.modal-xl{
  width: min(96vw, 960px);
}
.modal-card.modal-compact{
  width: min(92vw, 520px);
}
.permissions-modal{
  width: 100%;
}
.permissions-modal .permission-matrix-scroll{
  max-height: 52vh;
  overflow: auto;
  border: 1px solid #dbe4f5;
  border-radius: 10px;
  background: #ffffff;
}
.permissions-modal .permission-matrix-scroll table{
  margin: 0;
}
.permissions-modal .permission-matrix-scroll th{
  position: sticky;
  top: 0;
  z-index: 1;
}
.permission-section-row td{
  background: #eef3fb;
  color: #3a4f7a;
  font-size: 12px;
  letter-spacing: 0.4px;
  padding-top: 12px;
  padding-bottom: 6px;
}
@keyframes modalIn {
  to { transform: translateY(0); opacity: 1; }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0;
  color: var(--ink);
}
.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #8590b4;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.modal-close:hover { color: var(--ink); }
.modal-body { width: 100%; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
.modal-body .grid-2{
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.modal-body .grid-3{
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.modal-body .field{
  min-width: 0;
}
.modal-body .field input,
.modal-body .field select,
.modal-body .field textarea{
  width: 100%;
  max-width: 100%;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-shrink: 0; gap: 12px; }
.modal-title { flex: 1; min-width: 0; }
.modal-body table{
  width: 100%;
  min-width: 0;
}
.modal-body .table-scroll-wrap,
.modal-body .permission-matrix-scroll{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 640px){
  .modal-body .grid-2,
  .modal-body .grid-3{
    grid-template-columns: 1fr;
  }
  .modal-body .enr-dependent-row .grid-3{
    grid-template-columns: 1fr !important;
  }
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; flex-shrink: 0; }
.doc-preview-frame {
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.doc-preview-image {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  margin: 0 auto;
  border-radius: 8px;
}
.doc-preview-hint {
  margin-top: 10px;
}
.doc-panel {
  padding: 10px 14px;
  background: #f9fbff;
  border: 1px solid #e3eaf8;
  border-radius: 8px;
}
.doc-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.doc-actions-name {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.doc-list .doc-actions-row + .doc-actions-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e3eaf8;
}
.doc-actions {
  margin-top: 0;
}

.service-details-modal{
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.service-details-summary{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.service-details-kpi{
  padding: 10px 12px;
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 0;
}
.service-details-kpi .hint{
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  color: #6b7288;
}
.service-details-kpi strong{
  display: block;
  font-size: 16px;
  color: var(--ink);
}
.service-details-meta,
.service-details-docs{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}
.service-details-modal .field-compact{
  margin-bottom: 0;
  min-width: 0;
}
.service-details-modal .field-compact label{
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  color: #6b7288;
}
.service-details-modal .field-compact input,
.service-details-modal .field-compact textarea{
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  font-size: 13px;
}
.service-details-modal .field-compact textarea{
  min-height: 54px;
  max-height: 96px;
  resize: vertical;
}
.doc-panel-compact{
  padding: 8px 10px;
  min-height: 42px;
}
.service-details-modal .doc-actions-row{
  gap: 8px;
  align-items: center;
}
.service-details-modal .doc-actions-name{
  font-size: 12px;
}
.service-details-modal .doc-actions{
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.service-details-modal .doc-actions .btn-sm{
  padding: 5px 10px;
  font-size: 11px;
  min-width: 64px;
}
.service-details-table-wrap{
  margin-top: 2px;
}
.service-details-table{
  min-width: 0 !important;
}
.service-details-table th,
.service-details-table td{
  padding: 10px 12px;
  font-size: 13px;
}
.service-details-table th:last-child,
.service-details-table td:last-child{
  text-align: right;
  white-space: nowrap;
}
@media (max-width: 900px){
  .service-details-summary{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px){
  .service-details-summary,
  .service-details-meta,
  .service-details-docs{
    grid-template-columns: 1fr;
  }
  .service-details-modal .doc-actions-row{
    flex-direction: column;
    align-items: stretch;
  }
  .service-details-modal .doc-actions{
    justify-content: stretch;
    width: 100%;
  }
  .service-details-modal .doc-actions .btn-sm{
    flex: 1 1 auto;
    min-width: 0;
  }
}

.search-select{
  position: relative;
}
.search-select-control{
  position: relative;
  display: flex;
  align-items: center;
}
.search-select-input{
  width: 100%;
  padding-right: 34px;
}
.search-select-chevron{
  position: absolute;
  right: 12px;
  color: #8c8570;
  font-size: 12px;
  pointer-events: none;
}
.search-select.open .search-select-chevron{
  transform: rotate(180deg);
}
.search-select-dropdown{
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  max-height: min(280px, 40vh);
  overflow: auto;
  background: #fff;
  border: 1px solid #d8e2f4;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(28, 31, 114, 0.14);
}
.search-select.open .search-select-dropdown{
  display: block;
}
.search-select-option{
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid #eef2f9;
}
.search-select-option:last-child{
  border-bottom: none;
}
.search-select-option:hover,
.search-select-option.active{
  background: #eef5ff;
}
.search-select-option-label{
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
}
.search-select-option-meta{
  font-size: 12px;
  color: #8c8570;
}
.search-select-empty{
  padding: 12px;
  font-size: 13px;
  color: #8c8570;
}
.search-select-hint{
  margin-top: 6px;
  margin-bottom: 0;
}

.two-col{ display:grid; grid-template-columns: 1.1fr 0.9fr; gap: 20px; }
@media (max-width: 980px){ .two-col{ grid-template-columns: 1fr; } }

.tag-id{ font-family: var(--font-mono); font-size: 11.5px; color: #8c8570; }

.login-shell{
  min-height: 100vh;
  display:flex; align-items:center; justify-content:center;
  padding: 24px;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(57,201,168,0.18), transparent),
    radial-gradient(600px 400px at 90% 90%, rgba(47,136,234,0.16), transparent),
    radial-gradient(500px 300px at 70% 20%, rgba(246,127,151,0.14), transparent),
    var(--sand);
}
.login-card{
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px 42px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 52px rgba(28, 31, 114, 0.16);
}
.login-brand{
  font-family: var(--font-display);
  font-size: 26px; font-weight:600; color: var(--ink); margin:0 0 4px;
}
.login-sub{ font-size: 13.5px; color:#7380a8; margin: 0 0 26px; line-height:1.5;}
.login-error{
  background: var(--coral-soft); color: #7a2e17; border-radius: 8px;
  padding: 10px 14px; font-size: 13px; margin-bottom: 16px; font-weight: 600;
}

.session-bar{
  display:flex; align-items:center; justify-content:space-between;
  background: linear-gradient(130deg, #1a1f70, #28308e);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 12.5px;
  box-shadow: var(--surface-shadow-soft);
}
.session-bar .who strong{ color: #93d8ff; }
.session-bar .role-chip{
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  background: rgba(255,255,255,0.1);
  padding: 3px 9px;
  border-radius: 100px;
  margin-left: 8px;
}
.switch-btn{
  background: rgba(255,255,255,0.1);
  color: var(--paper);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight:600;
  cursor:pointer;
}
.switch-btn:hover{ background: rgba(255,255,255,0.18); }

.toast{
  position: fixed; bottom: 22px; right: 22px;
  background: linear-gradient(140deg, #1d2178, #2c3595); color: var(--paper);
  padding: 12px 18px; border-radius: 8px;
  font-size: 13px; font-weight:600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  transform: translateY(20px); opacity:0;
  transition: all .25s ease;
  z-index: 50;
  pointer-events:none;
  max-width: 360px;
}
.toast.show{ transform: translateY(0); opacity:1; }
.toast.error{ background: var(--coral); }

.credential-box{
  background: var(--sand-deep);
  border: 1px dashed var(--gold);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  margin-top: 10px;
  line-height: 1.7;
}
.loading-row{ padding: 40px; text-align:center; color:#8c8570; font-size:13.5px; }

/* Responsive layout — supports browser zoom and smaller viewports */
.grid-2,
.grid-3,
.overview-grid,
.kpi-row,
.role-card-row{
  min-width: 0;
}

img,
video,
canvas,
svg{
  max-width: 100%;
  height: auto;
}

@media (max-width: 1100px){
  .shell{
    grid-template-columns: minmax(160px, 200px) minmax(0, 1fr);
  }
  .nav-label{
    font-size: 12.5px;
  }
  th.actions-col,
  td.actions-cell{
    min-width: 180px;
  }
}

@media (max-width: 900px){
  .shell{
    grid-template-columns: 1fr;
  }
  .sidebar{
    position: sticky;
    top: 0;
    z-index: 30;
    max-height: 42vh;
    overflow-y: auto;
    padding: 14px 12px 10px;
  }
  .brand{
    font-size: clamp(18px, 4vw, 22px);
  }
  .main{
    padding: 16px;
  }
  .session-bar{
    flex-wrap: wrap;
    gap: 8px;
  }
  .workflow-steps{
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 10px;
  }
  .workflow-step{
    min-width: 64px;
    flex: 0 1 auto;
  }
  .workflow-step:not(:last-child)::after{
    display: none;
  }
  .panel-heading{
    max-width: 100%;
  }
  .panel-toolbar{
    flex-direction: column;
    align-items: stretch;
  }
  .panel-toolbar-actions{
    flex-wrap: wrap;
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
  .panel-toolbar-search{
    flex: 1 1 100%;
    max-width: none;
    width: 100%;
  }
  .panel-toolbar-title--row{
    flex-direction: column;
    align-items: stretch;
  }
  .modal-card{
    width: min(100%, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    padding: 18px 16px;
  }
  .modal-card.modal-lg,
  .modal-card.modal-xl{
    width: min(100%, calc(100vw - 20px));
  }
  .modal-body .grid-2,
  .modal-body .grid-3{
    grid-template-columns: 1fr;
  }
  #modal-overlay{
    padding: 12px;
  }
}

@media (max-width: 600px){
  .kpi-row{
    grid-template-columns: 1fr;
  }
  .table-scroll-wrap table{
    min-width: 720px;
  }
  td.actions-cell .table-actions{
    flex-direction: column;
    align-items: stretch;
  }
  td.actions-cell .table-actions .btn-sm{
    width: 100%;
    text-align: center;
  }
  .toast{
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}
