/* sheets.css - aibusinessmanager.au / sheets */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: #1e293b; background: #eef1f5; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
.muted { color: #64748b; }

/* top bar */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px;
       padding: 10px 18px; background: #0f172a; color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; }
.brand small { display: block; font-weight: 400; font-size: 11.5px; color: #94a3b8; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: #15803d; display: grid; place-items: center; font-weight: 800; }
.top nav { display: flex; gap: 8px; }
.btn { border: 1px solid #15803d; background: #15803d; color: #fff; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: #475569; color: inherit; }
.top .btn.ghost { color: #e2e8f0; }
.btn.small { padding: 5px 10px; font-size: 13.5px; }
.btn.danger, button.danger { color: #b91c1c; }
.btn.ghost.danger { border-color: #fca5a5; }

/* list */
.list-view { max-width: 880px; margin: 0 auto; padding: 24px 18px 60px; }
.intro h1 { margin: 0 0 6px; font-size: 24px; }
.intro p { margin: 6px 0; max-width: 70ch; }
.doc-list { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.doc { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center; background: #fff; border: 1px solid #e2e8f0;
       border-radius: 10px; padding: 12px 14px; }
.doc .name { font-weight: 650; font-size: 16px; color: #0f172a; cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.doc .name:hover { text-decoration: underline; }
.doc .meta { grid-column: 1; font-size: 13px; color: #64748b; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.doc .acts { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: center; gap: 8px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: #e2e8f0; color: #334155; }
.tag.kept { background: #ccfbf1; color: #115e59; }
.tag.warn { background: #fee2e2; color: #991b1b; }
.empty { background: #fff; border: 1px dashed #cbd5e1; border-radius: 10px; padding: 30px; text-align: center; }
.counts { margin-top: 14px; font-size: 13px; }

.docbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; max-width: 860px; width: 100%; margin: 16px auto 0; padding: 0 18px; }
.title { flex: 1 1 260px; min-width: 0; font-size: 20px; font-weight: 700; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; background: transparent; }
.title:hover, .title:focus { border-color: #cbd5e1; background: #fff; outline: none; }
.docbar-r { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.save-state { font-size: 13px; color: #64748b; min-width: 70px; text-align: right; }
.save-state.bad { color: #b91c1c; font-weight: 600; }
.keep { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; cursor: pointer; padding: 4px 10px; border-radius: 99px; border: 1px solid #cbd5e1; background: #fff; }
.keep:has(input:checked) { background: #ccfbf1; border-color: #5eead4; color: #115e59; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 25; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
             box-shadow: 0 10px 30px rgba(15,23,42,.15); padding: 6px; display: flex; flex-direction: column; min-width: 190px; }
.menu-list button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu-list button:hover { background: #f1f5f9; }
.expiry { max-width: 860px; width: 100%; margin: 2px auto 0; padding: 0 26px; font-size: 13px; color: #64748b; }
.expiry.warn { color: #b91c1c; font-weight: 600; }
.expiry button { border: 0; background: none; color: #15803d; font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline; }
.notice { max-width: 860px; width: calc(100% - 36px); margin: 10px auto 0; padding: 10px 14px; border-radius: 10px; background: #fef3c7; border: 1px solid #fcd34d; font-size: 14px;
          display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.notice.bad { background: #fee2e2; border-color: #fca5a5; }


.toast { position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 9px 16px; border-radius: 10px; z-index: 60; font-size: 14px;
         box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100% - 30px); }
.docbar { max-width: none; margin-top: 10px; }
.expiry, .notice { max-width: none; }
.expiry { padding: 0 26px 6px; }
.notice { width: calc(100% - 36px); }
.keep:has(input:checked) { background: #dcfce7; border-color: #86efac; color: #166534; }
.tag.kept { background: #dcfce7; color: #166534; }

/* the spreadsheet */
.edit-view { display: flex; flex-direction: column; height: calc(100vh - 52px); overflow: hidden; }
.fbar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: #fff; border-top: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0; }
.addr { min-width: 70px; font: 600 13px ui-monospace, Menlo, Consolas, monospace; color: #334155; padding: 4px 8px; border: 1px solid #e2e8f0; border-radius: 6px; text-align: center; }
.fx { font: italic 600 13px Georgia, serif; color: #64748b; }
.finput { flex: 1; min-width: 0; height: 30px; border: 1px solid #e2e8f0; border-radius: 6px; padding: 0 8px; font: 14px ui-monospace, Menlo, Consolas, monospace; }
.finput:focus { outline: 2px solid #86efac; border-color: #22c55e; }
.tb { width: 32px; height: 30px; border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; font-size: 16px; }
.tb:hover { background: #f1f5f9; }

.wrap { position: relative; flex: 1; overflow: auto; background: #fff; outline: none; }
.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; font: 13.5px/1 Arial, sans-serif; user-select: none; -webkit-user-select: none; }
.grid th, .grid td { height: 24px; padding: 0 5px; border-right: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.grid thead th { position: sticky; overflow: visible; top: 0; z-index: 3; background: #f8fafc; color: #475569; font: 600 12px system-ui, sans-serif; text-align: center; cursor: s-resize; }
.grid th.corner { left: 0; z-index: 4; cursor: se-resize; }
.grid td.rh { position: sticky; left: 0; z-index: 3; background: #f8fafc; color: #475569; font: 600 12px system-ui, sans-serif; text-align: center; cursor: e-resize; }
.grid td { color: #0f172a; cursor: cell; }
.grid td.num { text-align: right; }
.grid td.bool, .grid td.err { text-align: center; }
.grid td.err { color: #b91c1c; }
.grid td.in { box-shadow: inset 0 0 0 999px rgba(22,163,74,.13); }
.grid td.act { box-shadow: inset 0 0 0 2px #16a34a; }
.grid th.hl, .grid td.rh.hl { background: #dcfce7; color: #14532d; }
.grid td.pt { box-shadow: inset 0 0 0 999px rgba(37,99,235,.08); }
.grid td.ptT { border-top: 2px dashed #2563eb; } .grid td.ptB { border-bottom: 2px dashed #2563eb; }
.grid td.ptL { border-left: 2px dashed #2563eb; } .grid td.ptR { border-right: 2px dashed #2563eb; }
.grid tr.spacer td { padding: 0; border: 0; height: auto; }
.editor { position: absolute; z-index: 5; margin: 0; padding: 3px 5px; border: 2px solid #16a34a; box-shadow: 0 2px 10px rgba(0,0,0,.15);
          font: 13.5px/1.3 Arial, sans-serif; resize: none; overflow: hidden; background: #fff; outline: none; white-space: pre-wrap; }
.sink { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; pointer-events: none; }

.tabsbar { display: flex; align-items: center; gap: 4px; padding: 4px 10px; background: #f8fafc; border-top: 1px solid #e2e8f0; min-height: 40px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; max-width: 60%; }
.tab { flex: none; height: 30px; padding: 0 12px; border: 1px solid #e2e8f0; border-radius: 6px; background: #fff; cursor: pointer; font-size: 13.5px; white-space: nowrap; }
.tab.on { background: #dcfce7; border-color: #86efac; color: #14532d; font-weight: 700; }
.tab .x { margin-left: 8px; color: #94a3b8; font-weight: 400; }
.tab .x:hover { color: #b91c1c; }
.tab.add { font-weight: 700; width: 32px; padding: 0; }
.tab.more { color: #475569; }
.calc { margin-left: auto; font-size: 12.5px; color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 700px) {
    .top { padding: 8px 10px; }
    .brand small, #navFiles { display: none; }
    .docbar { padding: 0 10px; }
    .expiry { padding: 0 18px 6px; }
    .doc { grid-template-columns: 1fr; }
    .doc .acts { grid-column: 1; grid-row: auto; }
    .edit-view { height: calc(100vh - 48px); height: calc(100dvh - 48px); }
    .tabs { max-width: 45%; }
    .calc { display: none; }
}

/* the formatting toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 5px 12px; background: #fff; border-top: 1px solid #e2e8f0; }
.toolbar .grp { display: flex; align-items: center; gap: 2px; }
.toolbar .grp + .grp { padding-left: 10px; border-left: 1px solid #e2e8f0; }
.toolbar select { height: 30px; border: 1px solid #e2e8f0; border-radius: 6px; padding: 0 6px; background: #fff; font-size: 13.5px; }
.toolbar .tb { display: inline-grid; place-items: center; }
.toolbar .tb.on { background: #dcfce7; border-color: #86efac; }
.toolbar .tb.wide { width: auto; padding: 0 8px; font-size: 13px; }
.toolbar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.sw { font-weight: 800; border-bottom: 4px solid #dc2626; line-height: 1.1; padding: 0 3px; }
.sw.fill { color: #94a3b8; border-bottom-color: #fde047; font-size: 12px; }
.palette { position: fixed; z-index: 50; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 10px 30px rgba(15,23,42,.18); padding: 8px; width: 186px; }
.palette .none { width: 100%; height: 28px; border: 1px solid #e2e8f0; border-radius: 6px; background: #fff; cursor: pointer; margin-bottom: 6px; font-size: 13px; }
.palette .sw-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.palette .sw-grid button { height: 28px; border: 1px solid rgba(0,0,0,.15); border-radius: 6px; cursor: pointer; }
.palette .sw-grid button:hover { outline: 2px solid #16a34a; }
.grid thead th .rz { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 5; }
.grid thead th .rz:hover { background: #86efac; }
body.sizing, body.sizing * { cursor: col-resize !important; }
@media (max-width: 700px) { .toolbar { flex-wrap: nowrap; overflow-x: auto; } .toolbar .grp { flex: none; } .toolbar .tb { display: inline-grid; } }

/* frozen row and column */
.grid { --lh: 25px; }
#frow td { position: sticky; top: var(--lh); z-index: 3; background: #fff; border-bottom: 2px solid #94a3b8; }
#frow td.rh { left: 0; z-index: 4; background: #f8fafc; }
.grid td.fc, .grid th.fc { position: sticky; left: 48px; z-index: 1; background: #fff; border-right: 2px solid #94a3b8; }
.grid th.fc { z-index: 4; background: #f8fafc; }
#frow td.fc { z-index: 4; }
.grid td.rh.gap { box-shadow: inset 0 -3px 0 #2563eb; color: #1d4ed8; }

/* filter buttons and box */
.grid td .fbtn { float: right; margin: 2px -2px 0 4px; width: 18px; height: 18px; line-height: 17px; text-align: center; border: 1px solid #cbd5e1; border-radius: 4px;
                 background: #fff; color: #334155; font: 700 11px system-ui, sans-serif; cursor: pointer; }
.grid td .fbtn.on { background: #2563eb; border-color: #2563eb; color: #fff; }
.fpop { position: fixed; z-index: 55; width: 260px; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 12px 34px rgba(15,23,42,.2); padding: 10px;
        display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.fp-sort { display: flex; gap: 6px; }
.fp-sort button { flex: 1; height: 30px; border: 1px solid #e2e8f0; border-radius: 6px; background: #f8fafc; cursor: pointer; }
.fp-find { height: 30px; border: 1px solid #cbd5e1; border-radius: 6px; padding: 0 8px; }
.fp-list { max-height: 240px; overflow: auto; border: 1px solid #f1f5f9; border-radius: 6px; padding: 4px 6px; display: flex; flex-direction: column; }
.fp-list label, .fp-all { display: flex; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-list label .muted { margin-left: auto; font-size: 12px; }
.fp-foot { display: flex; gap: 6px; align-items: center; }

/* right-click menu */
.cmenu { position: fixed; z-index: 56; min-width: 230px; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 12px 34px rgba(15,23,42,.2); padding: 6px;
         display: flex; flex-direction: column; }
.cmenu button { text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.cmenu button:hover { background: #f1f5f9; }
.cmenu hr { border: 0; border-top: 1px solid #e2e8f0; margin: 4px 0; }

/* opening files */
.open-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 14px; font-size: 13.5px; }
.list-view .open-row .btn.ghost { color: #15803d; border-color: #86efac; background: #fff; }

/* printing: only the print table */
.print-area { display: none; }
@media print {
    body > *:not(.print-area) { display: none !important; }
    body { background: #fff; }
    .print-area { display: block; font: 10.5pt Arial, sans-serif; color: #000; }
    .ptitle { font-weight: 700; font-size: 12pt; margin-bottom: 8px; }
    .ptable { border-collapse: collapse; table-layout: fixed; max-width: 100%; }
    .ptable th { background: #f1f5f9; color: #475569; font-weight: 600; font-size: 9pt; border: 1px solid #cbd5e1; padding: 2px 4px; }
    .ptable td { border: 1px solid #e2e8f0; padding: 2px 5px; white-space: nowrap; overflow: hidden; height: 18px; }
    .ptable td.num { text-align: right; } .ptable td.bool, .ptable td.err { text-align: center; }
    .ptable thead { display: table-header-group; }
    .ptable tr { break-inside: avoid; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* charts */
.chart-layer { position: absolute; top: 0; left: 0; width: 0; height: 0; z-index: 2; }
.chart { position: absolute; background: #fff; border: 1px solid #cbd5e1; border-radius: 6px; box-shadow: 0 2px 10px rgba(15,23,42,.10); cursor: move; touch-action: none; overflow: hidden; }
.chart svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.chart.on { outline: 2px solid #16a34a; outline-offset: 1px; }
.chart-rz { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize;
            background: linear-gradient(135deg, transparent 50%, #94a3b8 50%, #94a3b8 60%, transparent 60%, transparent 70%, #94a3b8 70%, #94a3b8 80%, transparent 80%); }
.chart-panel { position: fixed; z-index: 57; width: 250px; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 12px 34px rgba(15,23,42,.2); padding: 10px;
               display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; }
.cp-row { display: flex; gap: 6px; flex-wrap: wrap; }
.cp-kinds button { flex: 1; height: 30px; border: 1px solid #e2e8f0; border-radius: 6px; background: #f8fafc; cursor: pointer; font-size: 13px; }
.cp-kinds button.on { background: #dcfce7; border-color: #86efac; color: #14532d; font-weight: 700; }
.cp-field { display: flex; flex-direction: column; gap: 3px; color: #475569; font-size: 12.5px; }
.cp-field input { height: 30px; border: 1px solid #cbd5e1; border-radius: 6px; padding: 0 8px; font-size: 14px; color: #0f172a; }
.cp-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.toolbar .chart-btn { color: #15803d; font-weight: 700; }
@media print { .pchart { margin-top: 14px; break-inside: avoid; } .pchart svg { max-width: 100%; height: auto; } }

.who { color: #e2e8f0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; align-self: center; }
.top nav { align-items: center; }
.top a.btn { text-decoration: none; display: inline-block; }
.intro a { color: #0f766e; font-weight: 600; }
@media (max-width: 700px) { .who { display: none; } }
