/* ==========================================================================
   eTariff Management Portal - application stylesheet
   Extends the supplied dashboard design system to the full application.
   Tokens, topbar, sidebar, cards, tables and status pills are inherited from
   base.css unchanged; everything below is additive.
   ========================================================================== */

/* --------------------------------------------------------------- layout --- */
.main-content { padding-bottom: 56px; }
.main-content.wide { min-width: 1180px; }
.page-heading { flex-wrap: wrap; gap: 14px; }
.page-heading > div:first-child { min-width: 0; }
.page-heading .crumbs { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #7285a0; margin-bottom: 7px; }
.page-heading .crumbs a, .crumbs a { color: #4d698d; font-weight: 600; }
.crumbs .sep { color: #b3c1d4; }
.page-heading h1 .muted-suffix { font-weight: 500; color: #6a7c95; font-size: 15px; margin-left: 8px; letter-spacing: 0; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.grid-side { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 16px; align-items: start; }
.grid-side-left { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 16px; align-items: start; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 8px } .mt-2 { margin-top: 14px } .mt-3 { margin-top: 22px }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: 8px } .mb-2 { margin-bottom: 14px }
.hide { display: none !important; }

/* ----------------------------------------------------------- typography --- */
.muted { color: #64768f; }
.small { font-size: 11px; }
.tiny { font-size: 10px; }
.mono { font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace; font-size: 11px; }
.strong { font-weight: 600; color: #24395a; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-text { color: #d1213a; }
.warn-text { color: #c07c05; }
.ok-text { color: #12854e; }
h2.section-title { font-size: 15px; margin: 0 0 10px; color: #10294d; font-weight: 700; display: flex; align-items: center; gap: 8px; }
h3.sub-title { font-size: 13px; margin: 0 0 8px; color: #2b4468; font-weight: 700; }

/* --------------------------------------------------------------- cards --- */
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 12px 14px; }
.card + .card { margin-top: 14px; }
.card-header .header-tools { display: flex; align-items: center; gap: 8px; }
.count-pill { background:#eef3fa; color:#4a6b90; border-radius:10px; padding:1px 7px; font-size:11px; font-weight:600; }
.card-footer { padding: 11px 18px; border-top: 1px solid #e9eef4; display: flex; align-items: center; gap: 10px; }

.panel { background: #fff; border: 1px solid #dbe3ed; border-radius: 8px; box-shadow: var(--shadow); }
.panel-pad { padding: 16px 18px; }

/* --------------------------------------------------------------- forms --- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; min-width: 0; }
.field > label { font-size: 11.5px; font-weight: 600; color: #43587a; display: flex; align-items: center; gap: 6px; }
.field > label .req { color: #d1213a; }
.field .hint { font-size: 10.5px; color: #74849d; line-height: 1.45; }
.field .err { font-size: 10.5px; color: #d1213a; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number],
input[type=search], select, textarea {
  height: 36px; border: 1px solid #ccd7e5; border-radius: 6px; padding: 0 10px;
  background: #fff; color: #16304f; font-size: 13px; width: 100%; outline: none;
}
textarea { height: auto; min-height: 84px; padding: 9px 10px; line-height: 1.5; resize: vertical; }
select { padding-right: 26px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2354688a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 14px; }
input:focus, select:focus, textarea:focus { border-color: #4a9bf5; box-shadow: 0 0 0 3px rgba(19,117,235,.12); }
input:disabled, select:disabled, textarea:disabled { background: #f4f7fa; color: #7b8ba3; }
.checkline { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: #35496b; margin-bottom: 9px; }
.checkline input { width: 15px; height: 15px; margin-top: 1px; accent-color: #1375eb; flex: 0 0 auto; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 14px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 0 14px; }
.field-row-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 0 12px; }
fieldset { border: 1px solid #e2e9f1; border-radius: 7px; padding: 14px 16px 2px; margin: 0 0 16px; }
legend { font-size: 11.5px; font-weight: 700; color: #33507a; padding: 0 6px; text-transform: uppercase; letter-spacing: .4px; }

.btn:hover { background: #f6f9fd; }
.btn-primary:hover { background: linear-gradient(180deg,#1a80f4,#1170e4); }
.btn:disabled, .btn[aria-disabled=true] { opacity: .5; pointer-events: none; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 5px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-xs { height: 25px; padding: 0 8px; font-size: 11px; border-radius: 5px; }
.btn-xs .icon { width: 13px; height: 13px; }
.btn-danger { background: #fff; border-color: #eebfc6; color: #c2172f; }
.btn-danger:hover { background: #fff5f6; }
.btn-ghost { border-color: transparent; background: transparent; color: #4a688f; }
.btn-ghost:hover { background: #eef3fa; }
.btn-block { width: 100%; }

/* -------------------------------------------------------------- tables --- */
.table-plain { width: 100%; border-collapse: collapse; table-layout: auto; }
.table-plain th { background: #f8fafc; font-size: 11px; font-weight: 600; color: #53647d;
  text-align: left; padding: 9px 12px; border-bottom: 1px solid #e3e9f1; white-space: nowrap; }
.table-plain td { font-size: 12px; padding: 9px 12px; border-bottom: 1px solid #eef2f7; color: #2d4463; vertical-align: middle; }
.table-plain tbody tr:hover { background: #fafcfe; }
.table-plain tbody tr.selected { background: #f0f7ff; }
.table-plain td.num, .table-plain th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-plain td.tight, .table-plain th.tight { width: 1%; white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 100%; }
.table-sticky thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 #e3e9f1; }
.table-plain a { font-weight: 600; }
.check-col { width: 34px; }
.check-col input { width: 15px; height: 15px; accent-color: #1375eb; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: #1375eb; }

.empty-state { padding: 44px 20px; text-align: center; color: #6d7f99; }
.empty-state .icon { width: 34px; height: 34px; margin: 0 auto 12px; color: #a9bad1; }
.empty-state h3 { margin: 0 0 6px; font-size: 14px; color: #37507a; }
.empty-state p { margin: 0 auto; max-width: 460px; font-size: 12px; line-height: 1.6; }
.empty-state .btn { margin-top: 16px; }

.pager { display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-top: 1px solid #e9eef4; font-size: 11.5px; color: #61738d; }

/* ------------------------------------------------------------- statuses --- */
.status.rejected { background: #fdecee; color: #c92038; } .status.rejected i { background: #d4283f; }
.status.neutral  { background: #eff2f6; color: #687893; } .status.neutral i { background: #7a8aa0; }
.status.info     { background: #eaf3ff; color: #1274e8; } .status.info i { background: #1274e8; }
.status.purple   { background: #f3ecff; color: #6a2fde; } .status.purple i { background: #6a2fde; }
.status.sm { height: 19px; font-size: 10px; padding: 0 7px; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px;
  border-radius: 11px; font-size: 10.5px; font-weight: 600; background: #eef2f7; color: #58698a; }
.pill.blue { background: #eaf3ff; color: #1268d6; }
.pill.green { background: #e8f7ef; color: #12854e; }
.pill.amber { background: #fff4e0; color: #b57806; }
.pill.red { background: #fdecee; color: #c92038; }
.pill.purple { background: #f3ecff; color: #6a2fde; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px;
  border: 1px solid #d7e2ee; background: #fff; font-size: 11.5px; color: #40587c; font-weight: 600; }
.chip.active { background: #eaf3ff; border-color: #b6d5f7; color: #0e63cc; }
.chip .icon { width: 13px; height: 13px; }

/* -------------------------------------------------------------- alerts --- */
.alert { display: flex; gap: 11px; padding: 12px 15px; border-radius: 7px; font-size: 12px;
  line-height: 1.6; border: 1px solid; margin-bottom: 14px; align-items: flex-start; }
.alert .icon { width: 19px; height: 19px; flex: 0 0 auto; margin-top: 1px; }
.alert strong { display: block; margin-bottom: 3px; font-size: 12.5px; }
.alert.info    { background: #f1f7ff; border-color: #cfe2fa; color: #1c4f8f; }
.alert.success { background: #ecf9f2; border-color: #c4e9d5; color: #14684a; }
.alert.warning { background: #fff8ec; border-color: #f3ddb4; color: #8a6209; }
.alert.danger  { background: #fdf1f3; border-color: #f4ccd3; color: #9d1c2f; }
.alert.critical { background: #fdf1f3; border: 2px solid #e0344c; color: #8e1425; }
.alert a { text-decoration: underline; }
.alert-actions { margin-top: 9px; display: flex; gap: 8px; }

.flash-stack { position: fixed; top: 76px; right: 22px; z-index: 60; width: 380px; display: flex; flex-direction: column; gap: 8px; }
.flash-stack .alert { box-shadow: 0 6px 22px rgba(16,40,74,.14); margin: 0; background-color: #fff; }

/* ---------------------------------------------------------------- tabs --- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid #dde5ee; margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; font-size: 12.5px; font-weight: 600; color: #5d7191;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: #1375eb; }
.tabs a.active { color: #0d5fc4; border-bottom-color: #1375eb; }
.tabs a .count { background: #eef2f7; border-radius: 9px; padding: 1px 6px; font-size: 10px; margin-left: 6px; color: #5d7191; }
.tabs a.active .count { background: #e3efff; color: #0d5fc4; }

/* ------------------------------------------------------------ key/value --- */
.kv { display: grid; grid-template-columns: 168px minmax(0,1fr); gap: 7px 14px; font-size: 12px; }
.kv dt { color: #64768f; font-weight: 500; }
.kv dd { margin: 0; color: #22385a; font-weight: 600; word-break: break-word; }
.kv.compact { grid-template-columns: 128px minmax(0,1fr); font-size: 11.5px; gap: 6px 12px; }

.metric-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)); gap: 10px; }
.metric { background: #f8fafd; border: 1px solid #e4ebf3; border-radius: 7px; padding: 12px 13px; }
.metric span { display: block; font-size: 10.5px; color: #64768f; margin-bottom: 5px; }
.metric strong { font-size: 20px; color: #10294d; letter-spacing: -.3px; display: block; }
.metric .delta { font-size: 10px; margin-top: 3px; }

/* ------------------------------------------------------------ tariff tree */
.tree-full { padding: 8px 6px; font-size: 12px; color: #2c425e; max-height: 620px; overflow: auto; }
.tree-node { display: flex; align-items: center; gap: 6px; height: 27px; padding: 0 8px; border-radius: 5px; white-space: nowrap; }
.tree-node:hover { background: #f2f7fd; }
.tree-node.current { background: #e8f2ff; font-weight: 600; }
.tree-node .toggle { width: 16px; height: 16px; color: #536c88; flex: 0 0 auto; cursor: pointer; }
.tree-node .toggle.empty { visibility: hidden; }
.tree-node .toggle.open { transform: rotate(90deg); }
.tree-node .node-icon { width: 15px; height: 15px; flex: 0 0 auto; }
.tree-node .node-icon.folder { color: #d69a2f; }
.tree-node .node-icon.file { color: #1878e8; }
.tree-node .node-icon.agreement { color: #6a2fde; }
.tree-node .node-label { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.tree-node .node-meta { font-size: 10px; color: #7d8ea6; flex: 0 0 auto; }
.tree-children { margin-left: 13px; border-left: 1px dashed #d6dfea; padding-left: 5px; }
.tree-children.collapsed { display: none; }

/* --------------------------------------------------------- record detail --- */
.version-timeline { position: relative; padding-left: 26px; }
.version-timeline:before { content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 2px; background: #dfe7f1; }
.version-node { position: relative; padding: 0 0 16px; }
.version-node:before { content: ""; position: absolute; left: -22px; top: 5px; width: 11px; height: 11px;
  border-radius: 50%; background: #fff; border: 2px solid #b9c8dc; }
.version-node.eff:before { background: #16a05f; border-color: #16a05f; }
.version-node.pending:before { background: #e5a014; border-color: #e5a014; }
.version-node.draft:before { background: #fff; border-color: #98a9c1; }
.version-node.rejected:before { background: #d4283f; border-color: #d4283f; }
.version-node .vhead { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.version-node .vhead b { font-size: 13px; color: #16304f; }
.version-node .vmeta { font-size: 11px; color: #6b7d97; margin-top: 4px; line-height: 1.6; }

.timeline-bar { position: relative; height: 56px; margin: 16px 0 6px; border-bottom: 1px solid #dde5ee; }
.timeline-bar .tl-seg { position: absolute; top: 14px; height: 12px; border-radius: 6px; background: #cfe0f5; }
.timeline-bar .tl-seg.eff { background: #16a05f; }
.timeline-bar .tl-seg.pending { background: #e5a014; }
.timeline-bar .tl-seg.future { background: #7ba7de; }
.timeline-bar .tl-tick { position: absolute; bottom: 4px; font-size: 9.5px; color: #7d8ea6; transform: translateX(-50%); }
.timeline-bar .tl-label { color: #4a688f; }

/* ------------------------------------------------------------- redline --- */
.redline-body { font-size: 12.5px; line-height: 1.75; color: #1f3550; white-space: pre-wrap;
  word-wrap: break-word; font-family: Georgia, "Times New Roman", serif; }
.redline-body ins { background: #e6f8ef; text-decoration: none; border-bottom: 1px solid #16a05f; color: #0d6a3f; }
.redline-body del { background: #fdeaec; color: #a3202f; }
.clean-body { font-size: 12.5px; line-height: 1.75; font-family: Georgia, "Times New Roman", serif; color: #1f3550; }
.clean-body p { margin: 0 0 11px; }
.doc-plain { font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px;
  line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; color: #24395a; margin: 0; }
.sbs { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid #e2e9f1; border-radius: 6px; overflow: hidden; }
.sbs-col { border-right: 1px solid #e2e9f1; overflow-x: auto; }
.sbs-col:last-child { border-right: 0; }
.sbs-head { background: #f6f9fc; padding: 8px 12px; font-size: 11px; font-weight: 700; color: #4a5f80;
  border-bottom: 1px solid #e2e9f1; position: sticky; top: 0; }
.sbs-line { padding: 1px 12px; font-family: "SFMono-Regular", ui-monospace, monospace; font-size: 11px;
  line-height: 1.55; white-space: pre; color: #2b4160; }
.sbs-line.sbs-add { background: #e9f9f0; }
.sbs-line.sbs-del { background: #fdeef0; }
.sbs-line.sbs-blank { background: #fafbfd; }
.diff-stats { display: flex; gap: 12px; font-size: 11px; color: #64768f; padding: 9px 0; }
.diff-stats b.add { color: #12854e; } .diff-stats b.del { color: #c92038; }

/* --------------------------------------------------------- validation ---- */
.validation-level { border: 1px solid #e2e9f1; border-radius: 7px; margin-bottom: 10px; overflow: hidden; }
.validation-level > header { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: #f8fafc; border-bottom: 1px solid #e9eef4; cursor: pointer; }
.validation-level > header .lvl-num { width: 22px; height: 22px; border-radius: 50%; background: #e6edf6;
  color: #4a688f; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: 0 0 auto; }
.validation-level.has-error > header .lvl-num { background: #fdecee; color: #c92038; }
.validation-level.has-warn > header .lvl-num { background: #fff4e0; color: #b57806; }
.validation-level.clean > header .lvl-num { background: #e8f7ef; color: #12854e; }
.validation-level > header h3 { margin: 0; font-size: 12.5px; font-weight: 700; color: #23395c; flex: 1; }
.finding { display: flex; gap: 11px; padding: 12px 14px; border-bottom: 1px solid #eef2f7; }
.finding:last-child { border-bottom: 0; }
.finding .f-icon { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.finding.error .f-icon { color: #d4283f; }
.finding.warning .f-icon { color: #e5a014; }
.finding.info .f-icon { color: #1274e8; }
.finding .f-body { min-width: 0; flex: 1; }
.finding .f-msg { font-size: 12.5px; color: #22395c; font-weight: 600; line-height: 1.5; }
.finding .f-detail { font-size: 11.5px; color: #61738d; margin-top: 4px; line-height: 1.6; }
.finding .f-fix { font-size: 11.5px; color: #2c6bb8; margin-top: 5px; line-height: 1.6; }
.finding .f-meta { font-size: 10.5px; color: #7f8fa8; margin-top: 5px; display: flex; gap: 10px; flex-wrap: wrap; }
.finding .f-link { flex: 0 0 auto; }

.readiness-panel .readiness-row { display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; font-size: 12px; border-bottom: 1px solid #f0f4f8; }
.readiness-panel .readiness-row:last-child { border-bottom: 0; }

/* ---------------------------------------------------------- change grid --- */
.bulk-bar { position: sticky; bottom: 0; z-index: 8; display: flex; align-items: center; gap: 10px;
  background: #0d2a4f; color: #eaf2fd; padding: 11px 16px; border-radius: 8px;
  box-shadow: 0 8px 26px rgba(8,32,64,.3); margin-top: 12px; }
.bulk-bar strong { font-size: 13px; }
.bulk-bar .btn { height: 32px; font-size: 12px; }
.bulk-bar .btn-ghost { color: #cfe0f5; border-color: rgba(255,255,255,.28); }
.bulk-bar .btn-ghost:hover { background: rgba(255,255,255,.1); }
.inline-edit { height: 28px; font-size: 11.5px; padding: 0 7px; border-radius: 4px; }
.inline-edit.narrow { width: 92px; }
.inline-edit.date { width: 132px; }
.inline-edit.tiny { width: 62px; }

.change-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: .3px; }
.change-tag.NEW { background: #e8f7ef; color: #12854e; }
.change-tag.CHANGE { background: #eaf3ff; color: #1268d6; }
.change-tag.CANCEL { background: #fdecee; color: #c92038; }
.change-tag.WITHDRAW { background: #fff4e0; color: #b57806; }
.change-tag.REINSTATE { background: #f3ecff; color: #6a2fde; }

/* ----------------------------------------------------------- wizard ------ */
.wizard-steps { display: flex; gap: 0; margin-bottom: 22px; }
.wizard-steps li { flex: 1; list-style: none; position: relative; padding: 0 10px; text-align: center; }
.wizard-steps li:before { content: ""; position: absolute; top: 13px; left: 0; right: 50%; height: 2px; background: #dde5ee; }
.wizard-steps li:after { content: ""; position: absolute; top: 13px; left: 50%; right: 0; height: 2px; background: #dde5ee; }
.wizard-steps li:first-child:before, .wizard-steps li:last-child:after { display: none; }
.wizard-steps li.done:before, .wizard-steps li.done:after, .wizard-steps li.current:before { background: #1375eb; }
.wizard-steps .dot { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 2px solid #cdd9e7; color: #7c8ca4; display: grid; place-items: center;
  margin: 0 auto 8px; font-size: 12px; font-weight: 700; }
.wizard-steps li.current .dot { border-color: #1375eb; color: #1375eb; box-shadow: 0 0 0 4px rgba(19,117,235,.12); }
.wizard-steps li.done .dot { background: #1375eb; border-color: #1375eb; color: #fff; }
.wizard-steps .label { font-size: 11.5px; font-weight: 600; color: #5d7191; }
.wizard-steps li.current .label { color: #0d5fc4; }

.pick-list { display: grid; gap: 9px; }
.pick { display: flex; gap: 12px; padding: 13px 15px; border: 1px solid #dbe4ee; border-radius: 7px;
  cursor: pointer; background: #fff; align-items: flex-start; }
.pick:hover { border-color: #a9cbf3; background: #fbfdff; }
.pick input { margin-top: 2px; accent-color: #1375eb; width: 16px; height: 16px; flex: 0 0 auto; }
.pick.checked { border-color: #1375eb; background: #f5faff; box-shadow: 0 0 0 1px #1375eb inset; }
.pick .pick-body { min-width: 0; }
.pick strong { display: block; font-size: 13px; color: #16304f; margin-bottom: 3px; }
.pick .pick-desc { font-size: 11.5px; color: #64768f; line-height: 1.55; }
.pick .pick-rule { font-size: 10.5px; color: #7d8ea6; margin-top: 6px; display: flex; gap: 9px; flex-wrap: wrap; }

/* ---------------------------------------------------------- workflow ----- */
.wf-steps { display: flex; flex-direction: column; gap: 0; }
.wf-step { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f4f8; }
.wf-step:last-child { border-bottom: 0; }
.wf-step .wf-dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; flex: 0 0 auto; background: #eef2f7; color: #7c8ca4; }
.wf-step.done .wf-dot { background: #e8f7ef; color: #12854e; }
.wf-step.current .wf-dot { background: #1375eb; color: #fff; box-shadow: 0 0 0 4px rgba(19,117,235,.14); }
.wf-step .wf-body { min-width: 0; flex: 1; }
.wf-step .wf-name { font-size: 12.5px; font-weight: 700; color: #23395c; }
.wf-step .wf-desc { font-size: 11px; color: #6b7d97; margin-top: 3px; line-height: 1.55; }
.wf-step .wf-decision { font-size: 11px; margin-top: 5px; }

/* --------------------------------------------------------- copilot ------- */
.copilot-fab { position: fixed; right: 24px; bottom: 24px; z-index: 40; width: 52px; height: 52px;
  border-radius: 50%; border: 0; background: linear-gradient(140deg,#1e7bf0,#6a2fde); color: #fff;
  display: grid; place-items: center; box-shadow: 0 8px 24px rgba(24,72,150,.35); cursor: pointer; }
.copilot-fab .icon { width: 25px; height: 25px; }
.copilot-panel { position: fixed; right: 0; top: 64px; bottom: 0; width: 420px; background: #fff;
  border-left: 1px solid #dbe3ed; box-shadow: -8px 0 28px rgba(16,40,74,.1); z-index: 45;
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .22s ease; }
.copilot-panel.open { transform: translateX(0); }
.copilot-head { height: 54px; display: flex; align-items: center; gap: 10px; padding: 0 16px;
  border-bottom: 1px solid #e7edf4; }
.copilot-head h2 { margin: 0; font-size: 14px; font-weight: 700; color: #10294d; flex: 1; }
.copilot-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.copilot-msg { font-size: 12.5px; line-height: 1.65; }
.copilot-msg.user { align-self: flex-end; background: #1375eb; color: #fff; padding: 9px 13px;
  border-radius: 12px 12px 3px 12px; max-width: 86%; }
.copilot-msg.assistant { background: #f5f8fc; border: 1px solid #e5ecf4; padding: 12px 14px;
  border-radius: 12px 12px 12px 3px; color: #22395c; }
.copilot-facts { margin-top: 10px; border-top: 1px solid #e5ecf4; padding-top: 9px; display: grid; gap: 6px; }
.copilot-facts a, .copilot-facts div { font-size: 11px; color: #4a688f; display: flex; gap: 8px; }
.copilot-facts b { color: #23395c; font-weight: 600; flex: 0 0 auto; max-width: 55%; }
.copilot-foot { border-top: 1px solid #e7edf4; padding: 12px 14px; }
.copilot-provider { font-size: 10px; color: #8493ab; margin-top: 7px; }
.copilot-suggest { border: 1px solid #d9c9f5; background: #faf7ff; border-radius: 7px; padding: 11px 13px; margin-bottom: 9px; }
.copilot-suggest .cs-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: #4b2a8f; }
.copilot-suggest .cs-why { font-size: 11px; color: #64768f; margin: 6px 0 9px; line-height: 1.6; }
.copilot-suggest .cs-actions { display: flex; gap: 7px; }
.conf { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  padding: 1px 6px; border-radius: 8px; }
.conf.high { background: #e8f7ef; color: #12854e; }
.conf.medium { background: #fff4e0; color: #b57806; }
.conf.low { background: #eef2f7; color: #68789a; }

/* ---------------------------------------------------------- modal -------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,28,55,.45); z-index: 70;
  display: grid; place-items: center; padding: 24px; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 620px; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(8,28,60,.3); }
.modal.wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid #e7edf4; }
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 700; color: #10294d; flex: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid #e7edf4; display: flex; gap: 9px; justify-content: flex-end; }

/* --------------------------------------------------------- login page ---- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 480px;
  background: linear-gradient(140deg,#062752 0%,#083667 48%,#05203f 100%); }
.auth-brand { display: flex; flex-direction: column; justify-content: center; padding: 60px 70px; color: #eaf2fd; }
.auth-brand .logo-row { display: flex; align-items: center; gap: 14px; margin-bottom: 34px; }
.auth-brand .logo-row img { width: 46px; height: 46px; }
.auth-brand .logo-row span { font-size: 23px; font-weight: 700; letter-spacing: -.4px; }
.auth-brand h1 { font-size: 33px; line-height: 1.25; margin: 0 0 18px; letter-spacing: -.8px; max-width: 620px; }
.auth-brand p { font-size: 15px; line-height: 1.7; color: #b9cee9; max-width: 560px; margin: 0 0 26px; }
.auth-points { display: grid; gap: 13px; max-width: 560px; }
.auth-points li { list-style: none; display: flex; gap: 11px; font-size: 13.5px; color: #cbdcf1; align-items: flex-start; }
.auth-points .icon { width: 19px; height: 19px; color: #6fb1f7; flex: 0 0 auto; margin-top: 2px; }
.auth-panel { background: #fff; display: flex; flex-direction: column; justify-content: center; padding: 48px 52px; }
.auth-panel h2 { margin: 0 0 6px; font-size: 22px; color: #0d2445; letter-spacing: -.4px; }
.auth-panel > p.sub { margin: 0 0 26px; color: #64768f; font-size: 13px; }
.auth-panel .btn-primary { height: 44px; font-size: 14px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: #94a3b8; font-size: 11px; }
.auth-divider:before, .auth-divider:after { content: ""; flex: 1; height: 1px; background: #e3eaf2; }
.demo-note { margin-top: 22px; padding: 12px 14px; background: #f5f8fc; border: 1px solid #e2e9f1;
  border-radius: 7px; font-size: 11.5px; color: #55688a; line-height: 1.65; }
.demo-note b { color: #23395c; }

/* -------------------------------------------------------- misc widgets --- */
.progress-bar.thin { height: 5px; }
.progress-bar span.amber { background: #e5a014; }
.progress-bar span.red { background: #d4283f; }
.progress-bar span.blue { background: #1375eb; }

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 8px; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  align-items: center; gap: 5px; min-width: 0; }
.bar-chart .bar { width: 100%; max-width: 34px; background: #1375eb; border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-chart .bar.alt { background: #6a2fde; }
.bar-chart .bar.ok { background: #16a05f; }
.bar-chart .bar.warn { background: #e5a014; }
.bar-chart .bar-label { font-size: 9px; color: #7d8ea6; white-space: nowrap; }
.bar-chart .bar-value { font-size: 9.5px; color: #4a688f; font-weight: 600; }

.hbar { display: grid; grid-template-columns: 150px minmax(0,1fr) 44px; gap: 10px; align-items: center;
  font-size: 11.5px; padding: 5px 0; }
.hbar .hbar-track { height: 8px; background: #eef2f7; border-radius: 4px; overflow: hidden; }
.hbar .hbar-fill { height: 100%; background: #1375eb; border-radius: 4px; }
.hbar .hbar-fill.red { background: #d4283f; }
.hbar .hbar-fill.amber { background: #e5a014; }
.hbar .hbar-fill.green { background: #16a05f; }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; color: #24395a; }

.dropzone { border: 2px dashed #c6d5e6; border-radius: 9px; padding: 28px 20px; text-align: center;
  background: #fafcff; color: #62748f; cursor: pointer; }
.dropzone.drag { border-color: #1375eb; background: #f0f7ff; }
.dropzone .icon { width: 30px; height: 30px; color: #93aac6; margin: 0 auto 10px; }
.dropzone strong { display: block; font-size: 13px; color: #2b4468; margin-bottom: 4px; }

.file-row { display: flex; align-items: center; gap: 11px; padding: 10px 0; border-bottom: 1px solid #f0f4f8; }
.file-row:last-child { border-bottom: 0; }
.file-icon { width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center;
  background: #eff5ff; color: #0871f1; flex: 0 0 auto; }
.file-icon .icon { width: 18px; height: 18px; }
.file-icon.red { background: #fff0f3; color: #e52848; }
.file-icon.green { background: #eafaf1; color: #12854e; }
.file-icon.purple { background: #f4efff; color: #6a2fde; }
.file-row .file-meta { font-size: 10.5px; color: #71829c; margin-top: 2px; }

.hash { font-family: "SFMono-Regular", ui-monospace, monospace; font-size: 10.5px; color: #6b7d97;
  background: #f4f7fb; padding: 2px 6px; border-radius: 4px; word-break: break-all; }

.side-list { display: flex; flex-direction: column; }
.side-list a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px;
  font-size: 12px; color: #40587c; font-weight: 600; }
.side-list a:hover { background: #f2f7fd; }
.side-list a.active { background: #eaf3ff; color: #0d5fc4; }
.side-list a .icon { width: 16px; height: 16px; }
.side-list a .count { margin-left: auto; font-size: 10.5px; color: #7d8ea6; font-weight: 600; }

.searchbox { position: relative; }
.searchbox .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: #8a9cb5; pointer-events: none; }
.searchbox input { padding-left: 32px; }

.suggest-drop { position: absolute; left: 0; right: 0; top: 46px; background: #fff; border: 1px solid #d8e2ee;
  border-radius: 7px; box-shadow: 0 10px 30px rgba(16,40,74,.14); z-index: 30; max-height: 420px; overflow-y: auto; }
.suggest-drop a { display: block; padding: 9px 13px; border-bottom: 1px solid #f0f4f8; }
.suggest-drop a:last-child { border-bottom: 0; }
.suggest-drop a:hover { background: #f5f9fd; }
.suggest-drop .s-title { font-size: 12.5px; color: #16304f; font-weight: 600; }
.suggest-drop .s-meta { font-size: 10.5px; color: #71829c; margin-top: 2px; }
.suggest-drop .s-scope { font-size: 9.5px; text-transform: uppercase; letter-spacing: .4px; color: #8a9cb5; }

.notif-drop { position: absolute; right: 0; top: 46px; width: 380px; background: #fff; border: 1px solid #d8e2ee;
  border-radius: 8px; box-shadow: 0 12px 34px rgba(16,40,74,.18); z-index: 40; max-height: 460px; overflow-y: auto; }
.notif-drop header { padding: 12px 15px; border-bottom: 1px solid #eef2f7; display: flex; align-items: center; }
.notif-drop header h3 { margin: 0; font-size: 13px; color: #10294d; flex: 1; }
.notif-item { display: flex; gap: 10px; padding: 11px 15px; border-bottom: 1px solid #f2f5f9; }
.notif-item:last-child { border-bottom: 0; }
.notif-item.unread { background: #f6faff; }
.notif-item .n-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; background: #cbd6e4; }
.notif-item.unread .n-dot { background: #1375eb; }
.notif-item .n-title { font-size: 12px; color: #22395c; font-weight: 600; line-height: 1.45; }
.notif-item .n-meta { font-size: 10px; color: #7d8ea6; margin-top: 3px; }
.notif-item.severity-warning .n-dot { background: #e5a014; }
.notif-item.severity-error .n-dot { background: #d4283f; }

.profile { position: relative; cursor: pointer; }
.profile-drop { position: absolute; right: 0; top: 52px; width: 250px; background: #fff; border: 1px solid #d8e2ee;
  border-radius: 8px; box-shadow: 0 12px 34px rgba(16,40,74,.18); z-index: 40; padding: 8px; }
.profile-drop .pd-head { padding: 10px 11px 12px; border-bottom: 1px solid #eef2f7; margin-bottom: 6px; }
.profile-drop .pd-head b { display: block; font-size: 13px; color: #16304f; }
.profile-drop .pd-head span { display: block; font-size: 11px; color: #71829c; margin-top: 2px; }
.profile-drop a { display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: 6px;
  font-size: 12px; color: #40587c; font-weight: 600; }
.profile-drop a:hover { background: #f2f7fd; }
.profile-drop a .icon { width: 16px; height: 16px; }

.sidebar.collapsed { width: 62px; }
.sidebar.collapsed .nav-item span, .sidebar.collapsed .collapse-button span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0; }
body.nav-collapsed .main-content { margin-left: 62px; }
.nav-section { font-size: 9.5px; text-transform: uppercase; letter-spacing: .7px; color: #9db6d8;
  padding: 14px 15px 5px; font-weight: 700; }
.sidebar.collapsed .nav-section { display: none; }
.nav-item .nav-count { margin-left: auto; background: rgba(255,255,255,.16); border-radius: 9px;
  padding: 1px 7px; font-size: 10px; font-weight: 700; }
.sidebar.collapsed .nav-item .nav-count { display: none; }
.side-nav { overflow-y: auto; flex: 1; padding-bottom: 12px; }
.side-nav::-webkit-scrollbar { width: 7px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 4px; }

.provisional-banner { background: #fff8ec; border-bottom: 1px solid #f3ddb4; color: #8a6209;
  font-size: 11.5px; padding: 8px 34px; display: flex; align-items: center; gap: 9px; }
.provisional-banner .icon { width: 16px; height: 16px; flex: 0 0 auto; }
.provisional-banner a { color: #7a5307; text-decoration: underline; font-weight: 600; }

@media (max-width: 1400px) {
  .grid-side { grid-template-columns: minmax(0,1fr) 300px; }
  .field-row-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 1200px) {
  .grid-side, .grid-side-left { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

@media print {
  .topbar, .sidebar, .page-actions, .copilot-fab, .copilot-panel, .bulk-bar, .tabs { display: none !important; }
  .main-content { margin: 0; padding: 0; min-width: 0; background: #fff; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
}

/* --------------------------------------------- design-fidelity fixes ----- */
/* Sidebar labels must never wrap; the reference keeps every item on one line. */
.nav-item span { white-space: nowrap; }
.nav-item { padding: 0 12px; gap: 10px; font-size: 13.5px; }
.nav-item .icon { width: 21px; height: 21px; }
.sidebar { width: 236px; }
.main-content { margin-left: 236px; }

/* In the four-up lower grid the card titles are longer than the template's,
   so let the title shrink rather than collide with its action link. */
.lower-grid .card-header h2 { min-width: 0; overflow: hidden; }
.lower-grid .card-header h2 span:not(.count-pill) { overflow: hidden; text-overflow: ellipsis; }
.lower-grid .card-header.compact { gap: 8px; }
.lower-grid .card-header.compact h2 { font-size: 13px; letter-spacing: -.15px; }
.lower-grid .card-header.compact .section-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.lower-grid .card-header.compact a { font-size: 10.5px; }
.lower-grid .card-header.compact a { flex: 0 0 auto; }
.card-header h2 { min-width: 0; }

/* ==========================================================================
   RESPONSIVE LAYER
   The supplied template is desktop-only: it pins .main-content to a 1180px
   minimum, fixes the sidebar open, and lays tables out with fixed column
   widths. Everything below adapts that to tablet and phone without changing
   the desktop rendering, which stays pixel-faithful to the template.
   Breakpoints: 1400 / 1200 / 1024 / 768 / 560.
   ========================================================================== */

/* Wide tables scroll inside their own container rather than the page body. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ------------------------------------------------------- tablet: <=1024px - */
@media (max-width: 1024px) {
  html, body { font-size: 14px; }
  body { overflow-x: hidden; }

  /* The sidebar becomes an off-canvas drawer. */
  .sidebar {
    width: 264px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 4px 0 28px rgba(6, 30, 64, .3);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .sidebar.collapsed { width: 264px; }
  .sidebar.collapsed .nav-item span,
  .sidebar.collapsed .collapse-button span,
  .sidebar.collapsed .nav-section { display: block; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 0 12px; }

  .main-content,
  body.nav-collapsed .main-content {
    margin-left: 0;
    min-width: 0;
    padding: 18px 20px 44px;
  }
  .main-content.wide { min-width: 0; }

  /* Scrim behind the open drawer. */
  .nav-scrim {
    position: fixed; inset: 64px 0 0 0; background: rgba(8, 28, 56, .45);
    z-index: 14; opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }

  /* Hamburger appears in the topbar. */
  .nav-toggle { display: grid !important; }
  .brand { width: auto; padding-left: 8px; flex: 0 0 auto; }
  .global-search { width: auto; flex: 1 1 auto; min-width: 0; margin: 0 14px; }

  /* Grids collapse. */
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .upper-grid { grid-template-columns: 1fr; }
  .lower-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lower-grid > .card { height: auto; min-height: 280px; }
  .grid-side, .grid-side-left { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .validation-card, .open-filings { height: auto; }

  /* Fixed template column widths must give way once the viewport is narrow. */
  table { table-layout: auto; }
  th:nth-child(1), th:nth-child(2), th:nth-child(3), th:nth-child(4),
  th:nth-child(5), th:nth-child(6), th:nth-child(7) { width: auto; }

  .copilot-panel { width: 400px; }
}

/* --------------------------------------------------------- phone: <=768px - */
@media (max-width: 768px) {
  .topbar { height: 58px; }
  .sidebar { top: 58px; }
  .nav-scrim { top: 58px; }
  .main-content { margin-top: 58px; padding: 14px 14px 40px; }

  .brand span { display: none; }          /* logo only; the title returns >768 */
  .brand-logo { width: 32px; height: 32px; }
  .global-search { height: 38px; margin: 0 10px; }
  .global-search .shortcut { display: none; }
  .top-actions { gap: 4px; padding-right: 10px; }
  .profile img { width: 34px; height: 34px; }
  .profile .chevron { display: none; }

  .page-heading { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-heading h1 { font-size: 20px; }
  .page-actions { flex-wrap: wrap; }
  .page-actions .btn { flex: 1 1 auto; min-width: 132px; }
  .page-actions .btn-square { flex: 0 0 auto; min-width: 0; }
  .split-button { flex: 1 1 100%; }
  .split-button .btn:first-child { flex: 1 1 auto; }

  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi-card { min-height: 0; padding: 12px; gap: 10px; }
  .kpi-icon { width: 42px; height: 42px; }
  .kpi-icon .icon { width: 23px; height: 23px; }
  .kpi-card strong { font-size: 20px; }
  .kpi-card .kpi-label { white-space: normal; line-height: 1.3; }

  .lower-grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .field-row, .field-row-3, .field-row-4 { grid-template-columns: 1fr; }
  .sbs { grid-template-columns: 1fr; }
  .sbs-col { border-right: 0; border-bottom: 1px solid #e2e9f1; }

  .card-header { height: auto; min-height: 46px; padding: 10px 14px; flex-wrap: wrap; gap: 6px; }
  .card-header.compact { height: auto; padding: 10px 14px; }
  .card-body { padding: 14px; }
  .table-wrap { padding: 0; }

  /* Tabs scroll horizontally with a hint of the next item. */
  .tabs { -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 1px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { padding: 9px 11px; font-size: 12px; }

  /* Key/value lists stack. */
  .kv, .kv.compact { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; }
  .kv dd { margin-bottom: 4px; }

  .wizard-steps { gap: 0; }
  .wizard-steps .label { font-size: 10px; }
  .wizard-steps li { padding: 0 4px; }

  /* The bulk bar becomes a stacked sheet pinned to the bottom. */
  .bulk-bar {
    position: fixed; left: 10px; right: 10px; bottom: 10px; margin: 0;
    flex-wrap: wrap; gap: 8px; padding: 12px 14px; z-index: 42;
  }
  .bulk-bar .spacer { display: none; }
  .bulk-bar select, .bulk-bar input { width: 100% !important; }
  .bulk-bar .btn { width: 100%; }
  .bulk-bar strong { flex: 1 1 100%; }

  /* Copilot becomes a full-height sheet. */
  .copilot-panel { width: 100%; top: 58px; }
  .copilot-fab { right: 16px; bottom: 16px; width: 48px; height: 48px; }
  body.copilot-open .copilot-fab { display: none; }

  .flash-stack { top: 68px; right: 10px; left: 10px; width: auto; }
  .notif-drop { width: calc(100vw - 24px); right: -8px; }
  .suggest-drop { position: fixed; left: 10px; right: 10px; top: 60px; }
  .profile-drop { right: -4px; }

  .modal { max-width: 100%; max-height: 92vh; }
  .auth-panel { padding: 34px 22px; }
  .auth-brand { display: none; }

  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hbar { grid-template-columns: 110px minmax(0, 1fr) 38px; font-size: 11px; }
  .bar-chart { height: 110px; }
  .bar-chart .bar-label { font-size: 8px; }

  .timeline { padding-left: 30px; }
  .timeline:before { left: 38px; }

  .tree-full { max-height: 420px; }
  .empty-state { padding: 30px 16px; }

  /* Touch targets. */
  .btn { height: 40px; }
  .btn-sm { height: 34px; }
  .btn-xs { height: 30px; }
  .row-menu { width: 32px; height: 32px; }
  input[type=text], input[type=email], input[type=password], input[type=date],
  input[type=number], input[type=search], select, textarea { font-size: 16px; }  /* stops iOS zoom-on-focus */
  .inline-edit { font-size: 16px; height: 34px; }
}

/* ------------------------------------------------- small phone: <=560px --- */
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: 1fr; }
  .page-actions .btn { min-width: 0; width: 100%; }
  .global-search { margin: 0 8px; }
  .profile-copy { display: none; }
  .hbar { grid-template-columns: 88px minmax(0, 1fr) 34px; }
  .wizard-steps .label { display: none; }
  .wizard-steps .dot { margin-bottom: 0; }

  /* Dense tables become stacked cards: each row is a labelled block. */
  table.stack-mobile, table.stack-mobile thead, table.stack-mobile tbody,
  table.stack-mobile tr, table.stack-mobile th, table.stack-mobile td { display: block; }
  table.stack-mobile thead { position: absolute; left: -9999px; }
  table.stack-mobile tr {
    border: 1px solid #e3e9f1; border-radius: 8px; margin: 0 0 10px; padding: 10px 12px;
    background: #fff; height: auto;
  }
  table.stack-mobile td {
    border: 0; padding: 4px 0; white-space: normal; overflow: visible;
    display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 10px; align-items: start;
  }
  table.stack-mobile td:before {
    content: attr(data-label); font-size: 10px; font-weight: 700; color: #7285a0;
    text-transform: uppercase; letter-spacing: .4px; padding-top: 2px;
  }
  table.stack-mobile td:empty { display: none; }
  /* Right alignment is a wide-table affordance; stacked cells read left. */
  table.stack-mobile td.num { text-align: left; }
  table.stack-mobile td > .status,
  table.stack-mobile td > .pill,
  table.stack-mobile td > .change-tag { justify-self: start; }
  table.stack-mobile td.check-col { grid-template-columns: 118px minmax(0,1fr); }
  table.stack-mobile td.tight { width: auto; }
}

/* ------------------------------------------- desktop-only affordances ----- */
.nav-toggle { display: none; }
@media (min-width: 1025px) {
  .nav-scrim { display: none; }
}

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  .sidebar, .copilot-panel, .nav-scrim, .flash-stack { transition: none !important; }
}

/* Coarse pointers get larger hit areas regardless of viewport width. */
@media (pointer: coarse) {
  .nav-item { height: 48px; }
  .tabs a { padding-top: 12px; padding-bottom: 12px; }
  .table-plain td, .table-plain th { padding-top: 11px; padding-bottom: 11px; }
  .check-col input, .checkline input { width: 18px; height: 18px; }
}

/* --------------------------------------------- responsive corrections ----- */
/* The template pins .main-content to 1180px (950px under 1200px), which forces
   the page to scroll horizontally on anything narrower than ~1440px. Release
   that and let the grids reflow instead. */
@media (max-width: 1440px) {
  .main-content { min-width: 0; }
  .main-content.wide { min-width: 0; }
}
@media (max-width: 1280px) {
  .lower-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lower-grid > .card { height: auto; min-height: 300px; }
  .upper-grid { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 1100px) {
  .upper-grid { grid-template-columns: 1fr; }
  .validation-card, .open-filings { height: auto; }
}

/* Filter bars carry fixed pixel widths from the desktop layout. On narrow
   viewports those must yield or the card header pushes the page wider than the
   screen - the classic source of horizontal scroll on a phone. */
@media (max-width: 900px) {
  .row { flex-wrap: wrap; }
  .card-header { flex-wrap: wrap; row-gap: 8px; }
  .card-header > form,
  .card-header > .header-tools { width: 100%; }

  .card-header form > select,
  .card-header form > input,
  .card-header form > .searchbox,
  .card-header form > label,
  .card-header form > .btn,
  form.row > select,
  form.row > input,
  form.row > .searchbox,
  form.row > .chip {
    flex: 1 1 150px;
    width: auto !important;
    min-width: 0;
    max-width: 100%;
  }
  .card-header form > .searchbox,
  form.row > .searchbox { flex: 1 1 100%; }
  .searchbox input { width: 100%; }

  /* Inline field blocks inside wrapping toolbars. */
  .row.wrap > .field { flex: 1 1 190px; width: auto !important; min-width: 0; }
}

/* Anything that still cannot shrink scrolls inside its own box rather than
   widening the document. */
@media (max-width: 1024px) {
  .card, .panel { max-width: 100%; }
  .table-scroll, .table-wrap { max-width: 100%; }
  pre, .doc-plain { max-width: 100%; overflow-x: auto; }
  .redline-body, .clean-body { overflow-wrap: anywhere; }
  .hash { overflow-wrap: anywhere; }
}

/* KPI row density, declared as classes so the responsive rules can override
   them without !important. */
.kpi-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1024px) {
  .kpi-grid.cols-4, .kpi-grid.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .kpi-grid.cols-4, .kpi-grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .kpi-grid.cols-4, .kpi-grid.cols-5 { grid-template-columns: 1fr; }
}

/* Grid items default to min-width:auto, so a wide table inside one refuses to
   shrink and pushes the whole page sideways. Every layout grid opts out. */
.grid-side > *, .grid-side-left > *,
.grid-2 > *, .grid-3 > *, .grid-4 > *,
.upper-grid > *, .lower-grid > *,
.kpi-grid > *, .metric-row > *,
.field-row > *, .field-row-3 > *, .field-row-4 > * { min-width: 0; }
.stack > * { min-width: 0; }

/* --------------------------------------------- responsive polish --------- */
/* A flex item will not shrink below its intrinsic content width unless told
   to, so the search field was growing under the topbar actions on a phone. */
.global-search { min-width: 0; }
.global-search input { min-width: 0; }
.top-actions { flex: 0 0 auto; }

@media (max-width: 768px) {
  /* Two KPI tiles per row reads better than one on a 390px phone. */
  .kpi-grid, .kpi-grid.cols-4, .kpi-grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Icon-only actions stay small instead of stretching across the row. */
  .page-actions .btn-square { width: 44px; min-width: 44px; flex: 0 0 auto; }
  .page-actions { gap: 8px; }
}
@media (max-width: 400px) {
  .kpi-grid, .kpi-grid.cols-4, .kpi-grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card { flex-direction: column; align-items: flex-start; gap: 6px; padding: 11px 10px; }
  .kpi-icon { width: 34px; height: 34px; border-radius: 8px; }
  .kpi-icon .icon { width: 19px; height: 19px; }
  .kpi-card strong { font-size: 19px; }
}
@media (max-width: 340px) {
  .kpi-grid, .kpi-grid.cols-4, .kpi-grid.cols-5 { grid-template-columns: 1fr; }
}
