:root {
    --excel-green: #107c41;
    --excel-green-dark: #0f5f31;
    --chrome: #f3f2f1;
    --chrome-dark: #e1dfdd;
    --grid-line: #d9e1f2;
    --header-fill: #d9ead3;
    --column-fill: #eef2f8;
    --row-fill: #eef2f8;
    --text: #1f2933;
    --muted: #5f6b7a;
    --active: #217346;
    --vat: #fff7d6;
    --missing: #fff1f0;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    background: #ffffff;
    font: 13px/1.35 Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

.excel-app {
    height: 100vh;
    display: grid;
    grid-template-rows: 34px 92px 34px minmax(0, 1fr) 28px;
    background: #ffffff;
    overflow: hidden;
}

.excel-titlebar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    background: var(--excel-green);
    color: #ffffff;
    min-width: 0;
}

.excel-titlebar strong {
    font-size: 13px;
    white-space: nowrap;
}

.excel-titlebar span:last-child {
    color: #dff3e7;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.window-controls {
    display: flex;
    gap: 6px;
}

.window-controls span {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .5);
}

.excel-ribbon {
    border-bottom: 1px solid #c8c6c4;
    background: var(--chrome);
    min-width: 0;
}

.ribbon-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 32px;
    padding: 0 10px;
    border-bottom: 1px solid var(--chrome-dark);
}

.ribbon-tabs button {
    border: 0;
    background: transparent;
    color: #323130;
    height: 32px;
    padding: 0 13px;
    cursor: default;
}

.ribbon-tabs .active {
    background: #ffffff;
    color: var(--excel-green-dark);
    font-weight: 700;
    border-left: 1px solid var(--chrome-dark);
    border-right: 1px solid var(--chrome-dark);
}

.ribbon-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 60px;
    padding: 8px 10px;
    overflow: hidden;
}

.ribbon-field {
    display: grid;
    gap: 3px;
    width: 260px;
    flex: none;
}

.ribbon-field span {
    color: var(--muted);
    font-size: 11px;
}

.ribbon-field select,
.excel-search {
    height: 28px;
    border: 1px solid #b8c2d1;
    background: #ffffff;
    color: var(--text);
    padding: 0 8px;
    min-width: 0;
}

.excel-file-button,
.excel-command {
    height: 34px;
    border: 1px solid #aeb8c8;
    background: #ffffff;
    color: var(--text);
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    white-space: nowrap;
}

.excel-file-button input {
    display: none;
}

.excel-command.primary {
    background: var(--excel-green);
    border-color: var(--excel-green);
    color: #ffffff;
    font-weight: 700;
}

.excel-search {
    width: min(280px, 20vw);
}

.summary-strip {
    display: flex;
    align-items: stretch;
    gap: 6px;
    margin-left: auto;
    min-width: 0;
}

.summary-strip span {
    min-width: 76px;
    border-left: 1px solid var(--chrome-dark);
    padding: 2px 8px;
}

.summary-strip small,
.summary-strip strong {
    display: block;
    white-space: nowrap;
}

.summary-strip small {
    color: var(--muted);
    font-size: 10px;
}

.summary-strip strong {
    font-size: 13px;
}

.formula-bar {
    display: grid;
    grid-template-columns: 82px 34px minmax(0, 1fr);
    align-items: center;
    background: #fafafa;
    border-bottom: 1px solid #c8c6c4;
}

.formula-bar span,
.formula-bar strong {
    height: 100%;
    display: grid;
    place-items: center;
    border-right: 1px solid #d0d7de;
    color: var(--muted);
}

.formula-bar input {
    height: 100%;
    border: 0;
    padding: 0 10px;
    min-width: 0;
}

.workbook {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) 36px;
    background: #ffffff;
}

.sheet-frame {
    min-height: 0;
    overflow: auto;
    background: #ffffff;
}

.excel-grid {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    width: max-content;
    min-width: 100%;
}

.excel-grid th,
.excel-grid td {
    border-right: 1px solid var(--grid-line);
    border-bottom: 1px solid var(--grid-line);
    height: 24px;
    padding: 3px 6px;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.excel-grid thead th {
    position: sticky;
    top: 0;
    z-index: 9;
    background: var(--column-fill);
    color: #344054;
    text-align: center;
    font-weight: 700;
    height: 24px;
}

.row-col,
.corner,
.row-head {
    width: 46px;
    min-width: 46px;
}

.excel-grid .corner,
.excel-grid .row-head {
    position: sticky;
    left: 0;
    z-index: 8;
    background: var(--row-fill);
    color: #526070;
    text-align: center;
    font-weight: 700;
}

.excel-grid thead .corner {
    z-index: 12;
}

.pmkt-info-row td {
    background: #ffffff;
    font-weight: 600;
}

.pmkt-title-row td {
    background: #ffffff;
}

.company-title {
    color: #1f4e79;
}

.sheet-title {
    text-align: center;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0;
}

.unit-note {
    text-align: center;
    font-style: italic;
}

.pmkt-header-row td {
    background: var(--header-fill);
    color: #1f4e2d;
    text-align: center;
    font-weight: 800;
    white-space: normal;
}

.pmkt-header-row.bottom td {
    background: #f8fbf7;
    color: #344054;
}

.pmkt-header-row .description-head {
    text-align: left;
    padding-left: 12px;
}

.excel-grid tbody td {
    background: #ffffff;
}

.excel-grid tbody tr.vat-row td {
    background: var(--vat);
}

.excel-grid tbody tr.missing-row td {
    background: var(--missing);
}

.excel-grid tbody tr:hover td {
    background-image: linear-gradient(rgba(33, 115, 70, .08), rgba(33, 115, 70, .08));
}

.excel-grid td[data-field] {
    outline: none;
}

.excel-grid td[data-field]:focus,
.excel-grid td.active {
    box-shadow: inset 0 0 0 2px var(--active);
    background: #ffffff;
}

.center {
    text-align: center;
}

.formula-cell {
    color: #1f2933;
    font-weight: 700;
}

.text-cell {
    white-space: nowrap;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.date {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.sheet-tabs {
    display: flex;
    align-items: end;
    gap: 2px;
    padding: 0 10px;
    border-top: 1px solid #c8c6c4;
    background: #f3f2f1;
    overflow-x: auto;
}

.sheet-tabs button {
    height: 29px;
    min-width: 82px;
    border: 1px solid #c8c6c4;
    border-bottom: 0;
    background: #e8e8e8;
    color: #323130;
    padding: 0 12px;
    white-space: nowrap;
    cursor: pointer;
}

.sheet-tabs .active {
    background: #ffffff;
    color: var(--excel-green-dark);
    border-top: 2px solid var(--excel-green);
    font-weight: 700;
}

.statusbar {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 10px;
    background: var(--excel-green);
    color: #ffffff;
    min-width: 0;
}

.statusbar span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast {
    position: fixed;
    right: 16px;
    bottom: 42px;
    max-width: min(460px, calc(100vw - 32px));
    padding: 11px 13px;
    background: #1f2933;
    color: #ffffff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .2);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity .16s ease, transform .16s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 860px) {
    .excel-app {
        grid-template-rows: 34px 132px 34px minmax(0, 1fr) 28px;
    }

    .ribbon-tools {
        height: 100px;
        flex-wrap: wrap;
        align-content: start;
    }

    .summary-strip {
        width: 100%;
        margin-left: 0;
        overflow-x: auto;
    }

    .ribbon-field {
        width: min(100%, 300px);
    }
}
