/* ================= BASE ================= */
* {
    box-sizing: border-box;
}

:root {
    --ink: #102033;
    --muted: #617089;
    --line: #cad7e5;
    --surface: #ffffff;
    --surface-soft: #f3f7f6;
    --deep: #083344;
    --deep-2: #0f3f4f;
    --teal: #0f766e;
    --mint: #d9f4ee;
    --gold: #d9982f;
    --gold-soft: #fff1d6;
    --green: #177245;
    --red: #b42318;
    --red-soft: #fff0ed;
    --blue-soft: #e7f0fa;
    --shadow: 0 18px 40px rgba(8, 51, 68, 0.12);
    --shadow-soft: 0 10px 22px rgba(8, 51, 68, 0.08);
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    line-height: 1.5;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.14), rgba(217, 152, 47, 0.13) 42%, rgba(8, 51, 68, 0.08)),
        var(--surface-soft);
}

a {
    color: var(--teal);
    font-weight: 800;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ================= APP CHROME ================= */
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    min-height: 76px;
    padding: 12px clamp(16px, 4vw, 42px);
    background: linear-gradient(90deg, #062f3d, #0f766e);
    border-bottom: 3px solid var(--gold);
    box-shadow: 0 12px 30px rgba(8, 51, 68, 0.2);
}

.brand {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 260px;
}

.brand-logo {
    width: 48px;
    height: 48px;
    padding: 5px;
    border-radius: 50%;
    background: #ffffff;
    object-fit: contain;
}

.brand-name {
    font-size: 17px;
    font-weight: 900;
    color: #ffffff;
}

.brand-location {
    margin-top: 1px;
    font-size: 12px;
    color: #ccefe8;
    text-transform: uppercase;
    letter-spacing: 0;
    font-weight: 800;
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.top-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 13px;
    border-radius: 7px;
    color: #f6fffc;
    font-size: 14px;
    font-weight: 800;
}

.top-nav a:hover,
.top-nav a.active {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    text-decoration: none;
}

.top-nav .logout-link {
    background: var(--gold-soft);
    color: #8a3c08;
}

.top-nav .logout-link:hover {
    background: #ffe2ad;
    color: #6f2f03;
}

.page-shell {
    width: min(1460px, 94vw);
    margin: 0 auto;
    padding: 32px 0 48px;
}

.page-title {
    margin-bottom: 24px;
    padding: 20px 0 6px;
}

.page-title p {
    margin: 0 0 5px;
    color: #315768;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

h1,
.page-title h1 {
    margin: 0;
    padding: 0;
    background: transparent;
    color: var(--deep);
    text-align: left;
    font-size: clamp(30px, 3.2vw, 44px);
    font-weight: 900;
}

h2,
h3 {
    margin: 0 0 16px;
    color: var(--deep);
    text-align: left;
}

/* ================= PANELS ================= */
.container,
.form-box,
.panel {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto 22px;
    padding: 24px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 118, 110, 0.18);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.container.wide {
    max-width: 1460px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.increment-title {
    margin-top: 22px;
}

.actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.alert {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-left-width: 5px;
    border-radius: 8px;
    background: #f8fafc;
    font-weight: 800;
}

.alert.success {
    border-left-color: var(--green);
    background: #eaf8ef;
    color: #14532d;
}

.alert.error {
    border-left-color: var(--red);
    background: var(--red-soft);
    color: var(--red);
}

.alert.warning {
    border-left-color: var(--gold);
    background: var(--gold-soft);
    color: #7a4b00;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--mint);
    color: var(--deep);
    font-size: 12px;
    font-weight: 900;
}

.badge.success {
    background: #e9f8ef;
    color: var(--green);
}

.badge.warning {
    background: var(--gold-soft);
    color: #7a4b00;
}

/* ================= DASHBOARD ================= */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin: 0;
    max-width: none;
}

.dashboard-section {
    margin-bottom: 30px;
}

.dashboard-section h2 {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 21px;
    font-weight: 900;
}

.dashboard-section h2::before {
    content: "";
    display: inline-block;
    width: 9px;
    height: 28px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--gold), var(--teal));
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 142px;
    padding: 20px;
    overflow: hidden;
    background: linear-gradient(145deg, #ffffff 0%, #f5fbf8 100%);
    border: 1px solid rgba(15, 118, 110, 0.22);
    border-radius: 10px;
    color: var(--ink);
    box-shadow: var(--shadow-soft);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
    background: linear-gradient(180deg, var(--teal), var(--gold));
}

.card::after {
    content: "";
    position: absolute;
    right: -34px;
    top: -34px;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: rgba(217, 152, 47, 0.13);
}

.card:hover {
    transform: translateY(-4px);
    border-color: rgba(15, 118, 110, 0.42);
    box-shadow: 0 18px 36px rgba(8, 51, 68, 0.17);
    text-decoration: none;
}

.card-kicker {
    position: relative;
    z-index: 1;
    color: #406172;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.card-title {
    position: relative;
    z-index: 1;
    margin-top: 12px;
    font-size: 19px;
    font-weight: 900;
    color: var(--deep);
}

.card-danger,
.danger {
    background: linear-gradient(145deg, #ffffff 0%, #fff6f3 100%);
    border-color: #ffc7bc;
}

.card-danger::before {
    background: linear-gradient(180deg, var(--red), var(--gold));
}

.card-danger .card-title,
.danger {
    color: var(--red);
}

/* ================= FORMS ================= */
form {
    margin: 0;
}

label {
    display: block;
    margin: 14px 0 6px;
    color: #344054;
    font-size: 13px;
    font-weight: 900;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid #a9bdc8;
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(15, 118, 110, 0.18);
    border-color: var(--teal);
}

.form-grid,
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.row {
    margin-top: 14px;
    padding: 14px;
    border: 1px solid rgba(15, 118, 110, 0.2);
    border-radius: 10px;
    background: #f7fcf9;
}

.copy-box,
.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--deep);
    font-size: 13px;
    font-weight: 800;
}

.copy-box {
    min-width: 150px;
    color: var(--muted);
    font-size: 12px;
}

.copy-box input,
.inline-check input {
    width: auto;
    min-height: auto;
}

.employee-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
}

.employee-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 12px;
    border: 1px solid rgba(15, 118, 110, 0.2);
    border-radius: 10px;
    background: #f8fdfb;
    cursor: pointer;
}

.employee-option:hover {
    border-color: rgba(15, 118, 110, 0.45);
    background: #ecfaf5;
}

.employee-option input {
    width: auto;
    min-height: auto;
    margin-top: 3px;
}

.employee-option small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.option-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 16px;
}

.qr-box {
    display: flex;
    align-items: center;
    gap: 22px;
    flex-wrap: wrap;
    margin-top: 18px;
    padding: 18px;
    border: 1px solid rgba(15, 118, 110, 0.2);
    border-radius: 12px;
    background: #f7fcf9;
}

.qr-box img {
    width: 220px;
    height: 220px;
    padding: 10px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid var(--line);
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--deep), var(--teal));
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 900;
    line-height: 1.2;
}

button:hover,
.btn:hover {
    background: linear-gradient(135deg, #062a38, #0c635d);
    color: #ffffff;
    text-decoration: none;
}

.btn-secondary,
button.secondary {
    background: var(--gold-soft);
    color: #7a4b00;
    border-color: #f2c471;
}

.btn-secondary:hover,
button.secondary:hover {
    background: #ffe1a6;
    color: #583500;
}

.btn-danger,
button.danger {
    background: linear-gradient(135deg, var(--red), #8f1f16);
}

.btn-danger:hover,
button.danger:hover {
    background: #7f1d1d;
}

.btn-success,
button.add {
    background: linear-gradient(135deg, var(--teal), #12977f);
}

.btn-success:hover,
button.add:hover {
    background: #0b5f59;
}

/* ================= TABLES ================= */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    border: 1px solid rgba(15, 118, 110, 0.18);
    border-radius: 10px;
    background: #ffffff;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    background: #ffffff;
    font-size: 13px;
}

.table-wrapper table {
    margin-top: 0;
}

.table-wrapper input {
    min-width: 120px;
}

th,
td {
    border: 1px solid #d5e0e7;
    padding: 9px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #dff4ef;
    color: var(--deep);
    font-weight: 900;
    white-space: nowrap;
}

tr:nth-child(even) td {
    background: #f7fbfa;
}

.amount,
.num,
td.amount,
td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 15px 0;
    font-weight: 900;
}

/* ================= LETTER PDF ================= */
.letter-page {
    width: 210mm;
    min-height: 297mm;
    margin: 24px auto;
    padding: 18mm 18mm 22mm;
    background: #ffffff;
    color: #000000;
    box-shadow: var(--shadow);
    font-family: "Times New Roman", Times, serif;
    font-size: 14pt;
    line-height: 1.35;
}

.letter-head {
    padding-bottom: 4px;
    border-bottom: 2px solid #000000;
    text-align: center;
    font-size: 17pt;
    font-weight: 800;
    line-height: 1.25;
}

.letter-meta {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 4px;
}

.letter-block {
    margin-top: 24px;
}

.letter-indent {
    margin-left: 60px;
}

.letter-subject {
    display: flex;
    gap: 12px;
    margin-top: 26px;
}

.letter-body {
    margin-top: 20px;
    text-align: justify;
}

.letter-table {
    width: 100%;
    margin-top: 18px;
    border-collapse: collapse;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10.5pt;
}

.letter-table th,
.letter-table td {
    border: 1px solid #000000;
    padding: 6px 7px;
    color: #000000;
}

.letter-table th {
    position: static;
    background: #f2f2f2;
    font-weight: 800;
}

.letter-table.compact {
    font-size: 9pt;
}

.letter-closing {
    margin-top: 34px;
    margin-left: auto;
    width: 270px;
    text-align: center;
}

/* ================= EMPLOYEE RECORD ================= */
.record-sheet {
    width: min(100%, 980px);
    margin: 0 auto 28px;
    padding: 28px;
    background: #ffffff;
    border: 1px solid rgba(15, 118, 110, 0.18);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.record-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 14px;
    border-bottom: 3px solid var(--deep);
}

.record-header p {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.record-header h1 {
    font-size: 25px;
}

.record-header h2 {
    margin: 5px 0 0;
    color: var(--teal);
    font-size: 18px;
}

.record-header img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.record-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 18px 0;
}

.record-summary div {
    padding: 11px;
    border: 1px solid #d5e0e7;
    border-radius: 8px;
    background: #f7fcf9;
}

.record-summary span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.record-summary strong {
    display: block;
    margin-top: 3px;
    overflow-wrap: anywhere;
    color: var(--deep);
    font-size: 14px;
}

.record-sheet h3 {
    margin-top: 22px;
}

.record-table {
    table-layout: fixed;
    margin-top: 8px;
}

.record-table th {
    width: 32%;
}

.record-table th,
.record-table td {
    overflow-wrap: anywhere;
}

.record-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 34px;
    padding-top: 18px;
    color: var(--deep);
    font-weight: 900;
}

/* ================= LOGIN ================= */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(rgba(6, 47, 61, 0.74), rgba(15, 118, 110, 0.78)),
        url("bg.jpg") center / cover no-repeat;
}

.login-box {
    width: min(410px, 100%);
    padding: 30px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
}

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

.login-brand img {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.login-brand h1 {
    font-size: 21px;
    line-height: 1.2;
}

.login-brand p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.login-box button {
    width: 100%;
    margin-top: 8px;
}

/* ================= PRINT ================= */
@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body {
        background: #ffffff;
        color: #000000;
    }

    .no-print,
    .app-header,
    .page-title {
        display: none !important;
    }

    .page-shell,
    .container,
    .form-box,
    .panel {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
    }

    th {
        position: static;
        background: #ffffff;
    }

    th,
    td {
        border-color: #000000;
    }

    .letter-page {
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        padding: 18mm 18mm 22mm;
        box-shadow: none;
        page-break-after: always;
    }

    .record-sheet {
        width: 100%;
        margin: 0;
        padding: 12mm;
        border: none;
        border-radius: 0;
        box-shadow: none;
        font-size: 10.5pt;
    }

    .record-header h1 {
        font-size: 18pt;
    }

    .record-header h2 {
        font-size: 13pt;
    }

    .record-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .record-summary div {
        background: #ffffff;
        border-color: #000000;
    }

    .record-table {
        page-break-inside: auto;
        font-size: 9.5pt;
    }

    .record-table tr {
        page-break-inside: avoid;
    }
}

@media (max-width: 760px) {
    .app-header {
        position: static;
        align-items: flex-start;
        flex-direction: column;
    }

    .top-nav {
        justify-content: flex-start;
    }

    .page-shell {
        width: min(100% - 24px, 1460px);
        padding-top: 20px;
    }

    .container,
    .form-box,
    .panel {
        padding: 18px;
    }

    .header-row,
    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .letter-page {
        width: 100%;
        min-height: auto;
        padding: 18px;
        font-size: 12pt;
    }

    .letter-meta,
    .letter-subject {
        flex-direction: column;
        gap: 4px;
    }

    .letter-indent {
        margin-left: 24px;
    }
}
