/* Sample financial statements workbook (case study).

   A spreadsheet, not a copy of any one spreadsheet app: the grid, formula
   bar, sheet tabs and status bar are the parts people recognise, rendered in
   the site's own blue and the Archivo face used by the dashboard sample.

   Figures are illustrative; see the banner at the top of the page. */

@font-face{
  font-family:'Archivo';
  src:url('../fonts/Archivo-Variable.woff2') format('woff2');
  font-weight:400 700;
  font-style:normal;
  font-display:swap;
}

:root{
  --paper:#EEF0F6;
  --surface:#FFFFFF;
  --chrome:#F6F7FB;
  --head:#F1F3F8;
  --head-hl:#DCE7F3;
  --rule:#E3E5EE;
  --rule-strong:#C9CCD9;

  --ink:#10192A;
  --ink-2:#3E4D64;
  --ink-3:#5A667A;

  --accent:#1A6FA8;
  --accent-deep:#0F4C77;
  --accent-wash:#E6F0F8;
  --sel-fill:rgba(26,111,168,0.10);

  --input:#1747C4;
  --link:#157048;
  --pos:#197A5E;

  --cell-h:21px;
}

*,*::before,*::after{box-sizing:border-box;}

html,body{height:100%;}
body.wb{height:100vh;height:100dvh;}
body.wb{
  margin:0;
  display:flex;
  flex-direction:column;
  background:var(--paper);
  color:var(--ink);
  font-family:'Archivo','Helvetica Neue',Helvetica,Arial,sans-serif;
  font-size:14px;
  line-height:1.4;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}
body.wb button{font:inherit;}
body.wb ::selection{background:var(--accent);color:#fff;}

/* ---------------- notice ---------------- */
.wb-notice{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px 20px;
  padding:10px 20px;
  background:var(--ink);
  color:#fff;
  font-size:13px;
}
.wb-notice a{color:#fff;text-decoration:underline;text-underline-offset:3px;text-decoration-thickness:1px;}
.wb-notice a:hover{text-decoration-thickness:2px;}
.wb-notice-tag{
  padding:3px 7px;
  border-radius:4px;
  background:rgba(255,255,255,0.14);
  font-size:11px;
  font-weight:600;
  letter-spacing:0.1em;
  text-transform:uppercase;
}
.wb-notice-text{color:rgba(255,255,255,0.72);}
.wb-notice-back{margin-left:auto;font-weight:500;}

/* ---------------- window ---------------- */
.wb-window{
  flex:1 1 auto;
  display:flex;
  flex-direction:column;
  min-height:0;
  width:calc(100% - 12px);
  min-height:520px;
  margin:6px auto;
  background:var(--surface);
  border:1px solid var(--rule-strong);
  border-radius:8px;
  overflow:hidden;
  box-shadow:0 1px 2px rgba(16,25,42,0.06), 0 12px 32px -12px rgba(16,25,42,0.18);
}

.wb-titlebar{
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 14px;
  background:var(--accent-deep);
  color:#fff;
}
.wb-app-mark{display:inline-flex;width:20px;height:20px;}
.wb-app-mark svg{width:100%;height:100%;}
.wb-filename{
  margin:0;
  font-size:13px;
  font-weight:600;
  letter-spacing:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.wb-filename span{font-weight:400;opacity:0.7;}
.wb-saved{
  margin-left:auto;
  font-size:12px;
  color:rgba(255,255,255,0.7);
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.wb-saved::before{
  content:"";
  width:6px;height:6px;border-radius:50%;
  background:#6FD3A6;
}

/* ---------------- ribbon (decorative) ---------------- */
.wb-ribbon{
  background:var(--chrome);
  border-bottom:1px solid var(--rule);
  user-select:none;
}
.wb-ribbon-tabs{
  display:flex;
  gap:2px;
  padding:0 10px;
  overflow:hidden;
  font-size:12px;
  color:var(--ink-2);
}
.wb-ribbon-tabs span{padding:5px 9px 4px;white-space:nowrap;border-bottom:2px solid transparent;}
.wb-ribbon-tabs .is-active{color:var(--accent-deep);font-weight:600;border-bottom-color:var(--accent);}
.wb-toolbar{
  display:flex;
  align-items:center;
  gap:4px;
  padding:4px 10px 5px;
  overflow:hidden;
  color:var(--ink-2);
  font-size:12px;
}
.wb-tool{
  flex:0 0 auto;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:28px;
  height:23px;
  padding:0 6px;
  border-radius:5px;
}
.wb-tool svg{width:16px;height:16px;}
.wb-tool--wide{
  padding:0 10px;
  background:var(--surface);
  border:1px solid var(--rule);
  white-space:nowrap;
}
.wb-tool--fill{box-shadow:inset 0 -3px 0 #F4D35E;}
.wb-sep{flex:0 0 auto;width:1px;height:20px;margin:0 6px;background:var(--rule-strong);}

/* ---------------- formula bar ---------------- */
.wb-formula{
  display:flex;
  align-items:stretch;
  border-bottom:1px solid var(--rule);
  font-size:12px;
  min-height:26px;
}
.wb-namebox{
  flex:0 0 96px;
  display:flex;
  align-items:center;
  padding:0 8px;
  border-right:1px solid var(--rule);
  font-weight:500;
  font-variant-numeric:tabular-nums;
}
.wb-fx{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  padding:0 12px;
  border-right:1px solid var(--rule);
  color:var(--ink-3);
  font-family:Georgia,'Times New Roman',serif;
}
.wb-formula-text{
  flex:1 1 auto;
  min-width:0;
  display:flex;
  align-items:center;
  padding:0 12px;
  font-family:ui-monospace,'SF Mono',Menlo,Consolas,monospace;
  font-size:11.5px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* ---------------- grid ---------------- */
.wb-grid-wrap{
  position:relative;
  flex:1 1 auto;
  min-height:0;
  overflow:auto;
  background:var(--surface);
  outline:none;
  scrollbar-width:thin;
  scrollbar-color:var(--rule-strong) transparent;
}
.wb-grid-wrap:focus-visible{box-shadow:inset 0 0 0 2px var(--accent);}

.wb-grid{
  font-size:12px;
  border-collapse:separate;
  border-spacing:0;
  table-layout:fixed;
  width:max-content;
  font-variant-numeric:tabular-nums lining-nums;
  user-select:none;
  cursor:cell;
}
.wb-col-rownum{width:36px;}

.wb-grid th,
.wb-grid td{
  height:var(--cell-h);
  padding:0 6px;
  border-right:1px solid var(--rule);
  border-bottom:1px solid var(--rule);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:clip;
  font-weight:400;
}

.wb-grid thead th{
  position:sticky;
  top:0;
  z-index:4;
  background:var(--head);
  color:var(--ink-3);
  font-size:10.5px;
  text-align:center;
  border-bottom-color:var(--rule-strong);
}
.wb-grid .wb-rowhead{
  position:sticky;
  left:0;
  z-index:3;
  background:var(--head);
  color:var(--ink-3);
  font-size:10.5px;
  text-align:center;
  border-right-color:var(--rule-strong);
  padding:0 4px;
}
.wb-grid .wb-corner{left:0;z-index:5;}
.wb-grid .wb-corner::after{
  content:"";
  position:absolute;
  right:3px;bottom:3px;
  border-left:8px solid transparent;
  border-bottom:8px solid var(--rule-strong);
}
.wb-grid th.is-hl{background:var(--head-hl);color:var(--accent-deep);font-weight:600;}
.wb-grid thead th.is-hl{box-shadow:inset 0 -2px 0 var(--accent);}
.wb-grid .wb-rowhead.is-hl{box-shadow:inset -2px 0 0 var(--accent);}

.wb-cell{position:relative;}
.wb-cell.is-num{text-align:right;}
.wb-cell.is-input{color:var(--input);}
.wb-cell.is-link{color:var(--link);}
.wb-cell.is-sel{background:var(--sel-fill);}
.wb-cell.is-active{background:var(--surface);}
.wb-cell.is-active::after{
  content:"";
  position:absolute;
  inset:0;
  border:2px solid var(--accent);
  pointer-events:none;
}
/* the fill handle */
.wb-cell.is-active::before{
  content:"";
  position:absolute;
  right:0;bottom:0;
  z-index:1;
  width:7px;height:7px;
  background:var(--accent);
  border:1px solid #fff;
}

/* ---------------- row styles ---------------- */
.r-title .wb-cell.is-label{font-size:14px;font-weight:700;overflow:visible;}
.r-sub .wb-cell.is-label{color:var(--ink-3);font-size:11px;overflow:visible;}
.r-head .wb-cell{
  background:var(--accent-deep);
  color:#fff;
  font-weight:600;
  font-size:11px;
  border-right-color:rgba(255,255,255,0.14);
}
.r-head .wb-cell:empty{background:var(--surface);border-right-color:var(--rule);}
.r-head .wb-cell.is-label{background:var(--accent-deep);}
.r-head .wb-cell.is-sel{box-shadow:inset 0 0 0 999px rgba(255,255,255,0.14);}
.r-section .wb-cell.is-label{
  font-weight:700;
  color:var(--accent-deep);
  text-transform:uppercase;
  font-size:10px;
  letter-spacing:0.06em;
  overflow:visible;
}
.r-subsection .wb-cell.is-label{font-style:italic;color:var(--ink-2);overflow:visible;}
.r-indent .wb-cell.is-label{padding-left:16px;}
.r-indent2 .wb-cell.is-label{padding-left:27px;color:var(--ink-2);}
.r-subtotal .wb-cell{font-weight:600;}
.r-subtotal .wb-cell.is-label{padding-left:16px;}
.r-subtotal .wb-cell.is-num{box-shadow:inset 0 1px 0 var(--rule-strong);}

.r-total .wb-cell{font-weight:600;}
.r-total .wb-cell.is-num{box-shadow:inset 0 1px 0 var(--ink);}
.r-strong .wb-cell{font-weight:700;}
.r-grand .wb-cell{font-weight:700;background:var(--accent-wash);}
.r-grand .wb-cell.is-num{box-shadow:inset 0 1px 0 var(--ink), inset 0 -3px 0 var(--accent-wash), inset 0 -4px 0 var(--ink);}
.r-grand .wb-cell.is-sel{background:#D6E6F3;}
.r-ratio .wb-cell{font-style:italic;color:var(--ink-3);}
.r-check .wb-cell{color:var(--pos);font-weight:600;font-size:11px;}
.r-muted .wb-cell{color:var(--ink-3);}
.r-note .wb-cell.is-label{padding-left:16px;}
.r-note .wb-cell.is-label::before{content:"\2022";margin-right:10px;color:var(--ink-3);}
.r-note .wb-cell.is-input::before,
.r-note .wb-cell.is-link::before{color:currentColor;}

/* ---------------- floating charts (Balance Sheet) ----------------
   Chart objects sit over the grid like embedded charts in a workbook: they
   scroll with the cells and keep a fixed size, so on a narrow screen the
   sheet scrolls sideways rather than the charts reflowing. */
.wb-charts{
  position:absolute;
  z-index:2;
  display:flex;
  flex-direction:column;
  gap:14px;
  cursor:default;
  user-select:none;
}
.wb-chart,
.kpi{
  margin:0;
  background:#fff;
  border:1px solid #D5D8E1;
  box-shadow:0 1px 2px rgba(16,25,42,0.06), 0 6px 16px -10px rgba(16,25,42,0.25);
}
.wb-chart--sankey{padding:14px 16px 10px;}
.wb-chart figcaption{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 14px;margin-bottom:6px;}
.wb-chart-t{font-size:16px;font-weight:700;}
.wb-chart-s{font-size:12px;color:var(--ink-3);}
.sk{display:block;overflow:visible;}
.sk-l{
  font-size:10.5px;
  font-weight:600;
  fill:var(--ink);
  paint-order:stroke;
  stroke:rgba(255,255,255,0.85);
  stroke-width:3px;
  stroke-linejoin:round;
}
.sk-g{font-size:11.5px;font-weight:700;}
.sk-v{font-weight:400;fill:var(--ink-2);}

.wb-kpis{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  grid-auto-rows:222px;
  gap:14px;
}
.wb-charts--side .kpi{height:300px;}
.kpi--center figcaption{align-items:center;text-align:center;}
.kpi-legend{display:flex;justify-content:center;gap:18px;margin-top:8px;font-size:12px;color:var(--ink-2);}
.kpi-legend .sw::before{content:"";display:inline-block;width:10px;height:10px;margin-right:6px;vertical-align:-1px;}
.sw-ar::before{background:#7A3FA3;}
.sw-ap::before{background:#35B6DE;}
.kpi .ax{font-size:10.5px;fill:var(--ink-3);}
.kpi .ax-x{font-size:11.5px;fill:var(--ink-2);}
.kpi .lbl{font-size:10.5px;font-weight:600;fill:#3A3F4B;}
.kpi-t--blue{color:#1F5C85;font-size:17px;}
.wcc-body{flex:1 1 auto;display:flex;gap:10px;min-height:0;margin-top:6px;}
.wcc-body svg{flex:1 1 auto;width:auto;min-width:0;height:100%;margin:0;}
.wcc-text{flex:0 0 190px;display:flex;flex-direction:column;justify-content:center;}
.wcc-text p{margin:0;}
.wcc-lead{font-size:13px;font-weight:600;color:var(--ink-3);}
.wcc-days{font-size:34px;font-weight:700;color:#1AA0B3;line-height:1.2;font-variant-numeric:tabular-nums;}
.wcc-note{font-size:13px;color:var(--ink-2);line-height:1.35;}
.wcc-text dl{display:grid;grid-template-columns:auto auto;gap:3px 12px;margin:12px 0 0;font-size:13px;}
.wcc-text dt{font-weight:600;color:var(--ink-2);}
.wcc-text dd{margin:0;font-weight:700;color:#1AA0B3;text-align:right;font-variant-numeric:tabular-nums;}
.kpi{
  display:flex;
  flex-direction:column;
  padding:14px 16px 10px;
  min-width:0;
}
.kpi figcaption{display:flex;flex-direction:column;gap:1px;}
.kpi-t{font-size:15px;font-weight:700;letter-spacing:-0.01em;}
.kpi-s{font-size:11.5px;color:var(--ink-3);}
.kpi-v{margin-top:4px;font-size:26px;font-weight:600;line-height:1.1;font-variant-numeric:tabular-nums;color:#3A3F4B;}
.kpi svg{display:block;flex:1 1 auto;min-height:0;width:100%;margin-top:auto;}
.kpi-spark text{font-size:10px;fill:var(--ink-3);}
.kpi--ring{text-align:center;}
.kpi--ring figcaption{align-items:center;}
.kpi-gauge-v{font-size:17px;font-weight:700;fill:#3A3F4B;}
.kpi-gauge-e{font-size:12px;font-weight:600;fill:#3A3F4B;}

/* ---------------- sheet tabs ---------------- */
.wb-sheets{
  display:flex;
  align-items:stretch;
  background:var(--chrome);
  border-top:1px solid var(--rule-strong);
  min-height:30px;
}
.wb-sheets-nav{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:2px;
  padding:0 8px;
  color:var(--ink-3);
  border-right:1px solid var(--rule);
}
.wb-sheets-nav svg{width:16px;height:16px;}
.wb-tabs{
  flex:0 1 auto;
  display:flex;
  min-width:0;
  overflow-x:auto;
  scrollbar-width:none;
}
.wb-tabs::-webkit-scrollbar{display:none;}
.wb-tab{
  position:relative;
  flex:0 0 auto;
  padding:0 14px;
  border:0;
  border-right:1px solid var(--rule);
  background:transparent;
  color:var(--ink-2);
  font-size:12px;
  white-space:nowrap;
  cursor:pointer;
  transition:background 0.15s ease, color 0.15s ease;
}
.wb-tab:hover{background:#EBEEF5;color:var(--ink);}
.wb-tab[aria-selected="true"]{
  background:var(--surface);
  color:var(--accent-deep);
  font-weight:600;
  margin-top:-1px;
}
.wb-tab[aria-selected="true"]::after{
  content:"";
  position:absolute;
  left:0;right:0;bottom:0;
  height:3px;
  background:var(--accent);
}
.wb-tab.is-disabled{display:flex;align-items:center;color:#9AA2B1;cursor:not-allowed;}
.wb-tab.is-disabled:hover{background:transparent;color:#9AA2B1;}
.wb-tab:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;}
.wb-tab-add{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  padding:0 14px;
  color:var(--ink-3);
  font-size:18px;
  line-height:1;
}

/* ---------------- status bar ---------------- */
.wb-status{
  display:flex;
  align-items:center;
  gap:16px;
  padding:3px 14px;
  background:var(--accent-deep);
  color:rgba(255,255,255,0.86);
  font-size:11px;
  min-height:23px;
}
.wb-status-stats{display:flex;gap:18px;margin-left:auto;font-variant-numeric:tabular-nums;}
.wb-status-stats b{color:#fff;font-weight:600;}
.wb-status-zoom{display:inline-flex;align-items:center;gap:10px;}
.wb-status-stats:empty + .wb-status-zoom{margin-left:auto;}
.wb-zoom-track{position:relative;width:90px;height:2px;background:rgba(255,255,255,0.4);}
.wb-zoom-thumb{position:absolute;left:50%;top:50%;width:4px;height:12px;margin:-6px 0 0 -2px;background:#fff;border-radius:1px;}

/* ---------------- small screens ---------------- */
@media (max-width:720px){
  .wb-notice{padding:10px 16px;}
  .wb-notice-back{margin-left:0;}
  .wb-window{width:100%;margin:0;border-radius:0;border-left:0;border-right:0;min-height:480px;}
  .wb-ribbon-tabs span:nth-child(n+5){display:none;}
  .wb-namebox{flex-basis:72px;}
  .wb-zoom-track{display:none;}
  .wb-status-ready{display:none;}
  .wb-status-stats{margin-left:0;gap:12px;}
}

@media (prefers-reduced-motion:reduce){
  .wb-tab{transition:none;}
}
