/* ============================================================
   PWTERP HR module — scoped design system
   All selectors live under .hr-page (or .hr-*) so other modules
   are not affected. Do not add unscoped Bootstrap overrides.
   ============================================================ */

.hr-page {
    --hr-text: #1e293b;
    --hr-muted: #64748b;
    --hr-border: #e2e8f0;
    --hr-border-strong: #cbd5e1;
    --hr-bg: #f8fafc;
    --hr-card: #ffffff;
    --hr-primary: #2563eb;
    --hr-primary-hover: #1d4ed8;
    --hr-primary-soft: #eff6ff;
    --hr-focus: #2563eb;
    --hr-success: #047857;
    --hr-success-bg: #ecfdf5;
    --hr-warning: #b45309;
    --hr-warning-bg: #fffbeb;
    --hr-danger: #b91c1c;
    --hr-danger-bg: #fef2f2;
    --hr-pending: #4338ca;
    --hr-pending-bg: #eef2ff;
    --hr-radius: 11px;
    --hr-control-h: 40px;
    --hr-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    color: var(--hr-text);
    max-width: 1280px;
}

.hr-page--wide { max-width: 1400px; }
.hr-page--narrow { max-width: 760px; }

/* ---------- Page header ---------- */
.hr-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.hr-page-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 750;
    letter-spacing: -.02em;
    line-height: 1.25;
    color: var(--hr-text);
}

.hr-page-subtitle {
    margin: 4px 0 0;
    color: var(--hr-muted);
    font-size: 13px;
    line-height: 1.45;
}

.hr-action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* ---------- Employee profile header ---------- */
.hr-employee-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--hr-card);
    border: 1px solid var(--hr-border);
    border-radius: var(--hr-radius);
    box-shadow: var(--hr-shadow);
    padding: 16px 18px;
    margin-bottom: 14px;
}

.hr-employee-header-main {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1 1 280px;
}

.hr-employee-avatar {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: var(--hr-primary-soft);
    color: var(--hr-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 750;
    font-size: 16px;
    letter-spacing: .02em;
    flex: 0 0 auto;
    border: 1px solid #dbeafe;
}

.hr-employee-identity { min-width: 0; }

.hr-employee-name {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 750;
    letter-spacing: -.02em;
    line-height: 1.25;
}

.hr-employee-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-top: 6px;
    color: var(--hr-muted);
    font-size: 12.5px;
}

.hr-employee-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hr-employee-meta-item + .hr-employee-meta-item::before {
    content: "";
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #94a3b8;
}

.hr-mode-hint {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--hr-border);
    color: var(--hr-muted);
    background: var(--hr-bg);
}

.hr-page--view .hr-mode-hint { color: #475569; }
.hr-page--edit .hr-mode-hint {
    color: #1d4ed8;
    background: var(--hr-primary-soft);
    border-color: #bfdbfe;
}

/* ---------- Cards / sections ---------- */
.hr-card,
.hr-section,
.hr-table-card {
    background: var(--hr-card);
    border: 1px solid var(--hr-border);
    border-radius: var(--hr-radius);
    box-shadow: var(--hr-shadow);
}

.hr-card { padding: 18px 18px 16px; margin-bottom: 14px; }
.hr-section { padding: 16px 18px 18px; margin-bottom: 14px; }
.hr-table-card { overflow: hidden; margin-bottom: 14px; }

.hr-table-card-title {
    margin: 0;
    padding: 14px 18px 10px;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #475569;
}

.hr-section-title,
.hr-card-title {
    margin: 0 0 14px;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #475569;
}

.hr-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.hr-section-head .hr-section-title { margin-bottom: 0; }

.hr-card-body { padding: 0; }
.hr-table-card > .hr-card-body,
.hr-table-card > .hr-section { border: 0; box-shadow: none; margin: 0; }

/* ---------- Form grid ---------- */
.hr-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 14px;
}

.hr-form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hr-form-grid--1 { grid-template-columns: 1fr; }

.hr-field { min-width: 0; }
.hr-field--wide { grid-column: span 2; }
.hr-field--full { grid-column: 1 / -1; }

.hr-page .hr-field > .form-label,
.hr-page label.hr-label,
.hr-label {
    display: block;
    font-size: 12.5px;
    font-weight: 650;
    color: #334155;
    margin-bottom: 5px;
}

.hr-req { color: var(--hr-danger); font-weight: 750; }
.hr-optional {
    color: var(--hr-muted);
    font-weight: 550;
    font-size: 11px;
}

.hr-page .form-control,
.hr-page .form-select,
.hr-page .form-control-sm,
.hr-page .form-select-sm {
    min-height: var(--hr-control-h);
    height: var(--hr-control-h);
    font-size: 13.5px;
    border-radius: 10px;
    border-color: var(--hr-border-strong);
    color: var(--hr-text);
    background-color: #fff;
    padding: 6px 12px;
}

.hr-page textarea.form-control {
    height: auto;
    min-height: 88px;
}

.hr-page .form-control:focus,
.hr-page .form-select:focus {
    border-color: var(--hr-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
    outline: none;
}

.hr-page .form-control:focus-visible,
.hr-page .form-select:focus-visible,
.hr-page .btn:focus-visible,
.hr-page .hr-tab:focus-visible,
.hr-page .form-check-input:focus-visible {
    outline: 2px solid var(--hr-focus);
    outline-offset: 2px;
    box-shadow: none;
}

.hr-page .form-control:disabled,
.hr-page .form-select:disabled,
.hr-page textarea.form-control:disabled,
.hr-page--view .form-control,
.hr-page--view .form-select {
    background: #f8fafc;
    color: #334155;
    border-color: var(--hr-border);
    cursor: default;
    opacity: 1;
}

.hr-page .form-control.invalid,
.hr-page .form-select.invalid,
.hr-page .invalid.form-control,
.hr-page .invalid.form-select {
    border-color: #dc2626;
    background: #fff7f7;
}

.hr-page .validation-message,
.hr-field .validation-message {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--hr-danger);
}

.hr-page .validation-errors,
.hr-page .validation-summary-errors {
    background: var(--hr-danger-bg);
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    color: var(--hr-danger);
    font-size: 13px;
}

.hr-page .validation-summary-errors ul { margin: 6px 0 0; padding-left: 18px; }

.hr-page .form-text,
.hr-help {
    font-size: 12px;
    color: var(--hr-muted);
}

.hr-page .form-check-input {
    width: 16px;
    height: 16px;
    margin-top: .2em;
    border-color: var(--hr-border-strong);
}

.hr-check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    align-items: center;
    min-height: var(--hr-control-h);
    padding-top: 22px;
}

.hr-check-row--flush { padding-top: 0; min-height: 0; }

.hr-color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: -1px;
    border: 1px solid rgba(15, 23, 42, .12);
}

/* ---------- Tabs ---------- */
.hr-tabs {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    border-bottom: 1px solid var(--hr-border);
    margin-bottom: 14px;
    padding-bottom: 0;
}

.hr-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: #475569;
    font-size: 13px;
    font-weight: 650;
    padding: 10px 12px;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    line-height: 1.2;
}

.hr-tab:hover:not(:disabled) {
    color: var(--hr-text);
    background: #f1f5f9;
}

.hr-tab.is-active,
.hr-tab[aria-current="page"] {
    color: var(--hr-primary);
    border-bottom-color: var(--hr-primary);
    background: transparent;
}

.hr-tab:disabled,
.hr-tab.is-disabled {
    color: #94a3b8;
    cursor: not-allowed;
    opacity: .7;
}

/* ---------- Tables ---------- */
.hr-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.hr-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: 13px;
}

.hr-table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 11.5px;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--hr-border);
    padding: 9px 12px;
    white-space: nowrap;
    text-align: left;
}

.hr-table tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.hr-table tbody tr:hover { background: #f8fafc; }
.hr-table tbody tr.is-inactive { background: #f8fafc; color: #64748b; }
.hr-table tbody tr.is-primary { background: #f8fbff; }
.hr-table .hr-num { text-align: right; font-variant-numeric: tabular-nums; }
.hr-table .hr-actions { text-align: right; white-space: nowrap; }
.hr-table .mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; }

.hr-row-actions {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.hr-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--hr-border);
    background: #fff;
}

.hr-toolbar .form-control,
.hr-toolbar .form-select { min-width: 140px; }

.hr-year-input { width: 110px; max-width: 110px; }
.hr-month-input { width: 180px; max-width: 100%; }

@media print {
    .hr-page-header,
    .hr-action-bar,
    .hr-tabs { display: none !important; }
}

.hr-table-foot {
    padding: 10px 14px;
    border-top: 1px solid var(--hr-border);
    color: var(--hr-muted);
    font-size: 12.5px;
    background: #fff;
}

/* ---------- Status chips ---------- */
.hr-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.3;
    border: 1px solid transparent;
    white-space: nowrap;
}

.hr-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.hr-status-active { background: var(--hr-success-bg); color: var(--hr-success); border-color: #a7f3d0; }
.hr-status-inactive { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.hr-status-warning { background: var(--hr-warning-bg); color: var(--hr-warning); border-color: #fde68a; }
.hr-status-pending { background: var(--hr-pending-bg); color: var(--hr-pending); border-color: #c7d2fe; }
.hr-status-approved { background: var(--hr-success-bg); color: var(--hr-success); border-color: #a7f3d0; }
.hr-status-rejected { background: var(--hr-danger-bg); color: var(--hr-danger); border-color: #fecaca; }
.hr-status-processing { background: var(--hr-primary-soft); color: #1d4ed8; border-color: #bfdbfe; }
.hr-status-primary { background: var(--hr-primary-soft); color: #1d4ed8; border-color: #bfdbfe; }

/* ---------- Buttons (scoped) ---------- */
.hr-page .btn {
    border-radius: 10px;
    font-weight: 650;
    font-size: 13px;
    min-height: 38px;
    padding: 6px 14px;
}

.hr-page .btn-sm {
    min-height: 32px;
    padding: 4px 10px;
    font-size: 12.5px;
    border-radius: 8px;
}

.hr-page .btn-primary {
    background: var(--hr-primary);
    border-color: var(--hr-primary);
}

.hr-page .btn-primary:hover:not(:disabled) {
    background: var(--hr-primary-hover);
    border-color: var(--hr-primary-hover);
}

.hr-page .btn-outline-secondary,
.hr-page .btn-outline-primary {
    background: #fff;
    color: #334155;
    border-color: var(--hr-border-strong);
}

.hr-page .btn-outline-primary { color: var(--hr-primary); border-color: #bfdbfe; }

.hr-page .btn-outline-danger,
.hr-page .hr-btn-danger {
    color: var(--hr-danger);
    border-color: #fecaca;
    background: #fff;
}

.hr-page .btn-success { background: #059669; border-color: #059669; }

.hr-page .btn:disabled { opacity: .55; }

/* ---------- Alerts / empty ---------- */
.hr-alert {
    border-radius: 10px;
    border: 1px solid var(--hr-border);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 12px;
}

.hr-alert-error { background: var(--hr-danger-bg); border-color: #fecaca; color: #991b1b; }
.hr-alert-success { background: var(--hr-success-bg); border-color: #a7f3d0; color: #065f46; }
.hr-alert-warning { background: var(--hr-warning-bg); border-color: #fde68a; color: #92400e; }
.hr-alert-info { background: var(--hr-primary-soft); border-color: #bfdbfe; color: #1e40af; }

.hr-empty {
    padding: 36px 20px;
    text-align: center;
    color: var(--hr-muted);
}

.hr-empty-title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 700;
    color: #334155;
}

.hr-empty-text { margin: 0; font-size: 13px; }

/* ---------- Snapshot / overview ---------- */
.hr-snapshot-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 16px;
}

.hr-kv { min-width: 0; }
.hr-kv-label {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--hr-muted);
    margin-bottom: 3px;
}
.hr-kv-value {
    font-size: 13.5px;
    font-weight: 650;
    color: var(--hr-text);
    word-break: break-word;
}

.hr-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.hr-total {
    background: #f8fafc;
    border: 1px solid var(--hr-border);
    border-radius: 10px;
    padding: 8px 12px;
    min-width: 140px;
}

.hr-total span {
    display: block;
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--hr-muted);
}

.hr-total strong {
    display: block;
    margin-top: 2px;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.hr-total.is-net { background: var(--hr-primary-soft); border-color: #bfdbfe; }

.hr-stat-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.hr-stat {
    background: var(--hr-card);
    border: 1px solid var(--hr-border);
    border-radius: var(--hr-radius);
    box-shadow: var(--hr-shadow);
    padding: 12px 14px;
}

.hr-stat span {
    display: block;
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--hr-muted);
}

.hr-stat strong {
    display: block;
    margin-top: 4px;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

.hr-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.hr-calendar-dow {
    text-align: center;
    font-size: 11.5px;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--hr-muted);
    padding: 4px 0;
}

.hr-calendar-cell {
    min-height: 88px;
    border: 1px solid var(--hr-border);
    border-radius: 8px;
    padding: 6px;
    background: #fff;
}

.hr-calendar-cell.is-out {
    background: #f8fafc;
    color: #94a3b8;
}

.hr-calendar-day {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}

.hr-calendar-item {
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid var(--hr-primary);
    padding-left: 5px;
    margin-top: 3px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .hr-form-grid,
    .hr-snapshot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hr-field--wide { grid-column: span 2; }
}

@media (max-width: 768px) {
    .hr-form-grid,
    .hr-form-grid--2,
    .hr-snapshot-grid { grid-template-columns: 1fr; }
    .hr-field--wide,
    .hr-field--full { grid-column: auto; }
    .hr-employee-header { padding: 14px; }
    .hr-page-title { font-size: 1.2rem; }
    .hr-check-row { padding-top: 0; }
    .hr-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hr-calendar-cell { min-height: 64px; }
}

@media (max-width: 390px) {
    .hr-employee-avatar { width: 44px; height: 44px; font-size: 14px; }
    .hr-tab { padding: 9px 10px; font-size: 12.5px; }
    .hr-stat-row { grid-template-columns: 1fr; }
}
