:root {
    --app-bg: #f8faf9;
    --app-surface: #ffffff;
    --app-text: #1f2a24;
    --app-muted: #6c757d;
    --app-border: #dfe7e2;
    --app-border-light: #e8eee9;
    --app-green: #4f8f67;
    --app-green-dark: #3f7654;
    --app-green-soft: #eaf5ee;
    --app-green-softer: #f5faf7;
    --app-head-bg: #f3f5f4;
    --app-warning-soft: #fff4d8;
    --app-blue-soft: #eaf2ff;
}

html {
    font-size: 14px;
}

body {
    background: var(--app-bg);
    color: var(--app-text);
}

.app-navbar {
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--app-border);
}

.app-nav-inner {
    padding-left: 24px;
    padding-right: 24px;
}

.app-navbar .navbar-brand {
    color: var(--app-green-dark);
    font-weight: 700;
}

.app-shell {
    padding-top: 1.25rem;
    padding-bottom: 2rem;
}

.app-shell-wide {
    box-sizing: border-box;
    width: calc(100% - 48px);
    max-width: 1560px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
}

.app-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 0.65rem;
    box-shadow: 0 8px 24px rgba(31, 42, 36, 0.04);
}

.app-card-header {
    background: var(--app-head-bg);
    border-bottom: 1px solid var(--app-border);
    color: var(--app-text);
    font-weight: 700;
    padding: 0.7rem 0.9rem;
}

.app-card-body {
    padding: 1rem;
}

.btn-primary,
.btn-success {
    background: var(--app-green);
    border-color: var(--app-green);
}

.btn-primary:hover,
.btn-success:hover {
    background: var(--app-green-dark);
    border-color: var(--app-green-dark);
}

.btn-outline-success {
    border-color: var(--app-green);
    color: var(--app-green-dark);
}

.btn-outline-success:hover {
    background: var(--app-green-soft);
    border-color: var(--app-green);
    color: var(--app-green-dark);
}

.form-control,
.form-select {
    border-color: #cfddd3;
    font-size: 0.92rem;
}

.table {
    --bs-table-hover-bg: var(--app-green-softer);
    color: var(--app-text);
    font-size: 0.9rem;
    border-color: var(--app-border-light);
}

.table-compact {
    font-size: 0.96rem;
}

.table-compact > :not(caption) > * > * {
    padding: 0.24rem 0.3rem;
    color: var(--app-text);
    border: 1px solid var(--app-border-light);
    text-align: center;
    vertical-align: middle;
}

.table thead th {
    background: var(--app-head-bg);
    color: #30443a;
    border-color: var(--app-border);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.15;
    text-align: center;
    vertical-align: middle;
    white-space: normal;
}

.number-cell {
    text-align: center;
    white-space: nowrap;
    overflow: visible;
}

.number-cell .comment-tooltip,
.number-cell .comment-preview {
    text-align: left;
}

.amount-cell {
    min-width: 90px;
    max-width: 130px;
    overflow: visible;
}

.amount-value {
    display: block;
    width: 100%;
    text-align: center;
}

.input-compact,
.table .form-control,
.table .form-select {
    font-size: 0.9rem;
    padding: 0.22rem 0.38rem;
    color: var(--app-text);
    text-align: left;
}

.table textarea.form-control {
    width: 190px;
    min-width: 170px;
    max-width: 210px;
    min-height: 38px;
    height: 44px;
    max-height: 50px;
    resize: vertical;
}

.approver-table .comment-cell {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

.approver-table .comment-cell textarea.form-control {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-width: 170px;
    max-width: 100%;
    height: 52px;
    min-height: 48px;
    max-height: 56px;
    margin: 0 auto;
    padding: 6px 8px;
    line-height: 1.25;
    resize: vertical;
}

.table input[name="adjustment_amount"] {
    width: 94px;
    min-width: 88px;
    max-width: 98px;
    text-align: center;
}

.table .btn-primary,
.table .btn-success {
    background: var(--app-green-soft);
    border-color: var(--app-green);
    color: var(--app-green-dark);
}

.table .btn-primary:hover,
.table .btn-success:hover {
    background: #dcefe3;
    border-color: var(--app-green-dark);
    color: #294d36;
}

.badge-status-submitted {
    background: var(--app-warning-soft);
    color: #7a5b12;
}

.badge-status-approved {
    background: var(--app-green-soft);
    color: var(--app-green-dark);
}

.badge-status-changed {
    background: var(--app-blue-soft);
    color: #24527a;
}

.summary-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-left: 3px solid #b9d8c4;
    border-radius: 0.5rem;
    padding: 0.55rem 0.65rem;
    min-height: 3.65rem;
}

.summary-label {
    color: var(--app-muted);
    font-size: 0.76rem;
    line-height: 1.15;
}

.summary-value {
    color: var(--app-green-dark);
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 0.15rem;
}

.comment-preview {
    display: block;
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.78rem;
    line-height: 1.2;
    color: var(--app-muted);
    cursor: help;
}

.comment-cell {
    max-width: 220px;
    white-space: normal;
    font-size: 0.86rem;
    text-align: left;
}

.kpi-cell {
    max-width: 82px;
    min-width: 72px;
    font-size: 0.82rem;
    text-align: center;
    vertical-align: middle;
}

.kpi-cell .comment-preview {
    text-align: center;
}

.comment-tooltip {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
}

.comment-tooltip-text {
    display: none;
    position: absolute;
    z-index: 3000;
    top: 100%;
    left: 0;
    background: #ffffff;
    color: #212529;
    border: 1px solid #d9e8dd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    padding: 8px 10px;
    min-width: 220px;
    max-width: 360px;
    white-space: normal;
    overflow-wrap: break-word;
    font-size: 0.85rem;
    line-height: 1.35;
    text-align: left;
}

.salary-comment-tooltip-text {
    white-space: pre-line;
}

.comment-tooltip:hover .comment-tooltip-text {
    display: block;
}

.field-help-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 0.25rem;
    vertical-align: middle;
}

.field-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border: 1px solid #b9d8c4;
    border-radius: 50%;
    background: var(--app-green-soft);
    color: var(--app-green-dark);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    cursor: help;
}

.field-help-tooltip-text {
    display: none;
    position: absolute;
    z-index: 3000;
    top: calc(100% + 0.35rem);
    left: 50%;
    transform: translateX(-50%);
    min-width: 220px;
    max-width: min(360px, 80vw);
    padding: 8px 10px;
    border: 1px solid #d9e8dd;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    color: #212529;
    font-size: 0.85rem;
    font-weight: 400;
    line-height: 1.35;
    overflow-wrap: break-word;
    text-align: left;
    white-space: normal;
}

.field-help-tooltip:hover .field-help-tooltip-text {
    display: block;
}

.worker-salary-form {
    max-width: 760px;
}

.worker-kpi-form {
    max-width: 760px;
}

.kpi-form {
    display: block;
}

.kpi-form .kpi-form-group {
    width: 100%;
    margin-bottom: 20px;
}

.kpi-form .kpi-form-group label {
    display: block;
    margin-bottom: 6px;
}

.kpi-form .kpi-form-group .form-control,
.kpi-form .kpi-form-group .form-select {
    width: 100%;
}

.kpi-form .kpi-checkbox-group {
    margin: 18px 0 20px;
}

.kpi-form .kpi-checkbox-group .form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 1.5rem;
    margin: 0;
    padding-left: 0;
}

.kpi-form .kpi-checkbox-group .form-check-input {
    flex: 0 0 auto;
    float: none;
    margin: 0;
}

.kpi-form .kpi-checkbox-group .form-check-label {
    margin: 0;
}

.kpi-form .worker-kpi-form-actions {
    margin-top: 10px;
}

.worker-kpi-table {
    font-size: 0.86rem;
}

.worker-kpi-table th,
.worker-kpi-table td {
    min-width: 92px;
}

.worker-kpi-table th:nth-child(2),
.worker-kpi-table td:nth-child(2) {
    min-width: 130px;
}

.worker-kpi-table .kpi-history-client-cell {
    text-align: center;
    vertical-align: middle;
}

.worker-kpi-table th:nth-child(8),
.worker-kpi-table td:nth-child(8) {
    min-width: 125px;
}

.payroll-info-card textarea.form-control {
    min-height: 6rem;
    resize: vertical;
}

.worker-info-card {
    border-left: 3px solid var(--app-green);
}

.worker-info-text {
    color: var(--app-text);
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: break-word;
}

.approver-table {
    width: 100%;
    table-layout: fixed;
    font-size: 0.96rem;
}

.approver-table th:nth-child(1),
.approver-table td:nth-child(1) {
    width: 34px;
}

.approver-table th:nth-child(2),
.approver-table td:nth-child(2) {
    width: 130px;
}

.approver-table th:nth-child(3),
.approver-table td:nth-child(3),
.approver-table th:nth-child(4),
.approver-table td:nth-child(4) {
    width: 110px;
}

.approver-table th:nth-child(5),
.approver-table td:nth-child(5) {
    width: 104px;
}

.approver-table th:nth-child(6),
.approver-table td:nth-child(6) {
    width: 100px;
}

.approver-table th:nth-child(7),
.approver-table td:nth-child(7) {
    width: 190px;
}

.approver-table th:nth-child(8),
.approver-table td:nth-child(8) {
    width: 145px;
}

.approver-table th:nth-child(9),
.approver-table td:nth-child(9) {
    width: 112px;
}

.approver-table .salary-status-cell {
    width: 145px;
    min-width: 130px;
    vertical-align: middle;
}

.approver-table .salary-actions-cell {
    width: 112px;
    max-width: 120px;
    vertical-align: middle;
    text-align: center;
}

.approver-table .badge,
.worker-table .badge {
    white-space: normal;
    line-height: 1.2;
}

.approver-table .btn {
    white-space: normal;
    line-height: 1.15;
}

.approver-kpi-table {
    width: 100%;
    table-layout: fixed;
    font-size: 0.9rem;
}

.approver-kpi-table th,
.approver-kpi-table td {
    padding: 0.32rem 0.4rem;
    text-align: center;
    vertical-align: middle;
}

.approver-kpi-worker-cell,
.approver-kpi-client-cell {
    text-align: center;
    vertical-align: middle;
}

.approver-kpi-table th:nth-child(1),
.approver-kpi-table td:nth-child(1) {
    width: 120px;
    max-width: 140px;
    white-space: normal;
    word-break: break-word;
}

.approver-kpi-table th:nth-child(2),
.approver-kpi-table td:nth-child(2) {
    width: 130px;
}

.approver-kpi-table th:nth-child(3),
.approver-kpi-table td:nth-child(3),
.approver-kpi-table th:nth-child(8),
.approver-kpi-table td:nth-child(8) {
    width: 125px;
}

.period-approval-bar {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    max-width: 640px;
    margin-left: auto;
}

.approval-step {
    min-width: 220px;
    padding: 0;
    background: transparent;
    text-align: center;
}

.approval-step-title {
    color: var(--app-muted);
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.approval-state {
    width: 100%;
    color: var(--app-green-dark);
    background: var(--app-green-soft);
    border-color: var(--app-green);
    opacity: 1;
}

.approval-cancel {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
}

@media (max-width: 768px) {
    .app-nav-inner {
        padding-left: 16px;
        padding-right: 16px;
    }

    .app-shell-wide {
        width: calc(100% - 16px);
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .period-approval-bar {
        display: block;
        max-width: none;
    }

    .approval-step + .approval-step {
        margin-top: 0.75rem;
    }
}
