:root {
    color-scheme: light;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #17202a;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
}

.shell {
    width: min(1480px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.app-header {
    align-items: center;
}

.main-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.main-nav a {
    min-height: 36px;
    padding: 10px 12px;
    border: 1px solid #d7dde5;
    border-radius: 6px;
    color: #394454;
    background: #ffffff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.main-nav a.active {
    border-color: #1f6feb;
    color: #ffffff;
    background: #1f6feb;
}

.eyebrow {
    margin: 0 0 6px;
    color: #687385;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 34px;
    line-height: 1.15;
}

h2 {
    font-size: 20px;
    line-height: 1.25;
}

.total {
    min-width: 180px;
    padding: 14px 18px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
    text-align: right;
}

.total span {
    display: block;
    color: #687385;
    font-size: 13px;
    margin-bottom: 4px;
}

.total strong {
    display: block;
    font-size: 30px;
    line-height: 1;
}

.toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 18px;
}

.compact-action {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.left-action {
    justify-content: flex-start;
    margin-bottom: 10px;
}

.select-form,
.upload-form,
.result {
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.select-form,
.upload-form {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 14px;
}

.upload-form.wide {
    grid-column: 1 / -1;
}

label {
    color: #394454;
    font-size: 14px;
    font-weight: 700;
}

select,
input[type="file"] {
    width: 100%;
    min-width: 0;
    height: 38px;
    border: 1px solid #c7cfda;
    border-radius: 6px;
    background: #ffffff;
    color: #17202a;
    font-size: 14px;
    padding: 0 10px;
}

.plain-field:not([type="file"]):not([type="checkbox"]) {
    min-height: 32px;
    border-color: transparent;
    border-radius: 0;
    background: transparent;
    padding: 4px 2px;
    box-shadow: none;
    cursor: default;
}

select.plain-field {
    padding-right: 24px;
    appearance: none;
}

select.plain-field[data-locked="1"] {
    border-color: transparent;
    background-color: transparent;
    background-image: none;
    color: #17202a;
    pointer-events: auto;
}

textarea.plain-field {
    min-height: 88px;
    line-height: 1.4;
}

.plain-field:not([type="file"]):not([type="checkbox"]):focus {
    outline: 0;
}

.plain-field.is-edited:not([type="file"]):not([type="checkbox"]) {
    background: #fff7df;
    box-shadow: inset 0 -2px #e4a900;
}

.plain-field.is-editing:not([type="file"]):not([type="checkbox"]) {
    border-color: #17202a;
    background: #ffffff;
    box-shadow: none;
    cursor: text;
}

select.plain-field.is-editing {
    appearance: auto;
    cursor: pointer;
}

.dirty-bar {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: min(620px, calc(100vw - 48px));
    padding: 12px;
    border: 1px solid #c7cfda;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(23, 32, 42, 0.18);
}

.dirty-bar strong {
    color: #243247;
    font-size: 14px;
}

.dirty-bar .button {
    white-space: nowrap;
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(23, 32, 42, 0.34);
}

.confirm-box {
    width: min(460px, 100%);
    padding: 22px;
    border: 1px solid #c7cfda;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 18px 48px rgba(23, 32, 42, 0.28);
}

.confirm-box h2 {
    margin: 0 0 8px;
}

.confirm-box p {
    color: #394454;
    font-size: 14px;
    line-height: 1.45;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

input[type="file"] {
    padding: 7px 10px;
}

input[type="email"],
input[type="password"],
input[type="text"],
textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid #c7cfda;
    border-radius: 6px;
    background: #ffffff;
    color: #17202a;
    font: inherit;
    font-size: 14px;
    padding: 9px 10px;
}

textarea {
    min-height: 180px;
    resize: vertical;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid #1f6feb;
    border-radius: 6px;
    background: #1f6feb;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    padding: 0 14px;
    text-decoration: none;
    cursor: pointer;
}

button:disabled {
    border-color: #c7cfda;
    background: #dfe5ec;
    color: #687385;
    cursor: not-allowed;
}

.button.danger,
button.danger {
    border-color: #c62828;
    background: #c62828;
    color: #ffffff;
}

.button.secondary {
    border-color: #c7cfda;
    background: #ffffff;
    color: #17202a;
}

.button.small {
    min-height: 30px;
    padding: 0 10px;
    font-size: 13px;
}

.result {
    margin-bottom: 22px;
    overflow: hidden;
}

.result + .result,
.toolbar + .result {
    margin-top: 22px;
}

.result-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 18px;
    border-bottom: 1px solid #e2e7ee;
}

.result-head p {
    color: #687385;
    font-size: 14px;
    margin-top: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid #e9edf2;
    text-align: left;
    vertical-align: top;
}

.overview-table th,
.overview-table td,
.payments-table th,
.payments-table td {
    white-space: nowrap;
}

.nowrap {
    white-space: nowrap;
}

th {
    color: #394454;
    background: #f8fafc;
    font-size: 13px;
}

tbody tr {
    transition: background-color 0.12s ease;
}

tbody tr:hover td {
    position: relative;
    z-index: 1;
    box-shadow: inset 0 1px #17202a, inset 0 -1px #17202a;
}

tbody tr:hover td:first-child {
    box-shadow: inset 1px 0 #17202a, inset 0 1px #17202a, inset 0 -1px #17202a;
}

tbody tr:hover td:last-child {
    box-shadow: inset -1px 0 #17202a, inset 0 1px #17202a, inset 0 -1px #17202a;
}

td {
    font-size: 14px;
}

tfoot th {
    border-bottom: 0;
    font-size: 15px;
}

.hours {
    width: 190px;
    font-weight: 800;
    white-space: nowrap;
}

.flash-stack {
    position: fixed;
    top: 18px;
    left: 50%;
    z-index: 80;
    display: grid;
    gap: 10px;
    width: min(760px, calc(100vw - 32px));
    transform: translateX(-50%);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.flash-stack.is-hiding {
    opacity: 0;
    transform: translate(-50%, -8px);
}

.message {
    padding: 18px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(23, 32, 42, 0.16);
    color: #394454;
}

.message.error {
    border-color: #e0a5a5;
    background: #fff6f6;
    color: #9b1c1c;
}

.message.success {
    border-color: #9fc9a9;
    background: #f4fff6;
    color: #17612a;
}

.subtext {
    display: block;
    color: #687385;
    font-size: 12px;
    margin-top: 3px;
}

.details-row td {
    padding-top: 0;
    background: #fbfcfe;
}

details {
    color: #394454;
}

summary {
    cursor: pointer;
    font-weight: 700;
    padding: 8px 0;
}

.file-list {
    display: grid;
    gap: 8px;
    margin: 6px 0 10px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    max-width: 560px;
    padding: 8px 10px;
    border: 1px solid #e2e7ee;
    border-radius: 6px;
    background: #ffffff;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(360px, 1fr));
    gap: 24px;
    padding: 8px 0 18px;
    align-items: start;
}

.month-title {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 18px;
    border-bottom: 1px solid #e2e7ee;
}

.month-title p {
    margin-top: 4px;
    color: #687385;
    font-size: 14px;
}

h3 {
    margin: 0 0 12px;
    font-size: 16px;
}

.inline-form,
.mail-form {
    display: grid;
    gap: 10px;
}

.inline-form {
    grid-template-columns: 150px minmax(0, 1fr) auto;
    align-items: center;
    margin-bottom: 10px;
}

.mail-form {
    margin-top: 14px;
}

.mail-form label,
.finance-form label {
    display: grid;
    gap: 6px;
}

.finance-form,
.rule-form,
.deduction-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.finance-form .wide-field,
.finance-form button,
.rule-form .wide-field,
.rule-form button,
.rule-form .form-actions,
.deduction-form .wide-field,
.deduction-form button,
.deduction-form .form-actions,
.finance-separator {
    grid-column: 1 / -1;
}

.add-form-panel {
    padding: 14px 18px 18px;
}

.add-form-panel.compact {
    padding: 8px 0 0;
}

.add-form-trigger {
    width: auto;
}

.create-form {
    border-top: 1px solid #e2e7ee;
    background: #fbfcfe;
}

.form-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.finance-separator {
    margin-top: 4px;
    padding-top: 12px;
    border-top: 2px solid #d7dde5;
    color: #394454;
    font-size: 14px;
    font-weight: 800;
}

.finance-rules {
    margin-top: 18px;
}

.finance-rules summary {
    padding: 18px;
}

.rules-body {
    border-top: 1px solid #e2e7ee;
}

.rules-body > .subtext {
    margin: 14px 18px 0;
}

.rule-form {
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    padding: 18px;
    margin-top: 0;
}

.rule-list {
    display: grid;
    gap: 8px;
    padding: 0 18px 18px;
}

.rule-item {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 10px 12px;
    border: 1px solid #e2e7ee;
    border-radius: 6px;
    background: #ffffff;
}

.rule-edit {
    align-items: end;
}

.rule-edit label {
    display: grid;
    gap: 4px;
    min-width: 110px;
}

.rule-edit input,
.rule-edit select {
    height: 34px;
    padding: 0 8px;
}

.rule-delete {
    margin: -2px 0 8px;
    padding-left: 18px;
}

.rules-table th,
.rules-table td {
    padding: 8px 10px;
    vertical-align: middle;
}

.rules-table input,
.rules-table select {
    height: 32px;
    padding: 0 8px;
    font-size: 13px;
}

.rules-table td:nth-child(2),
.rules-table td:nth-child(3),
.rules-table td:nth-child(4),
.rules-table td:nth-child(5),
.rules-table td:nth-child(6),
.rules-table td:nth-child(7) {
    width: 96px;
}

.rules-table td:nth-child(8) {
    width: 170px;
}

.rules-table td:nth-child(9) {
    min-width: 220px;
}

.row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.row-actions form {
    margin: 0;
}

.assignment-row td {
    background: #fbfcfe;
    padding-top: 0;
}

.project-list {
    display: grid;
    gap: 18px;
    padding: 18px;
}

.project-card,
.project-add-card {
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
}

.project-card-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding: 16px 18px;
    border-bottom: 1px solid #e2e7ee;
    background: #fbfcfe;
}

.project-card-head h3 {
    margin: 0 0 4px;
    font-size: 18px;
}

.project-card-head p {
    color: #687385;
    font-size: 13px;
}

.project-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.project-card-actions form {
    margin: 0;
}

.project-fields {
    display: grid;
    grid-template-columns: 180px 120px minmax(220px, 1fr) 90px 120px 120px 110px;
    gap: 12px;
    align-items: end;
    padding: 14px 18px;
    border-bottom: 1px solid #e9edf2;
}

.project-fields label {
    display: grid;
    gap: 4px;
}

.project-active span {
    display: flex;
    gap: 8px;
    align-items: center;
    min-height: 32px;
}

.project-add-card {
    margin: 0 18px 18px;
}

.assignment-list {
    display: grid;
    gap: 8px;
    padding: 14px 18px 18px;
}

.assignment-head,
.assignment-item {
    display: grid;
    grid-template-columns: 150px 190px minmax(180px, 1fr) 100px 110px minmax(220px, 1fr) 92px 170px;
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
    border-left: 4px solid transparent;
}

.assignment-head {
    color: #687385;
    font-size: 12px;
    font-weight: 800;
    padding: 0 0 2px;
}

.assignment-item input,
.assignment-item select {
    height: 32px;
    padding: 0 8px;
    font-size: 13px;
}

.add-assignment {
    margin-top: 6px;
    padding: 10px 0;
    border-top: 1px solid #c9d7ea;
    border-bottom: 1px solid #c9d7ea;
    border-radius: 0;
    background: #f4f8ff;
}

.assignment-item.role-worker {
    border-left-color: #2b6fe8;
    background: #f5f9ff;
}

.assignment-item.role-commission {
    border-left-color: #e4a900;
    background: #fff8e5;
}

.assignment-item.role-company {
    border-left-color: #2e9f55;
    background: #edf8f1;
}

.assignment-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.assignment-actions form {
    margin: 0;
}

.assignment-new-label {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    width: max-content;
    padding: 0 8px;
    border-radius: 999px;
    background: #e8f0ff;
    color: #2452a6;
    font-size: 12px;
    font-weight: 800;
}

.deduction-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.deduction-item {
    display: grid;
    grid-template-columns: 70px 110px minmax(220px, 1fr) 90px;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid #e2e7ee;
    border-radius: 6px;
    background: #ffffff;
    font-size: 14px;
}

.deduction-item span {
    min-width: 0;
}

.deduction-item span:nth-child(3) {
    color: #394454;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.deduction-item form {
    margin: 0;
}

.deduction-item .button {
    width: 100%;
    min-height: 34px;
    padding: 0 10px;
}

.attachment-line {
    margin: 8px 0 0;
    color: #394454;
    font-size: 14px;
}

.muted {
    color: #687385;
}

.finance-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e2e7ee;
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
}

.finance-table th,
.finance-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e9edf2;
    font-size: 14px;
}

.finance-table th {
    width: 58%;
    color: #394454;
    background: #f8fafc;
    font-weight: 700;
    text-align: left;
}

.finance-table td {
    text-align: right;
    font-weight: 800;
    white-space: nowrap;
}

.finance-table tr:last-child th,
.finance-table tr:last-child td {
    border-bottom: 0;
}

.finance-table span {
    display: block;
    color: #687385;
    font-size: 12px;
    font-weight: 400;
}

.payment-summary {
    display: inline-block;
    min-width: 88px;
    color: #394454;
    font-weight: 700;
}

.payment-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.payment-card {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid #dde5ef;
    border-radius: 6px;
    background: #ffffff;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    width: max-content;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.status-pill.calculated {
    background: #eef2f6;
    color: #394454;
}

.status-pill.waiting {
    background: #fff7df;
    color: #865400;
}

.status-pill.paid {
    background: #e8f8ee;
    color: #17612a;
}

.status-pill.sent {
    background: #e8f8ee;
    color: #17612a;
}

.status-pill.failed {
    background: #fff0f0;
    color: #9b1c1c;
}

.payment-summary-box {
    display: grid;
    gap: 6px;
}

.payment-dots {
    display: flex;
    gap: 5px;
}

.payment-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d8dee7;
}

.payment-dot.calculated,
.payment-cell.calculated {
    background: #f3f6f9;
}

.payment-dot.waiting,
.payment-cell.waiting {
    background: #fff6d8;
}

.payment-dot.paid,
.payment-cell.paid {
    background: #e8f8ee;
}

.workflow-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.workflow-card {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    min-height: 64px;
    padding: 12px 16px;
    border: 1px solid #dde5ef;
    border-left: 4px solid #b9c2cf;
    border-radius: 6px;
    background: #ffffff;
    color: inherit;
    text-decoration: none;
}

.workflow-card span {
    color: #394454;
    font-size: 13px;
    font-weight: 800;
}

.workflow-card strong {
    font-size: 24px;
}

.workflow-card.missing {
    border-left-color: #c7cfda;
    background: #fbfcfe;
}

.workflow-card.ready {
    border-left-color: #2b6fe8;
    background: #edf4ff;
}

.workflow-card.waiting {
    border-left-color: #e4a900;
    background: #fff6d8;
}

.workflow-card.done {
    border-left-color: #2e9f55;
    background: #e8f8ee;
}

.workflow-card.all {
    border-left-color: #243247;
    background: #ffffff;
}

.workflow-card.active {
    outline: 2px solid #17202a;
    outline-offset: 1px;
}

.workflow-next {
    min-width: 190px;
    border-left: 3px solid transparent;
}

.workflow-next strong,
.workflow-next span {
    display: block;
}

.workflow-next strong {
    margin-bottom: 4px;
}

.workflow-next span {
    color: #394454;
    font-size: 12px;
    font-weight: 700;
}

.workflow-next.missing {
    border-left-color: #c7cfda;
    background: #fbfcfe;
}

.workflow-next.ready {
    border-left-color: #2b6fe8;
    background: #edf4ff;
}

.workflow-next.waiting {
    border-left-color: #e4a900;
    background: #fff6d8;
}

.workflow-next.done {
    border-left-color: #2e9f55;
    background: #e8f8ee;
}

.process-cell {
    border-left: 3px solid transparent;
}

.process-cell strong {
    display: block;
    margin-bottom: 4px;
}

.process-cell .button {
    margin-top: 4px;
}

.process-cell.done,
.process-cell.paid {
    border-left-color: #2e9f55;
    background: #e8f8ee;
}

.process-cell.sent {
    border-left-color: #2b6fe8;
    background: #edf4ff;
}

.process-cell.waiting {
    border-left-color: #e4a900;
    background: #fff6d8;
}

.process-cell.calculated {
    border-left-color: #b9c2cf;
    background: #f3f6f9;
}

.process-cell.missing {
    border-left-color: #c7cfda;
    background: #fbfcfe;
}

.payment-cell {
    border-left: 3px solid transparent;
}

.payment-cell .status-pill {
    margin-top: 8px;
}

.payment-lines {
    display: grid;
    gap: 6px;
    grid-template-rows: repeat(6, minmax(18px, auto));
    min-width: 210px;
}

.payment-lines div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: baseline;
}

.payment-lines span {
    color: #687385;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.payment-lines strong {
    white-space: nowrap;
}

.payment-lines .empty-line {
    visibility: hidden;
}

.payment-total {
    margin-top: 2px;
    padding-top: 5px;
    border-top: 1px solid rgba(57, 68, 84, 0.16);
}

.payment-total span,
.payment-total strong {
    color: #17202a;
}

.payment-cell.calculated {
    border-left-color: #b9c2cf;
}

.payment-cell.waiting {
    border-left-color: #e4a900;
}

.payment-cell.paid {
    border-left-color: #2e9f55;
}

.reports-table td {
    vertical-align: middle;
}

.project-report-table > tbody > tr.project-summary-row > td {
    border-top: 2px solid #d7dde5;
    vertical-align: top;
}

.project-summary-row:first-child > td {
    border-top: 0;
}

.project-detail-row > td {
    padding-top: 0;
    background: #fbfcfe;
}

.compact-report-table {
    margin-top: 10px;
    border: 1px solid #e2e7ee;
    background: #ffffff;
}

.compact-report-table .status-pill {
    margin-top: 6px;
}

.compact-report-table tr.needs-payout td {
    border-top: 2px solid #e4a900;
    border-bottom: 2px solid #e4a900;
    background: #fff8e5;
}

.compact-report-table tr.needs-payout td:first-child {
    border-left: 4px solid #e4a900;
}

.payment-check {
    display: flex;
    gap: 8px;
    align-items: center;
    font-weight: 800;
}

.payment-check input {
    width: auto;
}

.settings-form {
    display: grid;
    gap: 0;
}

.settings-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 18px;
}

.settings-panel {
    display: grid;
    align-content: start;
    gap: 12px;
    padding: 14px;
    border: 1px solid #e2e7ee;
    border-radius: 6px;
    background: #fbfcfe;
}

.settings-panel h3 {
    margin-bottom: 4px;
}

.settings-panel p {
    margin: 0;
    color: #687385;
    font-size: 13px;
    line-height: 1.35;
}

.settings-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(160px, 1fr));
    gap: 10px;
}

.settings-fields-money {
    grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.settings-fields label {
    display: grid;
    gap: 6px;
}

.settings-template-fields {
    grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1.2fr);
}

.settings-details summary {
    padding: 0;
    color: #243247;
}

.settings-details[open] summary {
    margin-bottom: 2px;
}

.settings-details textarea {
    min-height: 150px;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0 18px 18px;
}

.settings-save {
    width: auto;
    min-width: 190px;
    margin: 0;
}

.finance-rules-settings {
    margin-top: 18px;
}

.finance-rules-settings > details > summary {
    padding: 18px;
}

.finance-rules-settings .rule-form {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.finance-rules-settings .rule-form button {
    grid-column: auto;
    align-self: end;
}

.portal-body {
    background: #f4f6f8;
}

.portal-shell,
.employee-shell {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.portal-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.portal-header p {
    margin-top: 6px;
    color: #687385;
    font-size: 15px;
}

.portal-role-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.portal-role-card {
    display: grid;
    gap: 8px;
    min-height: 150px;
    padding: 18px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
    color: #17202a;
    text-decoration: none;
}

.portal-role-card:hover,
.portal-role-card:focus-visible {
    border-color: #17202a;
    outline: 0;
}

.portal-role-card.primary {
    border-color: #1f6feb;
    background: #f5f9ff;
}

.portal-role-card span {
    color: #687385;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.portal-role-card strong {
    font-size: 20px;
}

.portal-role-card p {
    color: #4c5a6d;
    font-size: 14px;
    line-height: 1.4;
}

.portal-permission-table {
    overflow: hidden;
}

.portal-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.portal-sidebar,
.portal-main {
    display: grid;
    gap: 14px;
}

.portal-user-card,
.permission-box {
    padding: 16px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.portal-user-card {
    display: grid;
    gap: 4px;
}

.portal-user-card span,
.portal-user-card small {
    color: #687385;
    font-size: 13px;
}

.portal-user-card strong {
    font-size: 22px;
}

.permission-box {
    border-left: 4px solid #d7dde5;
}

.permission-box.allowed {
    border-left-color: #2e9f55;
}

.permission-box.denied {
    border-left-color: #d64545;
}

.permission-box h2 {
    margin-bottom: 10px;
    font-size: 17px;
}

.permission-box ul {
    display: grid;
    gap: 7px;
    margin: 0;
    padding-left: 18px;
    color: #394454;
    font-size: 14px;
    line-height: 1.35;
}

.portal-upload-form {
    display: grid;
    grid-template-columns: minmax(180px, 0.7fr) minmax(260px, 1fr) auto;
    gap: 12px;
    align-items: end;
    padding: 18px;
}

.portal-upload-form label {
    display: grid;
    gap: 6px;
}

.portal-confirm-card,
.portal-history-card {
    overflow: hidden;
}

.employee-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 18px;
}

.employee-summary div {
    padding: 14px;
    border: 1px solid #e2e7ee;
    border-radius: 6px;
    background: #fbfcfe;
}

.employee-summary span {
    display: block;
    margin-bottom: 5px;
    color: #687385;
    font-size: 13px;
    font-weight: 700;
}

.employee-summary strong {
    font-size: 22px;
}

.employee-months-table .hours {
    font-weight: 800;
}

.review-form {
    display: grid;
    grid-template-columns: minmax(180px, 0.6fr) minmax(260px, 1fr) auto;
    gap: 12px;
    align-items: end;
    padding: 0 18px 18px;
    border-bottom: 1px solid #e2e7ee;
}

.review-form label {
    display: grid;
    gap: 6px;
}

.review-line {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.account-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 18px;
}

.account-summary div {
    padding: 14px;
    border: 1px solid #e2e7ee;
    border-radius: 6px;
    background: #fbfcfe;
}

.account-summary span {
    display: block;
    margin-bottom: 6px;
    color: #687385;
    font-size: 13px;
    font-weight: 800;
}

.account-summary strong {
    font-size: 18px;
}

.stacked-selects {
    display: grid;
    gap: 6px;
}

.stacked-selects select {
    height: 32px;
}

.identity-row.role-worker td {
    background: #f5f9ff;
}

.identity-row.role-customer td {
    background: #edf8f1;
}

.identity-row.role-commission td {
    background: #fff8e5;
}

.identity-create-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(140px, auto) auto;
    gap: 8px;
    align-items: center;
}

.generated-password-label {
    color: #687385;
    font-size: 13px;
    font-weight: 700;
}

.locked-value {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid #d7dde5;
    border-radius: 6px;
    background: #f4f6f8;
    color: #394454;
    font-weight: 800;
}

.login-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
}

.login-card > p:not(.eyebrow) {
    margin-top: 8px;
    color: #687385;
}

.login-form {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.login-form label {
    display: grid;
    gap: 6px;
}

@media (max-width: 820px) {
    .topbar,
    .result-head {
        align-items: stretch;
        flex-direction: column;
    }

    .main-nav {
        flex-wrap: wrap;
    }

    .total {
        text-align: left;
    }

    .toolbar {
        grid-template-columns: 1fr;
    }

    .select-form,
    .upload-form {
        grid-template-columns: 1fr;
    }

    .detail-grid,
    .payment-grid,
    .workflow-summary,
    .portal-role-grid,
    .portal-layout,
    .settings-layout,
    .settings-fields,
    .settings-fields-money,
    .settings-template-fields,
    .inline-form,
    .portal-upload-form,
    .employee-summary,
    .review-form,
    .account-summary,
    .identity-create-form {
        grid-template-columns: 1fr;
    }

    .settings-actions {
        justify-content: stretch;
    }

    .settings-save {
        width: 100%;
    }

    table {
        display: block;
        overflow-x: auto;
    }

    th,
    td {
        min-width: 140px;
    }
}
