:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #667085;
    --line: #d9e0e7;
    --primary: #1f7a5a;
    --primary-dark: #146144;
    --danger: #b42318;
    --danger-soft: #fee4e2;
    --ok-soft: #dcfae6;
    --pending-soft: #fff3c6;
    --neutral-soft: #edf2f7;
    --shadow: 0 10px 30px rgba(20, 33, 45, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", "Malgun Gothic", Arial, sans-serif;
    line-height: 1.5;
}

a {
    color: var(--primary-dark);
    text-decoration: none;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 8px 14px;
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
}

button.primary,
.button.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

button.primary:hover,
.button.primary:hover {
    background: var(--primary-dark);
}

button.danger,
.button.danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 10px 11px;
    font: inherit;
}

input[readonly],
textarea[readonly] {
    background: #f8fafc;
    color: #667085;
}

textarea {
    resize: vertical;
}

label {
    display: grid;
    gap: 6px;
    color: #344054;
    font-weight: 600;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 18px;
}

.topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 24px;
    align-items: center;
    min-height: 68px;
    padding: 0 28px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    color: var(--text);
}

.brand-logo {
    width: 82px;
    height: 52px;
    display: block;
    flex: 0 0 auto;
    object-fit: contain;
}

.brand-text {
    display: grid;
    gap: 2px;
}

.brand-text span {
    color: var(--muted);
    font-size: 12px;
}

.brand-text strong {
    font-size: 17px;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topbar nav a {
    border-radius: 6px;
    color: #344054;
    padding: 8px 10px;
}

.topbar nav a:hover {
    background: var(--neutral-soft);
}

.shell {
    width: min(1240px, calc(100vw - 32px));
    margin: 18px auto 36px;
}

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

.login-panel {
    width: min(430px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 30px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.login-brand-logo {
    width: 88px;
    height: 48px;
    display: block;
    flex: 0 0 auto;
    object-fit: contain;
}

.login-brand-copy {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 10px;
    min-width: 0;
}

.login-panel h1 {
    margin-bottom: 6px;
}

.login-brand-copy h1 {
    margin: 0;
}

.login-brand-copy span {
    color: #344054;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.page-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-title p {
    margin: 6px 0 0;
    color: var(--muted);
}

.card,
.metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.card {
    padding: 18px;
}

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

.metric {
    display: grid;
    gap: 4px;
    padding: 18px;
}

.metric span,
.metric small,
.muted,
.hint,
.sub {
    color: var(--muted);
}

.metric strong {
    font-size: 30px;
}

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

.two-column.wide-left {
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
}

.document-view {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: start;
}

.document-view aside {
    display: grid;
    gap: 14px;
}

.document-body {
    min-height: 240px;
    white-space: normal;
}

.print-form {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.print-form-header {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(360px, 0.9fr);
    gap: 18px;
    align-items: start;
    margin-bottom: 16px;
}

.print-form-header h2 {
    font-size: 28px;
    margin: 4px 0 6px;
}

.form-kicker {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.compose-form {
    gap: 10px;
    padding: 18px;
}

.compose-form-header {
    grid-template-columns: minmax(300px, 1fr) minmax(390px, 0.9fr);
    gap: 14px;
    align-items: stretch;
    margin-bottom: 4px;
}

.form-selection-row {
    display: grid;
    grid-template-columns: minmax(150px, 0.45fr) minmax(220px, 1fr);
    gap: 10px;
    align-items: end;
    margin-top: 8px;
}

.form-table,
.approval-form-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin-top: 12px;
}

.form-table th,
.form-table td,
.approval-form-table th,
.approval-form-table td {
    border: 1px solid var(--line);
    padding: 10px;
    vertical-align: middle;
}

.form-table th {
    width: 12%;
    background: #f8fafc;
    color: #344054;
    text-align: center;
    font-weight: 700;
}

.form-table td {
    min-height: 42px;
    white-space: pre-line;
}

.approval-form-table {
    margin-top: 0;
}

.approval-form-table th {
    background: #f8fafc;
    color: #344054;
    text-align: center;
}

.approval-form-table td {
    height: 96px;
    text-align: center;
}

.approval-form-table td strong,
.approval-form-table td span,
.approval-form-table td small {
    display: block;
}

.approval-form-table td span,
.approval-form-table td small {
    color: var(--muted);
    font-size: 12px;
}

.approval-form-mark {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    margin: 5px 0;
}

.employment-certificate-form {
    width: min(794px, 100%);
    margin: 0 auto;
    padding: 34px 46px 48px;
    color: #111;
    font-family: "Batang", "Malgun Gothic", serif;
}

.certificate-no {
    min-height: 28px;
    font-size: 17px;
    font-weight: 700;
}

.certificate-title {
    margin: 18px 0 36px;
    text-align: center;
    font-family: "Batang", "Malgun Gothic", serif;
    font-size: 38px;
    font-weight: 800;
    letter-spacing: 0;
    text-decoration: underline;
    text-underline-offset: 7px;
}

.certificate-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 0;
    font-family: "Malgun Gothic", Arial, sans-serif;
    font-size: 14px;
}

.certificate-table th,
.certificate-table td {
    border: 1px solid #222;
    padding: 9px 8px;
    height: 38px;
    text-align: center;
    vertical-align: middle;
}

.certificate-table th {
    background: #d8eef2;
    color: #111;
    font-weight: 800;
}

.certificate-table td {
    background: #fff;
    font-weight: 600;
    word-break: keep-all;
    overflow-wrap: normal;
}

.certificate-table .certificate-group {
    width: 86px;
}

.certificate-group-col {
    width: 12%;
}

.certificate-label-col {
    width: 13%;
}

.certificate-sub-label-col {
    width: 11%;
}

.certificate-value-col {
    width: 25%;
}

.certificate-wide-value-col {
    width: 23%;
}

.certificate-statement {
    display: grid;
    gap: 22px;
    margin: 64px 0 38px;
    text-align: center;
    font-size: 19px;
    line-height: 1.8;
}

.certificate-statement p,
.certificate-recipient,
.certificate-issue-date,
.certificate-issuer p {
    margin: 0;
}

.certificate-recipient {
    margin-top: 18px;
    font-family: "Malgun Gothic", Arial, sans-serif;
    font-size: 16px;
    font-weight: 700;
}

.certificate-issue-date {
    margin-top: 72px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
}

.certificate-issuer {
    display: grid;
    gap: 14px;
    margin-top: 64px;
    text-align: center;
    font-size: 21px;
    font-weight: 800;
}

.seal-wrap {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 76px;
    height: 62px;
    margin-left: 4px;
    vertical-align: middle;
}

.seal-text {
    position: relative;
    z-index: 2;
}

.seal-wrap-pending {
    width: auto;
    height: auto;
    min-width: 76px;
}

.seal-pending {
    color: var(--muted);
    font-family: "Malgun Gothic", Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
}

.company-stamp {
    position: absolute;
    z-index: 1;
    width: 82px;
    height: 82px;
    object-fit: contain;
    opacity: 0.92;
}

.editable-approval-line {
    display: grid;
    gap: 6px;
}

.editable-approval-table td {
    height: 54px;
    padding: 4px 6px;
}

.editable-approval-table th {
    padding: 4px 6px;
    line-height: 1.2;
}

.editable-approval-table select {
    min-height: 32px;
    padding: 5px 8px;
}

.editable-approval-table strong,
.editable-approval-table span {
    line-height: 1.2;
}

.editable-approval-table [data-review-cell].muted {
    background: var(--neutral-soft);
}

.form-support-panels {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.doc-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.doc-meta div {
    display: grid;
    gap: 3px;
}

.doc-meta span {
    color: var(--muted);
    font-size: 13px;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 18px 0;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 8px;
    text-align: left;
    vertical-align: top;
}

th {
    color: #475467;
    font-size: 13px;
    font-weight: 700;
}

td .sub {
    display: block;
    font-size: 12px;
    margin-top: 2px;
}

.empty {
    color: var(--muted);
    text-align: center;
    padding: 22px 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 700;
}

.badge.ok {
    background: var(--ok-soft);
    color: #067647;
}

.badge.pending {
    background: var(--pending-soft);
    color: #92400e;
}

.badge.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge.neutral,
.badge.muted-badge {
    background: var(--neutral-soft);
    color: #475467;
}

.tabs,
.search-row,
.actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.tabs {
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.tabs a {
    padding: 9px 13px;
    border-radius: 6px;
    color: #344054;
}

.tabs a.active {
    background: #dff3ea;
    color: var(--primary-dark);
    font-weight: 700;
}

.search-row {
    margin-bottom: 14px;
}

.import-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.actions.compact {
    gap: 6px;
    flex-wrap: nowrap;
}

.actions.compact form {
    display: inline-flex;
}

.signature-cell {
    display: grid;
    gap: 8px;
    min-width: 126px;
}

.signature-picker,
.signature-thumb,
.signature-placeholder,
.approval-signature {
    display: block;
    width: 96px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.signature-picker {
    cursor: pointer;
    overflow: hidden;
}

.signature-picker:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.12);
}

.signature-thumb {
    object-fit: contain;
    border: 0;
}

.signature-placeholder {
    display: grid;
    place-items: center;
    padding: 4px;
    color: #344054;
    font-family: "Malgun Gothic", serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
}

.signature-input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    pointer-events: none;
}

.employee-info-row > td {
    background: #fbfcfe;
    padding: 0 8px 12px;
}

.employee-info-details {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    background: #fff;
}

.employee-info-details summary {
    cursor: pointer;
    color: #344054;
    font-weight: 800;
}

.employee-info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.employee-address-field {
    grid-column: span 4;
}

.address-search-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: stretch;
}

.address-search-control button {
    white-space: nowrap;
}

.approval-mark {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.approval-signature {
    width: 82px;
    height: 36px;
    object-fit: contain;
}

.admin-password-card {
    width: 100%;
}

.admin-password-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 10px;
    align-items: end;
}

button:disabled,
.button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.search-row input {
    max-width: 420px;
}

.form-card,
.stack {
    display: grid;
    gap: 16px;
}

.narrow {
    width: min(520px, 100%);
}

.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 14px;
}

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

fieldset {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

legend {
    padding: 0 6px;
    color: #344054;
    font-weight: 700;
}

.approver-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    gap: 10px;
}

.approval-stage-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
}

.approval-stage-card {
    display: grid;
    gap: 8px;
    min-height: 88px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.approval-stage-card strong {
    color: #344054;
}

.approval-stage-card span {
    color: var(--muted);
    font-size: 13px;
}

.approval-stage-card.muted {
    background: var(--neutral-soft);
}

.template-panels {
    display: grid;
    gap: 8px;
}

.template-panel[hidden] {
    display: none;
}

[data-template-basic][hidden] {
    display: none !important;
}

.template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.editable-form-panel {
    padding: 0;
    overflow: visible;
}

.editable-form-panel legend {
    font-size: 16px;
    font-weight: 800;
}

.editable-form-table {
    margin-top: 0;
    min-width: 0;
}

.editable-form-table td {
    padding: 5px;
}

.editable-form-table th {
    padding: 5px;
    font-size: 12px;
}

.editable-form-table .editable-form-input {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 4px;
    background: #fff;
    min-height: 32px;
    padding: 5px 7px;
    font: inherit;
}

.editable-form-table textarea.editable-form-input {
    min-height: 34px;
    resize: none;
}

.editable-form-table .editable-form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(36, 99, 235, 0.12);
    outline: none;
}

.date-range-inputs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 6px;
    align-items: center;
}

.bank-account-control {
    display: grid;
    grid-template-columns: minmax(96px, 0.45fr) minmax(160px, 1fr);
    gap: 6px;
    align-items: center;
}

.compose-footer {
    display: grid;
    grid-template-columns: minmax(260px, 0.75fr) minmax(320px, 1fr) auto;
    gap: 8px 12px;
    align-items: end;
}

.compose-footer .hint {
    margin: 0;
    align-self: center;
}

.compose-footer .actions {
    justify-content: end;
}

.date-range-inputs span {
    color: var(--muted);
    font-weight: 700;
}

.inline-user-form {
    display: contents;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.checkbox input {
    width: auto;
}

.approval-steps {
    list-style: none;
    display: grid;
    gap: 10px;
    margin: 14px 0 0;
    padding: 0;
}

.approval-steps li {
    display: grid;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px;
}

.approval-steps li > div {
    display: grid;
    gap: 2px;
}

.approval-steps span,
.approval-steps small {
    color: var(--muted);
    font-size: 13px;
}

.approval-stage-bypassed {
    background: var(--ok-soft);
}

.file-list,
.timeline {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.file-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 9px;
}

.file-list span,
.timeline span {
    color: var(--muted);
    font-size: 12px;
}

.timeline li {
    border-left: 3px solid var(--line);
    padding-left: 10px;
}

.timeline p {
    margin: 4px 0 0;
}

.flash {
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 12px 14px;
    font-weight: 700;
}

.flash.success {
    background: var(--ok-soft);
    color: #067647;
}

.flash.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.error-panel {
    width: min(700px, 100%);
}

code {
    background: var(--neutral-soft);
    border-radius: 5px;
    padding: 2px 5px;
}

@media (max-width: 980px) {
    .topbar,
    .page-title,
    .two-column,
    .two-column.wide-left,
    .document-view,
    .metric-grid,
    .form-grid,
    .doc-meta,
    .print-form-header,
    .form-selection-row,
    .form-support-panels,
    .approval-stage-grid,
    .bank-account-control,
    .admin-password-row,
    .compose-footer {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: start;
        padding: 14px 18px;
    }

    .approver-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .employee-info-grid {
        grid-template-columns: 1fr;
    }

    .employee-address-field {
        grid-column: auto;
    }

    .address-search-control {
        grid-template-columns: 1fr;
    }
}

@media print {
    @page {
        size: A4;
        margin: 8mm;
    }

    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body {
        background: #fff;
        color: #111;
        font-size: 12px;
        line-height: 1.32;
    }

    .topbar,
    .page-title,
    .flash,
    .no-print {
        display: none !important;
    }

    .shell {
        width: 100%;
        margin: 0;
    }

    .print-form {
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
        page-break-inside: avoid;
    }

    .print-form-header {
        grid-template-columns: minmax(190px, 1fr) minmax(330px, 0.9fr);
        gap: 8px;
        margin-bottom: 8px;
    }

    .print-form-header h2 {
        font-size: 22px;
    }

    .form-table,
    .approval-form-table {
        page-break-inside: avoid;
    }

    .form-table th,
    .form-table td,
    .approval-form-table th,
    .approval-form-table td {
        border-color: #222;
        padding: 5px;
    }

    .form-table th,
    .approval-form-table th {
        background: #f1f5f9;
    }

    .badge {
        border: 1px solid #98a2b3;
    }

    .approval-form-table td {
        height: 74px;
    }

    .approval-form-mark {
        min-height: 28px;
        margin: 3px 0;
    }

    .approval-signature {
        width: 72px;
        height: 30px;
    }

    .employment-certificate-form {
        width: 100%;
        padding: 9mm 12mm 10mm;
        font-size: 12px;
    }

    .certificate-title {
        margin: 12mm 0 13mm;
        font-size: 30px;
        text-underline-offset: 5px;
    }

    .certificate-no,
    .certificate-recipient {
        font-size: 13px;
    }

    .certificate-table th,
    .certificate-table td {
        padding: 5px;
        height: 30px;
        border-color: #111;
    }

    .certificate-statement {
        gap: 9mm;
        margin: 18mm 0 12mm;
        font-size: 16px;
    }

    .certificate-issue-date {
        margin-top: 22mm;
        font-size: 15px;
    }

    .certificate-issuer {
        gap: 5mm;
        margin-top: 17mm;
        font-size: 18px;
    }

    .company-stamp {
        width: 22mm;
        height: 22mm;
    }
}

@media (max-width: 640px) {
    .shell {
        width: min(100vw - 20px, 1240px);
        margin-top: 14px;
    }

    .approver-grid,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .topbar nav,
    .search-row,
    .import-row,
    .actions {
        align-items: stretch;
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .login-brand {
        align-items: flex-start;
        gap: 12px;
    }

    .login-brand-logo {
        width: 78px;
        height: 42px;
    }

    button,
    .button {
        width: 100%;
    }
}
