:root {
    --primary: #2563eb;
    --ink: #111827;
    --muted: #6b7280;
    --line: #dbe3ef;
    --panel: #ffffff;
    --soft: #f3f6fb;
    --sidebar: #182230;
}

body {
    color: var(--ink);
    background: var(--soft);
}

.form-navbar-brand {
    display: inline-flex;
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
}

.form-navbar-brand img {
    display: block;
    width: 72px;
    max-height: 34px;
    object-fit: contain;
}

.eyebrow {
    color: var(--primary);
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

.public-shell {
    width: min(960px, 100%);
}

.public-hero {
    margin-bottom: 24px;
}

.hero-logo {
    display: block;
    width: min(300px, 72%);
    height: auto;
    margin: 0 auto 16px;
}

.department-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 16px;
}

.department-card {
    min-height: 184px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 20px 14px;
    text-align: center;
    text-decoration: none;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
    transition: transform .15s ease, border-color .15s ease;
}

.department-card:hover,
.department-card.active {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.department-icon {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: #eaf2ff;
    border-radius: 8px;
}

.department-icon svg {
    width: 32px;
    height: 32px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.department-code {
    font-size: 1.45rem;
    line-height: 1;
    font-weight: 800;
}

.department-name {
    min-height: 42px;
    display: flex;
    align-items: center;
    color: #334155;
    font-size: .92rem;
    font-weight: 700;
    line-height: 1.25;
}

.department-card small {
    color: var(--muted);
}

.form-menu-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 16px;
}

.scheme-grid {
    display: flex;
    justify-content: center;
    width: 100%;
}

.scheme-card {
    width: min(420px, 100%);
    margin-inline: auto;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
}

.public-page [hidden] {
    display: none !important;
}

.selected-scheme-info {
    margin: 24px auto 20px;
}

.selected-scheme-info h2 {
    margin: 0 0 10px;
    color: var(--ink);
    font-size: clamp(1.35rem, 3vw, 1.8rem);
    font-weight: 700;
}

.selected-scheme-info p {
    margin: 0;
    color: #334155;
    font-size: 1.1rem;
    font-weight: 700;
}

.tkj-forms {
    margin-top: 20px;
}

.form-menu-card {
    min-height: 170px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 24px;
    text-align: center;
    text-decoration: none;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
    transition: transform .15s ease, border-color .15s ease;
}

.form-menu-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.form-menu-card strong {
    font-size: 1.45rem;
    line-height: 1;
}

.form-menu-card span:last-child {
    color: #334155;
    font-weight: 700;
}

.form-menu-icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: #eaf2ff;
    border-radius: 8px;
}

.form-menu-icon svg {
    width: 32px;
    height: 32px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.apl02-table th:nth-child(2),
.apl02-table th:nth-child(3),
.apl02-table td:nth-child(2),
.apl02-table td:nth-child(3) {
    width: 64px;
}

.apl02-table th:first-child {
    min-width: 340px;
}

.apl02-table th:last-child {
    min-width: 260px;
}

.apl02-criteria {
    margin: 10px 0 0;
    padding-left: 18px;
    color: #475569;
    font-size: .92rem;
}

.form-page .navbar {
    box-shadow: 0 4px 18px rgba(15, 23, 42, .04);
}

.form-heading,
.form-section,
.notice-panel,
.success-panel,
.login-card,
.admin-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
}

.form-heading {
    padding: 24px;
    margin-bottom: 16px;
}

.form-section {
    padding: 24px;
    margin-bottom: 16px;
}

.form-section h2,
.admin-panel h2 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 16px;
}

.form-section h3,
.detail-grid h3 {
    font-size: .95rem;
    font-weight: 800;
    margin-bottom: 12px;
}

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

.signature-box {
    width: 100%;
    border: 1px dashed #94a3b8;
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.signature-box canvas {
    display: block;
    width: 100%;
    height: 220px;
    cursor: crosshair;
    touch-action: none;
}

.notice-panel,
.success-panel,
.login-card {
    width: min(460px, 100%);
    padding: 28px;
}

.login-logo {
    display: block;
    width: 108px;
    max-width: 38%;
    max-height: 108px;
    height: auto;
    object-fit: contain;
    margin: 0 auto 16px;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 20px;
}

.registration-number {
    display: inline-flex;
    padding: 10px 14px;
    border-radius: 8px;
    background: #eaf2ff;
    color: #1d4ed8;
    font-weight: 800;
}

.admin-page {
    min-height: 100vh;
}

.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    padding: 20px 16px;
    background: var(--sidebar);
    color: #fff;
}

.admin-sidebar-header {
    display: block;
}

.admin-sidebar-toggle {
    display: none;
}

.admin-sidebar-nav {
    display: flex !important;
}

.admin-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 116px;
    margin-bottom: 18px;
}

.admin-brand img {
    display: block;
    width: min(214px, 100%);
    height: auto;
    max-height: 108px;
    object-fit: contain;
}

.admin-sidebar .nav-link {
    color: #cbd5e1;
    border-radius: 8px;
    margin-bottom: 6px;
}

.admin-sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

.admin-sidebar .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, .14);
}

.admin-main {
    margin-left: 248px;
}

.admin-topbar {
    min-height: 82px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.admin-topbar h1 {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0;
}

.admin-user {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    text-align: right;
}

.admin-user strong {
    color: #334155;
    font-size: .95rem;
}

.admin-content {
    padding: 24px;
}

.metric-card {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 18px;
    color: #fff;
    border-radius: 8px;
}

.metric-card span {
    font-weight: 700;
}

.metric-card strong {
    font-size: 2rem;
}

.accent-blue { background: #2563eb; }
.accent-green { background: #059669; }
.accent-yellow { background: #ca8a04; }
.accent-red { background: #dc2626; }

.department-color-dpib { background: #7c3aed; }
.department-color-titl { background: #059669; }
.department-color-tkj { background: #2563eb; }
.department-color-tlas { background: #c2410c; }
.department-color-tpem { background: #0e7490; }
.department-color-tkr { background: #dc2626; }
.department-color-gsp { background: #a16207; }
.department-color-default { background: #475569; }

.admin-panel {
    padding: 20px;
    margin-bottom: 16px;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.panel-heading h2 {
    margin-bottom: 0;
}

.tuk-scheme-table {
    table-layout: fixed;
    width: 100%;
    min-width: 980px;
}

.tuk-scheme-no,
.tuk-scheme-no-col {
    width: 72px;
}

.tuk-scheme-code,
.tuk-scheme-code-col {
    width: 420px;
}

.tuk-scheme-action,
.tuk-scheme-action-col {
    width: 170px;
}

.tuk-scheme-name,
.tuk-scheme-name-col {
    width: auto;
}

.tuk-scheme-table th,
.tuk-scheme-table td {
    overflow-wrap: anywhere;
    vertical-align: middle;
}

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

dl {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 8px 14px;
    margin: 0;
}

dt {
    color: var(--muted);
    font-weight: 700;
}

dd {
    margin: 0;
}

.signature-preview {
    min-height: 180px;
    display: grid;
    place-items: center;
    border: 1px dashed #94a3b8;
    border-radius: 8px;
    background: #fff;
}

.signature-preview img {
    max-width: 100%;
    max-height: 180px;
}

@media (max-width: 900px) {
    .department-grid,
    .form-menu-grid,
    .option-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
        width: 100%;
        padding: 10px 12px;
    }

    .admin-sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .admin-brand {
        min-height: 0;
        justify-content: flex-start;
        margin-bottom: 0;
    }

    .admin-brand img {
        width: min(150px, 100%);
        max-height: 56px;
    }

    .admin-sidebar-toggle {
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .admin-sidebar-nav {
        display: none !important;
        padding-top: 10px;
    }

    .admin-sidebar-nav.show {
        display: flex !important;
    }

    .admin-main {
        margin-left: 0;
    }

    .admin-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-user {
        align-items: flex-start;
        justify-content: flex-start;
        flex-direction: column;
        text-align: left;
    }

    dl {
        grid-template-columns: 1fr;
    }
}

@media print {
    .admin-sidebar,
    .admin-topbar,
    .btn {
        display: none !important;
    }

    .admin-main {
        margin-left: 0;
    }

    .admin-content {
        padding: 0;
    }
}
