/* Spud & Root: retail/production/index.html, BACK TO EXCEL (packaging-excel.js).
   A plain, generic spreadsheet app: title bar, menus, toolbar, formula
   bar, the grid with a frozen header row, sheet tabs, status bar. On a
   phone it slims down to a phone spreadsheet app's chrome. */

/* The sheet's own full-screen layer, so any page can put it up. */
.pk-excel {
  position: fixed;
  z-index: 1000;
  inset: 0;
  background: #fff;
  color: #222;
  -webkit-user-select: text;
  user-select: text;
}
.pk-excel[hidden] { display: none; }


.xl {
  --xl-accent: #1f6e43;
  --xl-accent-dark: #185836;
  --xl-line: #d4d4d4;
  --xl-head: #f3f3f3;
  --xl-sel: #1f6e43;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #222;
  font: 13px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}
.xl button { font: inherit; color: inherit; cursor: default; }

/* title bar */
.xl-top {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: env(safe-area-inset-top) 12px 0;
  background: var(--xl-accent);
  color: #fff;
  flex: none;
}
.xl-icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background:
    linear-gradient(#fff, #fff) 6px 5px / 12px 1.5px no-repeat,
    linear-gradient(#fff, #fff) 6px 10px / 12px 1.5px no-repeat,
    linear-gradient(#fff, #fff) 6px 15px / 12px 1.5px no-repeat,
    linear-gradient(#fff, #fff) 11px 4px / 1.5px 14px no-repeat,
    var(--xl-accent-dark);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.7);
}
.xl-file { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xl-file b { font-weight: 600; }
.xl-ext { opacity: 0.85; }
.xl-saved { font-size: 12px; opacity: 0.8; }
.xl-saved::before { content: "· "; }
.xl-who {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #c7a76a;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* menus and toolbar */
.xl-menus {
  display: flex;
  gap: 2px;
  padding: 0 8px;
  background: #fff;
  border-bottom: 1px solid #e3e3e3;
  flex: none;
  overflow: hidden;
}
.xl-menu {
  padding: 8px 10px 7px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  white-space: nowrap;
}
.xl-menu--on { border-bottom-color: var(--xl-accent); color: var(--xl-accent); font-weight: 600; }
.xl-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 40px;
  padding: 0 8px;
  background: #fafafa;
  border-bottom: 1px solid #e0e0e0;
  flex: none;
  overflow: hidden;
}
.xl-tool {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  white-space: nowrap;
}
.xl-tool:hover { background: #e9e9e9; border-color: #d6d6d6; }
.xl-tool--icon { font-size: 16px; }
.xl-tool--font, .xl-tool--size, .xl-tool--fmt { border-color: #cfcfcf; background: #fff; text-align: left; }
.xl-tool--font { width: 118px; }
.xl-tool--fmt { width: 96px; }
.xl-tool--b { font-weight: 800; }
.xl-tool--i { font-style: italic; font-family: Georgia, serif; }
.xl-tool--u { text-decoration: underline; }
.xl-tool--fill::before {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  margin: 0 auto;
  border: 1px solid #555;
  border-bottom: 4px solid #ffd54a;
  border-radius: 2px;
  background: #fff;
}
.xl-tool--color { font-weight: 700; text-decoration: underline 3px #d6322b; }
.xl-sep { width: 1px; height: 22px; margin: 0 5px; background: #ddd; flex: none; }

/* formula bar */
.xl-fbar {
  display: flex;
  align-items: center;
  height: 28px;
  border-bottom: 1px solid #d9d9d9;
  background: #fff;
  flex: none;
}
.xl-name {
  width: 88px;
  height: 100%;
  padding: 0 8px;
  line-height: 28px;
  border-right: 1px solid #d9d9d9;
  box-sizing: border-box;
}
.xl-fx {
  padding: 0 10px;
  color: #888;
  font-style: italic;
  font-family: Georgia, serif;
  border-right: 1px solid #e6e6e6;
}
.xl-formula {
  flex: 1;
  min-width: 0;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-user-select: text;
  user-select: text;
}

/* the grid */
.xl-grid {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #fff;
  outline: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.xl-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: max-content;
}
.xl-table th, .xl-table td {
  height: 22px;
  padding: 0 6px;
  box-sizing: border-box;
  border-right: 1px solid var(--xl-line);
  border-bottom: 1px solid var(--xl-line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.xl-corner, .xl-colh, .xl-rowh {
  background: var(--xl-head);
  color: #555;
  font-weight: 400;
  text-align: center;
  border-color: #c8c8c8;
}
.xl-corner { position: sticky; top: 0; left: 0; z-index: 4; }
.xl-colh { position: sticky; top: 0; z-index: 3; }
.xl-rowh { position: sticky; left: 0; z-index: 2; font-size: 12px; }
.xl-colh--on, .xl-rowh--on { background: #dfe9e3; color: var(--xl-accent); font-weight: 600; border-bottom-color: var(--xl-accent); }

.xl-c { background: #fff; }
.xl-c--num { text-align: right; font-variant-numeric: tabular-nums; }
.xl-c--odd { background: #f4f8f5; }
.xl-c--title { height: 34px; font-size: 20px; font-weight: 700; color: var(--xl-accent-dark); border-bottom: 2px solid var(--xl-accent) !important; }
.xl-r--title .xl-rowh { height: 34px; }
.xl-c--note { color: #666; font-style: italic; }
.xl-c--foot { color: #555; font-size: 12px; }
.xl-r--head td.xl-c--hd {
  background: var(--xl-accent);
  color: #fff;
  font-weight: 600;
  border-right-color: #2f8a57;
}
.xl-frozen td, .xl-frozen th { position: sticky; top: 22px; z-index: 2; }
.xl-frozen th { z-index: 3; }
.xl-frozen td { box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12); }
.xl-r--total td { font-weight: 700; border-top: 1px solid #333; border-bottom: 3px double #333; background: #eef4ef; }
.xl-c--tbd { color: #b25a00; font-style: italic; position: relative; }
.xl-c--tbd::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-top: 6px solid #d6322b;
  border-left: 6px solid transparent;
}
.xl-c--key { font-weight: 600; box-shadow: inset 4px 0 0 var(--xl-key, #999); }
.xl-c--key-gold { --xl-key: #ffb81b; }
.xl-c--key-red { --xl-key: #ff4438; }
.xl-c--key-russet { --xl-key: #bc6124; }
.xl-c--key-white { --xl-key: #5fb4e6; }
.xl-c--key-herb { --xl-key: #6b9a2e; }
.xl-c--key-rich { --xl-key: #7e5a8c; }
.xl-c--key-kraft, .xl-c--key-wood { --xl-key: #c79d66; }
.xl-r--layer .xl-rowh { height: 150px; }
.xl-c--pic { height: 150px; padding: 10px 12px; }
.xl-fig { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; margin-right: 28px; vertical-align: top; }
.xl-fig__cap { font-size: 12px; color: #555; }
/* 48 x 40 in: two bags lengthwise (24 x 16) along one side, three crosswise (16 x 24) beside them */
.xl-layer {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: 2fr 3fr;
  gap: 2px;
  width: 144px;
  height: 120px;
  padding: 2px;
  box-sizing: border-box;
  border: 1px solid #9b6c3a;
  background: #c99a62;
}
.xl-layer--turned { transform: rotate(180deg); }
.xl-bag { border: 1px solid #7a5530; border-radius: 3px; background: #dbb987; }
.xl-bag--a { grid-column: 1 / 4; }
.xl-bag--b { grid-column: 4 / 7; background: #c79d66; }
.xl-bag--c { grid-column: 1 / 3; background: #c79d66; }
.xl-bag--d { grid-column: 3 / 5; }
.xl-bag--e { grid-column: 5 / 7; background: #c79d66; }
.xl-c--b { font-weight: 700; }
.xl-c--i { font-style: italic; }
.xl-c--u { text-decoration: underline; }
.xl-c--fill { background: #fff3b0 !important; }

.xl-c--in { background-color: #e3efe7 !important; }
.xl-c--sel { outline: 2px solid var(--xl-sel); outline-offset: -2px; background-color: #fff !important; }

/* tabs and status */
.xl-bottom {
  display: flex;
  align-items: stretch;
  height: 32px;
  border-top: 1px solid #d0d0d0;
  background: #f3f3f3;
  flex: none;
}
.xl-add { width: 34px; border: 0; border-right: 1px solid #d0d0d0; background: none; font-size: 18px; color: #555; }
.xl-tabs { display: flex; overflow-x: auto; scrollbar-width: none; }
.xl-tabs::-webkit-scrollbar { display: none; }
.xl-tab {
  padding: 0 16px;
  border: 0;
  border-right: 1px solid #d0d0d0;
  background: none;
  white-space: nowrap;
  color: #444;
  cursor: pointer !important;
}
.xl-tab:hover { background: #e8e8e8; }
.xl-tab--on { background: #fff; color: var(--xl-accent); font-weight: 600; box-shadow: inset 0 -3px 0 var(--xl-accent); }
.xl-tab:focus-visible, .xl-grid:focus-visible { outline: 2px solid var(--xl-accent); outline-offset: -2px; }
.xl-status {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 24px;
  padding: 0 12px calc(env(safe-area-inset-bottom));
  background: var(--xl-accent);
  color: #fff;
  font-size: 12px;
  flex: none;
}
.xl-stats { margin-left: auto; white-space: pre; }
.xl-zoom { white-space: pre; opacity: 0.9; }

/* a phone's spreadsheet app: less chrome, bigger touch rows */
@media (max-width: 700px) {
  .xl { font-size: 14px; }
  .xl-top { height: 46px; }
  .xl-saved, .xl-menus .xl-menu:nth-child(n+5) { display: none; }
  .xl-wide, .xl-sep { display: none; }
  .xl-tools { height: 44px; gap: 4px; overflow-x: auto; }
  .xl-tool { min-width: 36px; height: 34px; }
  .xl-table th, .xl-table td { height: 30px; }
  .xl-frozen td, .xl-frozen th { top: 30px; }
  .xl-name { width: 64px; }
  .xl-fbar { height: 34px; }
  .xl-name { line-height: 34px; }
  .xl-bottom { height: 40px; }
  .xl-zoom { display: none; }
  .xl-status { height: auto; min-height: 22px; }
}
