:root {
    --closing-green: #08773d;
    --closing-green-dark: #056332;
    --closing-border: #dde3df;
    --closing-muted: #66716b;
    --closing-text: #171c19;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--closing-text);
    background: #f6f8f7;
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

body {
    margin: 0;
    overflow-x: hidden;
    background: #f6f8f7;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

button,
input,
select,
textarea { font: inherit; }

button { outline: 0; }

.closing-main {
    min-width: 780px;
    min-height: 100vh;
    margin-right: 0;
    padding: 18px 17px 14px;
    transition: margin-right .22s ease;
}

body.drawer-open .closing-main { margin-right: 372px; }

.page-header-block { margin: 0 4px 16px; }

.page-header-block h1 {
    margin: 0 0 7px;
    color: #101512;
    font-size: 25px;
    font-weight: 700;
    line-height: 1.2;
}

.breadcrumb-line {
    display: flex;
    align-items: center;
    gap: 13px;
    color: #68736d;
    font-size: 13px;
}

.breadcrumb-line i {
    color: #a3aaa6;
    font-style: normal;
}

.panel {
    border: 1px solid var(--closing-border);
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 2px 7px rgba(32, 59, 44, .07);
}

.filter-panel {
    display: grid;
    grid-template-columns: minmax(190px, 1.15fr) minmax(155px, .95fr) minmax(160px, .95fr) minmax(190px, 1fr) minmax(178px, .93fr);
    align-items: end;
    gap: 24px;
    min-height: 112px;
    padding: 14px 12px 13px 22px;
}

.filter-field,
.drawer-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
}

.filter-field label,
.drawer-field label {
    margin: 0;
    color: #242a26;
    font-size: 13px;
    font-weight: 500;
}

.filter-field input,
.filter-field select,
.drawer-field input,
.drawer-field select,
.drawer-field textarea {
    width: 100%;
    height: 40px;
    border: 1px solid #d1d8d4;
    border-radius: 6px;
    outline: 0;
    background: #fff;
    color: #29312d;
}

.filter-field input,
.drawer-field input,
.drawer-field textarea { padding: 8px 12px; }

.filter-field select,
.drawer-field select {
    padding: 7px 34px 7px 12px;
    background-image: linear-gradient(45deg, transparent 50%, #67716b 50%), linear-gradient(135deg, #67716b 50%, transparent 50%);
    background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
    background-repeat: no-repeat;
    background-size: 5px 5px, 5px 5px;
    appearance: none;
}

.filter-field input:focus,
.filter-field select:focus,
.drawer-field input:focus,
.drawer-field select:focus,
.drawer-field textarea:focus {
    border-color: var(--closing-green);
    box-shadow: 0 0 0 3px rgba(8, 119, 61, .1);
}

.control-with-icon { position: relative; }

.control-with-icon input { padding-right: 36px; }

.control-with-icon > .glyphicon {
    position: absolute;
    top: 50%;
    right: 12px;
    color: #66736c;
    transform: translateY(-50%);
    pointer-events: none;
}

.sync-state {
    display: flex;
    min-height: 68px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-pill i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-pill.compiling { background: #fff1df; color: #bb6309; }
.status-pill.completed { background: #e9f5eb; color: #147940; }

.sync-state small {
    color: #6c7771;
    font-size: 12px;
    line-height: 1.55;
    white-space: nowrap;
}

.sync-state small b { color: #6c7771; }

.filter-actions {
    display: flex;
    min-width: 174px;
    flex-direction: column;
    gap: 8px;
}

.button {
    display: inline-flex;
    height: 38px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 0 14px;
    border: 1px solid #ccd4cf;
    border-radius: 7px;
    background: #fff;
    color: #202723;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.button:hover { border-color: #9dacA3; background: #f8faf9; }
.button:focus-visible { box-shadow: 0 0 0 3px rgba(8, 119, 61, .16); }
.button:disabled { cursor: default; opacity: .65; }

.button.primary {
    border-color: var(--closing-green);
    background: linear-gradient(180deg, #0a8245, #056c37);
    color: #fff;
}

.button.primary:hover { background: var(--closing-green-dark); }
.button.secondary { font-size: 12px; }
.button.secondary .glyphicon { font-size: 13px; }

.summary-grid {
    display: grid;
    grid-template-columns: 223fr 212fr 232fr 159fr 203fr;
    gap: 13px;
    margin: 17px 0 14px;
}

.summary-card {
    display: flex;
    min-width: 0;
    min-height: 88px;
    align-items: center;
    gap: 16px;
    padding: 13px 17px;
    border: 1px solid var(--closing-border);
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 2px 7px rgba(32, 59, 44, .06);
}

.summary-icon {
    position: relative;
    display: inline-flex;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 23px;
}

.summary-icon.green { background: #eaf6ed; color: #168044; }
.summary-icon.blue { background: #ecf5ff; color: #1d72d8; }
.summary-icon.violet { background: #f5eaff; color: #922eea; }
.summary-icon.orange { background: #fff2e6; color: #fb790e; }

.summary-icon i {
    position: absolute;
    top: 10px;
    right: 8px;
    font-size: 14px;
    font-style: normal;
    font-weight: 700;
}

.summary-card > div { min-width: 0; }

.summary-card > div > span {
    display: block;
    overflow: hidden;
    color: #1e2521;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.summary-card strong {
    display: block;
    margin-top: 3px;
    color: #151a17;
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
}

.compact-card { padding-right: 10px; padding-left: 13px; gap: 12px; }

.total-card {
    gap: 10px;
    padding-right: 10px;
    padding-left: 12px;
    border-color: #92c89d;
    background: linear-gradient(120deg, #f3fbf4, #fff);
}

.summary-card:nth-child(3) {
    gap: 10px;
    padding-right: 10px;
    padding-left: 14px;
}

.summary-card:nth-child(3) > div > span { font-size: 12px; }

.total-card > div > span,
.total-card strong { color: #067438; }

.total-card > div > span { font-weight: 700; }

.department-panel,
.guest-panel { padding: 15px 14px 7px; }

.guest-panel { margin-top: 0; padding-bottom: 9px; }

.section-heading {
    display: flex;
    min-height: 28px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 0 3px;
}

.section-heading h2 {
    margin: 0;
    color: #151a17;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.25;
}

.section-heading p {
    margin: 4px 0 0;
    color: #6d7771;
    font-size: 12px;
}

.table-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 2px 10px;
}

.search-box {
    position: relative;
    display: block;
    width: 42%;
    min-width: 270px;
    margin: 0;
}

.search-box input {
    width: 100%;
    height: 36px;
    padding: 7px 38px 7px 14px;
    border: 1px solid #d0d7d3;
    border-radius: 7px;
    outline: 0;
}

.search-box input:focus {
    border-color: var(--closing-green);
    box-shadow: 0 0 0 3px rgba(8, 119, 61, .1);
}

.search-box .glyphicon {
    position: absolute;
    top: 50%;
    right: 13px;
    color: #69756e;
    font-size: 15px;
    transform: translateY(-50%);
}

.filter-button { height: 36px; padding: 0 14px; }

.table-scroll {
    overflow: auto;
    border: 1px solid #dbe1dd;
    border-radius: 7px;
}

.data-table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    background: #fff;
    table-layout: fixed;
}

.data-table th,
.data-table td {
    height: 37px;
    padding: 7px 9px;
    border-right: 1px solid #dfe4e1;
    border-bottom: 1px solid #dfe4e1;
    color: #1f2622;
    font-size: 12px;
    line-height: 1.25;
    text-align: center;
    vertical-align: middle;
}

.department-table td {
    height: 34px;
    padding-top: 4px;
    padding-bottom: 4px;
}

.data-table th {
    height: 34px;
    background: #fbfcfb;
    font-weight: 700;
}

.data-table th:last-child,
.data-table td:last-child { border-right: 0; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fafcfb; }
.data-table .text-left { text-align: left; }
.data-table .col-index { width: 45px; }

.department-table th:nth-child(2) { width: 16%; }
.department-table th:nth-child(3) { width: 14%; }
.department-table th:nth-child(4) { width: 14%; }
.department-table th:nth-child(5),
.department-table th:nth-child(6) { width: 11%; }
.department-table th:nth-child(7) { width: 12%; }
.department-table th:nth-child(8) { width: 9%; }
.department-table th:nth-child(9) { width: 14%; }

.department-table tfoot td {
    height: 37px;
    border-top: 1px solid #b8d8bf;
    border-bottom: 0;
    background: linear-gradient(180deg, #f1f8f2, #eaf5ec);
    font-size: 13px;
    font-weight: 700;
}

.state-badge,
.source-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 25px;
    padding: 4px 9px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.state-badge.ok,
.source-badge.registered { background: #e8f5e9; color: #147a40; }
.state-badge.waiting { background: #fff2df; color: #e87009; }
.state-badge.adjusted { background: #fff0e4; color: #f06a00; }
.state-badge.added,
.source-badge.added { background: #f1e8ff; color: #732be1; }
.state-badge .glyphicon { font-size: 13px; }

.guest-heading { align-items: center; padding-bottom: 10px; }
.outline-success { border-color: #12804a; color: #08733d; }
.outline-success:hover { border-color: #08733d; background: #f0f8f3; }
.guest-table { min-width: 980px; }
.guest-table th {
    padding-right: 5px;
    padding-left: 5px;
    white-space: nowrap;
}

.guest-table td {
    height: 34px;
    padding-top: 4px;
    padding-bottom: 4px;
}
.guest-table th:first-child { width: 20%; }
.guest-table th:nth-child(2) { width: 14%; }
.guest-table th:nth-child(3) { width: 14%; }
.guest-table th:nth-child(4),
.guest-table th:nth-child(5) { width: 8%; }
.guest-table th:nth-child(6) { width: 10%; }
.guest-table th:nth-child(7) { width: 11%; }
.guest-table th:nth-child(8) { width: 12%; }
.guest-table th:nth-child(9) { width: 8%; }

.adjustment-value.negative { color: #ed5c00; }
.adjustment-value.positive { color: #087ad8; }

.edit-row-button {
    width: 31px;
    height: 29px;
    padding: 0;
    border: 1px solid #d4dbd7;
    border-radius: 6px;
    background: #fff;
    color: #1d2922;
    cursor: pointer;
}

.edit-row-button:hover { border-color: #77aa87; color: var(--closing-green); }

.page-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 15px 0 0;
    color: #6d7771;
    font-size: 13px;
}

.page-note .glyphicon { color: #68736d; font-size: 16px; }

.adjustment-drawer {
    position: fixed;
    z-index: 50;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    width: 372px;
    flex-direction: column;
    border-left: 1px solid #dfe4e1;
    background: #fff;
    box-shadow: -6px 0 18px rgba(23, 48, 33, .12);
    transform: translateX(100%);
    transition: transform .22s ease;
}

body.drawer-open .adjustment-drawer { transform: translateX(0); }

.drawer-header {
    display: flex;
    min-height: 65px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 20px;
}

.drawer-header h2 {
    margin: 0;
    color: #171c19;
    font-size: 20px;
    font-weight: 700;
}

.icon-button {
    width: 35px;
    height: 35px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #44514a;
    font-size: 28px;
    font-weight: 300;
    line-height: 32px;
    cursor: pointer;
}

.icon-button:hover { color: #0b6f3b; }

#adjustmentForm {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
}

.drawer-body {
    min-height: 0;
    flex: 1;
    padding: 0 20px 14px;
    overflow-y: auto;
}

.drawer-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
    padding: 11px 13px;
    border: 1px solid #9dcea8;
    border-radius: 6px;
    background: linear-gradient(120deg, #f0f8f1, #fbfdfb);
    color: #215e39;
}

.drawer-info > .glyphicon { margin-top: 2px; font-size: 18px; }

.drawer-info p {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
}

.drawer-field { margin-bottom: 14px; }

.drawer-field input[readonly] {
    background: #f8f9f8;
    color: #3b4540;
}

.drawer-control input { padding-right: 37px; }

.linked-control {
    position: relative;
    display: flex;
}

.linked-control input { padding-right: 100px; }

.linked-control button {
    position: absolute;
    top: 0;
    right: 0;
    height: 40px;
    padding: 0 13px;
    border: 0;
    background: transparent;
    color: #06708c;
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
}

.drawer-field textarea {
    height: 67px;
    padding-bottom: 23px;
    resize: none;
    line-height: 1.35;
}

.textarea-wrap { position: relative; }

.textarea-wrap > span {
    position: absolute;
    right: 10px;
    bottom: 7px;
    color: #727c76;
    font-size: 11px;
}

.textarea-wrap b { font-weight: 400; }

.adjuster {
    margin: 1px 0 0;
    color: #48534d;
    font-size: 13px;
}

.adjuster strong { font-weight: 400; }

.drawer-message {
    margin: -5px 0 12px;
    padding: 9px 11px;
    border: 1px solid #efb4ae;
    border-radius: 6px;
    background: #fff3f2;
    color: #a3352a;
    font-size: 12px;
}

.drawer-footer {
    display: grid;
    grid-template-columns: 104px 1fr;
    gap: 14px;
    padding: 12px 20px 20px;
    border-top: 1px solid #edf0ee;
    background: #fff;
}

.drawer-footer .button { height: 43px; }
.cancel-button { font-size: 14px; }
.save-button { font-size: 14px; }

.closing-toast {
    position: fixed;
    z-index: 100;
    right: 24px;
    bottom: 24px;
    max-width: 360px;
    padding: 11px 16px;
    border-radius: 7px;
    background: #164b31;
    color: #fff;
    box-shadow: 0 5px 18px rgba(14, 45, 29, .25);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: .2s ease;
}

.closing-toast.error { background: #a33a31; }
.closing-toast.show { opacity: 1; transform: translateY(0); }

.drawer-backdrop { display: none; }

@media (max-width: 1320px) {
    .filter-panel { grid-template-columns: 1.1fr .9fr .9fr 1fr; gap: 14px; }
    .filter-actions { grid-column: 4; grid-row: 1 / span 2; }
    .summary-grid { grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 9px; }
    .summary-card { gap: 10px; padding: 12px 10px; }
    .summary-icon { width: 42px; height: 42px; flex-basis: 42px; font-size: 20px; }
    .summary-card > div > span { font-size: 12px; }
    .summary-card strong { font-size: 23px; }
}

@media (max-width: 1080px) {
    .closing-main { min-width: 0; }
    body.drawer-open .closing-main { margin-right: 0; }
    .adjustment-drawer { width: 350px; }
    .filter-panel { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    .filter-actions { grid-column: auto; grid-row: auto; }
    .summary-grid { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
    .total-card { grid-column: span 2; }
    .drawer-backdrop {
        position: fixed;
        z-index: 45;
        inset: 0;
        display: block;
        background: rgba(22, 34, 27, .25);
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s ease;
    }
    body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
}

@media (max-width: 820px) {
    .closing-main { min-width: 0; padding: 15px 12px 20px; }
    body.drawer-open .closing-main { margin-right: 0; }
    .filter-panel { grid-template-columns: 1fr; padding: 16px; }
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .total-card { grid-column: span 2; }
    .search-box { width: 100%; min-width: 0; }
    .section-heading.guest-heading { align-items: stretch; flex-direction: column; }
    .page-note { align-items: flex-start; text-align: left; }
    .adjustment-drawer { width: min(390px, 100vw); }
}

@media (max-width: 520px) {
    .page-header-block h1 { font-size: 22px; }
    .breadcrumb-line { flex-wrap: wrap; gap: 6px 10px; }
    .summary-grid { grid-template-columns: 1fr; }
    .total-card { grid-column: auto; }
    .summary-card { min-height: 78px; }
    .table-tools { align-items: stretch; flex-direction: column; }
    .filter-button { width: 100%; }
    .department-panel,
    .guest-panel { padding: 13px 10px 9px; }
    .drawer-footer { grid-template-columns: 90px 1fr; gap: 9px; padding: 11px 14px 14px; }
    .drawer-body { padding-right: 14px; padding-left: 14px; }
    .drawer-header { padding-right: 14px; padding-left: 14px; }
}
