:root {
    --bg-top: #0a5f8f;
    --bg-bottom: #12a8cf;
    --panel: #eef6fb;
    --panel-strong: #f7fbfe;
    --ink: #12324b;
    --muted: #53708a;
    --line: #c8dceb;
    --blue: #1773a8;
    --blue-dark: #0f5a84;
    --blue-soft: #dff4fb;
    --cyan: #1fb8db;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.16), transparent 24%),
        linear-gradient(145deg, var(--bg-top), var(--bg-bottom));
    min-height: 100vh;
}

.page-shell {
    width: min(1320px, calc(100% - 24px));
    margin: 12px auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    margin-bottom: 12px;
    background: rgba(238, 246, 251, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.44);
    border-radius: 24px;
    padding: 10px 14px;
    box-shadow: 0 16px 40px rgba(4, 31, 49, 0.16);
}

.topbar-side {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

.brand-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0;
    min-width: 0;
    flex: 1 1 auto;
    flex-wrap: wrap;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.brand-logo {
    width: 62px;
    height: auto;
    flex: 0 0 auto;
}

.brand-home {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.brand-copy {
    min-width: 0;
}

.brand-title-link {
    display: inline-block;
    text-decoration: none;
    font: 800 clamp(18px, 3vw, 28px)/1 "Segoe UI", sans-serif;
    color: #0b2740;
}

.brand-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font: 600 12px/1.2 "Segoe UI", sans-serif;
}

.dashboard-link {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 0;
    border-radius: 14px;
    border: 0;
    background: transparent;
    text-decoration: none;
    color: var(--blue-dark);
    box-shadow: none;
}

.dashboard-logo {
    width: 92px;
    height: auto;
    display: block;
}

.topbar-links {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.layout {
    display: grid;
    grid-template-columns: minmax(280px, 320px);
    gap: 16px;
}

.layout.single-column {
    grid-template-columns: minmax(320px, 420px);
}

.layout.has-preview {
    grid-template-columns: minmax(280px, 320px) 1fr;
}

.dashboard-stack {
    display: grid;
    gap: 16px;
}

.dashboard-stack-centered {
    justify-items: center;
}

.unit-selection-body {
    color: #18324a;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.78), transparent 28%),
        radial-gradient(circle at bottom right, rgba(174, 224, 237, 0.28), transparent 26%),
        linear-gradient(145deg, #eaf5fb 0%, #d6ebf5 45%, #eef8fc 100%);
}

.selection-topbar {
    margin-bottom: 18px;
    padding: 18px 22px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 28px;
    box-shadow: 0 24px 60px rgba(20, 57, 85, 0.12);
    backdrop-filter: blur(14px);
}

.selection-dashboard-link {
    gap: 0;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(28, 119, 168, 0.14);
    box-shadow: 0 10px 24px rgba(22, 83, 120, 0.08);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.selection-dashboard-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(22, 83, 120, 0.12);
    border-color: rgba(28, 119, 168, 0.24);
}

.unit-selection-panel {
    width: min(100%, 560px);
    margin: 0 auto;
    padding: 28px;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid rgba(255, 255, 255, 0.88);
    border-radius: 32px;
    box-shadow: 0 28px 70px rgba(18, 63, 94, 0.14);
    backdrop-filter: blur(16px);
}

.unit-selection-intro {
    width: 100%;
    margin: 0 auto 18px;
    text-align: center;
}

.unit-selection-intro h1 {
    margin: 0;
    font: 800 clamp(26px, 4vw, 34px)/1.06 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    letter-spacing: -0.04em;
    color: #0f2940;
}

.unit-grid {
    display: grid;
    gap: 14px;
}

.unit-grid-compact {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.unit-card {
    display: grid;
    gap: 18px;
    min-height: 0;
    padding: 20px 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 249, 253, 0.92)),
        rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(31, 117, 166, 0.1);
    border-radius: 26px;
    box-shadow: 0 18px 38px rgba(14, 59, 88, 0.09);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
}

.unit-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 28px 54px rgba(14, 59, 88, 0.14);
    border-color: rgba(31, 117, 166, 0.18);
}

.unit-card h3,
.unit-card p {
    margin: 0;
}

.unit-card h3 {
    text-align: center;
    font: 800 clamp(22px, 3vw, 28px)/1.02 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    letter-spacing: -0.03em;
    color: #102b43;
}

.unit-card .primary-button {
    justify-self: center;
}

.unit-card-button {
    min-height: 42px;
    min-width: 104px;
    padding: 10px 16px;
    font: 800 13px/1 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    letter-spacing: 0.01em;
    background: linear-gradient(135deg, #1682b6, #13638f);
    box-shadow: 0 12px 24px rgba(19, 99, 143, 0.22);
}

.unit-card-button:hover {
    box-shadow: 0 18px 30px rgba(19, 99, 143, 0.24);
}

@media (max-width: 720px) {
    .selection-topbar {
        padding: 16px;
        border-radius: 22px;
    }

    .unit-selection-panel {
        width: min(100%, 100%);
        padding: 22px 18px;
        border-radius: 24px;
    }

    .unit-grid-compact {
        grid-template-columns: 1fr;
        max-width: 360px;
    }

    .unit-selection-intro {
        margin-bottom: 18px;
    }

    .unit-card {
        min-height: 0;
    }
}

.panel,
.preview-wrapper {
    background: rgba(238, 246, 251, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 24px;
    box-shadow: 0 18px 42px rgba(5, 33, 53, 0.14);
}

.unit-panel {
    padding: 16px;
}

.form-panel {
    padding: 16px 16px 18px;
}

.form-panel h2 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 17px;
    color: var(--blue-dark);
}

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

.compact-heading {
    align-items: start;
}

.section-kicker {
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--blue);
    font: 700 10px/1.2 "Segoe UI", sans-serif;
}

.section-copy {
    margin: 0;
    color: var(--muted);
    font: 400 12px/1.4 "Segoe UI", sans-serif;
}

form label {
    display: block;
    margin-bottom: 10px;
}

form span {
    display: block;
    margin-bottom: 4px;
    font: 700 11px/1.15 "Segoe UI", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--blue-dark);
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #bfd5e6;
    border-radius: 12px;
    padding: 8px 10px;
    font: 400 12px/1.3 "Segoe UI", sans-serif;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

textarea {
    resize: vertical;
    min-height: 64px;
}

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

.search-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
}

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

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

.field-span-2 {
    grid-column: span 2;
}

.align-end {
    align-self: end;
}

.form-actions,
.preview-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.quick-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-shortcut-cell {
    align-self: end;
    justify-self: end;
}

.new-certificate-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 38px;
    padding: 8px 12px;
    gap: 7px;
    white-space: nowrap;
    border: 1px solid rgba(23, 115, 168, 0.16);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(237, 246, 252, 0.94));
    color: var(--blue-dark);
    font: 800 11px/1 "Segoe UI", sans-serif;
    letter-spacing: 0.03em;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(5, 33, 53, 0.08);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.new-certificate-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(5, 33, 53, 0.12);
    border-color: rgba(23, 115, 168, 0.24);
}

.new-certificate-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: #fff;
    font: 800 14px/1 "Segoe UI", sans-serif;
    box-shadow: 0 6px 14px rgba(23, 115, 168, 0.22);
}

.new-certificate-text {
    color: inherit;
}

.modal-card.modal-card-issue {
    width: min(420px, calc(100% - 32px)) !important;
    height: auto;
    min-height: 0;
}

.issue-modal-form {
    display: grid;
    gap: 12px;
}

.issue-modal-grid {
    margin-top: 0;
}

.issue-layout-field {
    margin: 0;
    opacity: 0.72;
}

.issue-layout-field span {
    margin-bottom: 3px;
    font-size: 9px;
    letter-spacing: 0.08em;
}

.issue-layout-field select {
    width: auto;
    min-width: 78px;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 10px;
}

.issue-modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: -2px;
}

.field-span-3 {
    grid-column: span 3;
}

.quick-filter-label {
    color: var(--blue-dark);
    font: 700 11px/1 "Segoe UI", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 2px;
}

.quick-filter-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 8px 14px;
    border: 1px solid rgba(23, 115, 168, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--blue-dark);
    font: 700 12px/1 "Segoe UI", sans-serif;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.quick-filter-chip:hover {
    transform: translateY(-1px);
}

.quick-filter-chip.is-active {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
}

.preview-clear {
    margin-left: auto;
}

.primary-button,
.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 10px 16px;
    font: 700 12px/1 "Segoe UI", sans-serif;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.primary-button {
    border: 0;
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
}

.ghost-button {
    border: 1px solid rgba(23, 115, 168, 0.2);
    color: var(--blue-dark);
    background: rgba(255, 255, 255, 0.72);
}

.primary-button:hover,
.ghost-button:hover {
    transform: translateY(-1px);
}

.help-box {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(223, 244, 251, 0.84), rgba(235, 249, 255, 0.92));
    color: var(--blue);
    font: 400 12px/1.4 "Segoe UI", sans-serif;
}

.help-box p {
    margin: 8px 0 0;
}

.help-box-warning {
    background: linear-gradient(180deg, rgba(255, 245, 210, 0.96), rgba(255, 249, 229, 0.96));
    color: #7b5b08;
}

.flash-banner {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 10000;
    max-width: min(280px, calc(100vw - 28px));
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(15, 90, 132, 0.14);
    font: 700 11px/1.2 "Segoe UI", sans-serif;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 8px 18px rgba(5, 33, 53, 0.12);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.flash-success {
    color: #0f5a84;
}

.flash-error {
    color: #8b2e2e;
}

.flash-banner.is-hidden {
    opacity: 0;
    transform: translateY(-6px);
}

.app-nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.app-nav-inline {
    padding: 0;
    margin-bottom: 0;
    margin-left: 8px;
}

.app-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 8px 14px;
    font: 700 12px/1 "Segoe UI", sans-serif;
    text-decoration: none;
    color: var(--blue-dark);
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(23, 115, 168, 0.16);
}

.app-nav a.active {
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
}

.preview-wrapper {
    padding: 16px;
}

.preview-note {
    margin-bottom: 10px;
    color: var(--muted);
    font: 400 12px/1.4 "Segoe UI", sans-serif;
}

.certificate-preview {
    overflow: auto;
    border-radius: 16px;
    border: 1px solid rgba(23, 115, 168, 0.14);
    background: #fff;
    padding: 10px;
}

.certificate-canvas {
    position: relative;
    width: 100%;
    min-width: 760px;
}

.certificate-bg {
    display: block;
    width: 100%;
    height: auto;
}

.certificate-overlay {
    position: absolute;
    inset: 0;
}

.preview-block {
    position: absolute;
    left: 34.8%;
    top: 38.8%;
    width: 56.8%;
    text-align: center;
    color: #111;
    font-family: Calibri, "Segoe UI", Arial, sans-serif;
}

.preview-name {
    font-size: clamp(28px, 2vw, 34px);
    font-weight: 700;
    line-height: 1.05;
    margin-bottom: 4px;
}

.preview-intro {
    font-size: clamp(11px, 0.85vw, 14px);
    line-height: 1.08;
    margin-bottom: 2px;
}

.preview-course {
    font-size: clamp(22px, 1.5vw, 28px);
    font-weight: 700;
    line-height: 1.08;
    margin-bottom: 10px;
}

.preview-body,
.preview-period {
    font-size: clamp(11px, 0.84vw, 13px);
    line-height: 1.03;
}

.preview-body {
    margin-bottom: 8px;
}

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

.top-gap {
    margin-top: 12px;
}

.top-gap-small {
    margin-top: 6px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font: 400 12px/1.4 "Segoe UI", sans-serif;
}

.data-table th,
.data-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(23, 115, 168, 0.12);
}

.data-table th {
    color: var(--blue-dark);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 10px;
}

.data-table a {
    color: var(--blue-dark);
    font-weight: 700;
    text-decoration: none;
}

.data-table-wide th,
.data-table-wide td {
    vertical-align: top;
}

.data-table-sticky-actions th:last-child,
.data-table-sticky-actions td:last-child {
    position: sticky;
    right: 0;
    background: rgba(238, 246, 251, 0.98);
}

.select-with-tool {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
    align-items: center;
}

.tool-button {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(23, 115, 168, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--blue-dark);
    font: 700 18px/1 "Segoe UI", sans-serif;
    cursor: pointer;
}

.tool-button-close {
    font-size: 16px;
}

.inline-form,
.mark-form-inline,
.action-menu-form {
    margin: 0;
}

.mark-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 270px;
}

.mark-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 8px 14px 8px 54px;
    border-radius: 999px;
    border: 1px solid rgba(23, 115, 168, 0.14);
    background: rgba(255, 255, 255, 0.88);
    color: var(--blue-dark);
    font: 700 11px/1 "Segoe UI", sans-serif;
    cursor: pointer;
    margin-bottom: 0;
    min-height: 38px;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.mark-toggle::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    width: 32px;
    height: 18px;
    border-radius: 999px;
    background: #d4e2ee;
    box-shadow: inset 0 1px 2px rgba(18, 50, 75, 0.16);
    transform: translateY(-50%);
    transition: background 0.18s ease;
}

.mark-toggle::after {
    content: "";
    position: absolute;
    left: 14px;
    top: 50%;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 2px 5px rgba(18, 50, 75, 0.18);
    transform: translateY(-50%);
    transition: left 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.mark-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mark-toggle span {
    margin-bottom: 0;
    color: inherit;
}

.mark-toggle-link {
    text-decoration: none;
}

.mark-toggle.is-checked {
    background: linear-gradient(135deg, rgba(23, 115, 168, 0.2), rgba(15, 90, 132, 0.12));
    border-color: rgba(23, 115, 168, 0.24);
    box-shadow: inset 0 0 0 1px rgba(23, 115, 168, 0.05);
}

.mark-toggle.is-checked::before {
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
}

.mark-toggle.is-checked::after {
    left: 28px;
}

.mark-toggle-printed-pending {
    background: linear-gradient(135deg, rgba(214, 77, 77, 0.18), rgba(176, 34, 34, 0.12));
    border-color: rgba(176, 34, 34, 0.24);
    color: #8f1f1f;
    box-shadow: inset 0 0 0 1px rgba(176, 34, 34, 0.05);
}

.mark-toggle-printed-pending::before {
    background: linear-gradient(135deg, #e05757, #b22222);
}

.mark-toggle-delivered {
    background: linear-gradient(135deg, rgba(245, 194, 66, 0.2), rgba(234, 179, 8, 0.12));
    border-color: rgba(202, 138, 4, 0.24);
    color: #8a5a00;
    box-shadow: inset 0 0 0 1px rgba(202, 138, 4, 0.05);
}

.mark-toggle-delivered::before {
    background: linear-gradient(135deg, #f7cf5d, #d6a61d);
}

.mark-toggle-delivered.is-checked {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.22), rgba(22, 163, 74, 0.14));
    border-color: rgba(22, 163, 74, 0.28);
    color: #166534;
    box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.06);
}

.mark-toggle-delivered.is-checked::before {
    background: linear-gradient(135deg, #22c55e, #15803d);
}

.mark-meta {
    color: var(--muted);
    font: 600 11px/1.3 "Segoe UI", sans-serif;
    white-space: nowrap;
}

.floating-action-menu {
    position: fixed;
    min-width: 180px;
    padding: 8px;
    border-radius: 16px;
    border: 1px solid rgba(23, 115, 168, 0.12);
    background: rgba(255, 255, 255, 0.99);
    box-shadow: 0 18px 34px rgba(5, 33, 53, 0.22);
    display: grid;
    gap: 6px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    transform-origin: center;
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}

.floating-action-menu.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.action-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid rgba(23, 115, 168, 0.16);
    background: rgba(255, 255, 255, 0.92);
    color: var(--blue-dark);
    cursor: pointer;
    font: 700 20px/1 "Segoe UI", sans-serif;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.action-menu-trigger:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(5, 33, 53, 0.12);
    background: rgba(255, 255, 255, 1);
}

.menu-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.menu-dots span {
    width: 4px;
    height: 4px;
    border-radius: 999px;
    background: currentColor;
    display: block;
}

.action-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    border: 0;
    border-radius: 12px;
    background: rgba(223, 244, 251, 0.44);
    color: var(--blue-dark);
    text-decoration: none;
    text-align: left;
    font: 700 12px/1.2 "Segoe UI", sans-serif;
    cursor: pointer;
}

.action-menu-item:hover {
    background: rgba(223, 244, 251, 0.8);
}

.action-menu-danger {
    color: #8b2e2e;
}

.table-actions-icons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(23, 115, 168, 0.16);
    background: rgba(255, 255, 255, 0.84);
    color: var(--blue-dark);
    text-decoration: none;
    font: 700 15px/1 "Segoe UI", sans-serif;
    cursor: pointer;
}

.icon-action-danger {
    color: #8b2e2e;
}

.public-panel {
    position: relative;
    overflow: hidden;
}

.public-preview-panel {
    overflow: visible;
}

.public-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-20deg);
    font: 800 clamp(28px, 7vw, 72px)/1 "Segoe UI", sans-serif;
    color: rgba(23, 115, 168, 0.1);
    white-space: nowrap;
    pointer-events: none;
}

.qr-panel {
    text-align: center;
}

.qr-panel-centered {
    width: min(100%, 720px);
    margin: 0 auto;
}

.qr-layout {
    width: min(100%, 640px);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 20px;
    align-items: start;
    text-align: left;
}

.qr-copy {
    min-width: 0;
}

.qr-copy .preview-actions,
.qr-copy .form-actions {
    justify-content: flex-start;
}

.qr-main-actions {
    gap: 10px;
}

.qr-main-actions .primary-button,
.qr-main-actions .ghost-button {
    min-width: 0;
}

.qr-back-action {
    margin-top: 8px;
}

.qr-side {
    display: grid;
    gap: 10px;
    justify-items: center;
}

.public-link-text {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.public-link-box {
    margin-top: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(23, 115, 168, 0.12);
}

.qr-card {
    display: inline-flex;
    justify-content: center;
    padding: 12px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(23, 115, 168, 0.12);
    box-shadow: 0 14px 34px rgba(5, 33, 53, 0.12);
}

.qr-card img {
    width: min(100%, 220px);
    height: auto;
    display: block;
}

.qr-link-actions {
    width: 100%;
    display: grid;
    gap: 8px;
}

.qr-link-actions .ghost-button {
    width: 100%;
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 30;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 28, 41, 0.56);
}

.modal-card {
    position: relative;
    width: min(920px, calc(100% - 32px));
    height: min(720px, calc(100% - 32px));
    margin: 16px auto;
    background: rgba(238, 246, 251, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.44);
    border-radius: 24px;
    box-shadow: 0 20px 48px rgba(5, 33, 53, 0.24);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-card iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
}

.modal-card-medium {
    width: min(960px, calc(100% - 32px));
    height: min(640px, calc(100% - 32px));
}

.modal-card-small {
    width: min(460px, calc(100% - 32px));
    height: auto;
    min-height: 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(23, 115, 168, 0.12);
}

.modal-content {
    padding: 16px;
}

.print-confirm-title {
    margin: 0;
    color: var(--blue-dark);
    font: 800 18px/1.2 "Segoe UI", sans-serif;
}

.print-confirm-actions {
    margin-top: 14px;
}

.print-hidden-frame {
    position: absolute;
    width: 1px;
    height: 1px;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.popup-body {
    background: transparent;
}

.popup-shell {
    padding: 12px;
}

.popup-stack {
    gap: 0;
}

.popup-panel {
    box-shadow: none;
}

.user-agent-cell {
    max-width: 340px;
    word-break: break-word;
}

.pdf-viewer-shell {
    position: relative;
    min-height: 78vh;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(23, 115, 168, 0.14);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.84);
}

.pdf-viewer-frame {
    display: block;
    width: 100%;
    min-height: 78vh;
    border: 0;
    background: #dbe9f3;
}

.public-mobile-card {
    display: none;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(23, 118, 168, 0.12);
    color: var(--ink);
}

.public-mobile-card strong,
.public-mobile-card p {
    margin: 0;
}

.public-mobile-card p {
    margin-top: 6px;
    color: var(--muted);
}

.public-details-grid {
    margin-bottom: 12px;
}

.public-header-inline h2 {
    margin: 0 0 8px;
}

.public-inline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    color: var(--muted);
    font: 600 12px/1.4 "Segoe UI", sans-serif;
}

.public-inline-meta span strong {
    color: var(--blue-dark);
    margin-right: 4px;
}

code {
    font-family: Consolas, monospace;
}

/* Global visual refresh */
:root {
    --bg-top: #0f6f98;
    --bg-bottom: #84d2de;
    --panel: #f3f8fb;
    --panel-strong: #fbfdff;
    --ink: #163247;
    --muted: #667f93;
    --line: rgba(39, 103, 143, 0.14);
    --blue: #1776a8;
    --blue-dark: #13597e;
    --blue-soft: #eef7fb;
    --cyan: #2ab6cf;
}

body {
    font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.18), transparent 24%),
        radial-gradient(circle at bottom left, rgba(255, 255, 255, 0.14), transparent 20%),
        linear-gradient(145deg, var(--bg-top), var(--bg-bottom));
}

.page-shell {
    width: min(1340px, calc(100% - 28px));
    margin: 14px auto;
}

.topbar {
    margin-bottom: 14px;
    padding: 12px 16px;
    background: rgba(250, 253, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 28px;
    box-shadow: 0 24px 54px rgba(12, 48, 71, 0.13);
    backdrop-filter: blur(12px);
}

.brand-card {
    gap: 16px;
}

.brand-title-link {
    font: 800 clamp(20px, 3vw, 30px)/1.02 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    letter-spacing: -0.04em;
    color: #0d2c44;
}

.brand-subtitle {
    margin-top: 5px;
    color: #647c90;
    font: 600 12px/1.25 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}

.dashboard-link {
    border-radius: 18px;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.dashboard-link:hover {
    transform: translateY(-1px);
    opacity: 0.94;
}

.panel,
.preview-wrapper {
    background: rgba(248, 252, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 28px;
    box-shadow: 0 24px 56px rgba(11, 48, 73, 0.12);
}

.unit-panel,
.form-panel,
.preview-wrapper {
    padding: 18px;
}

.section-kicker {
    margin: 0 0 8px;
    color: #1c7aa5;
    font: 800 10px/1.2 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    letter-spacing: 0.14em;
}

.section-heading h2,
.section-heading h3 {
    margin: 0;
    font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    letter-spacing: -0.03em;
    color: #102c43;
}

.section-copy {
    color: var(--muted);
    font: 500 14px/1.6 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}

label > span,
.search-grid label > span,
.grid-3 label > span {
    display: inline-block;
    margin-bottom: 7px;
    color: #155a82;
    font: 800 11px/1.2 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

input,
textarea,
select {
    border: 1px solid rgba(28, 116, 165, 0.16);
    border-radius: 16px;
    padding: 11px 13px;
    font: 500 14px/1.35 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    color: #18364b;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: rgba(23, 118, 168, 0.34);
    box-shadow: 0 0 0 4px rgba(23, 118, 168, 0.08);
    background: #fff;
}

.primary-button,
.ghost-button,
.app-nav a {
    min-height: 42px;
    padding: 11px 18px;
    border-radius: 999px;
    font: 800 13px/1 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    letter-spacing: 0.01em;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.primary-button {
    background: linear-gradient(135deg, #1b82b5, #145d85);
    box-shadow: 0 12px 26px rgba(20, 93, 133, 0.2);
}

.ghost-button,
.app-nav a {
    border: 1px solid rgba(23, 118, 168, 0.14);
    background: rgba(255, 255, 255, 0.84);
    color: #134c6f;
}

.primary-button:hover,
.ghost-button:hover,
.app-nav a:hover {
    transform: translateY(-1px);
}

.app-nav {
    gap: 8px;
}

.app-nav a.active {
    background: linear-gradient(135deg, #1b82b5, #145d85);
    box-shadow: 0 12px 24px rgba(20, 93, 133, 0.18);
}

.help-box {
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(28, 116, 165, 0.1);
}

.table-wrap {
    border-radius: 20px;
}

.data-table {
    font: 500 13px/1.45 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(23, 115, 168, 0.08);
}

.data-table th {
    color: #16577c;
    letter-spacing: 0.1em;
    font-size: 10px;
}

.data-table tbody tr {
    transition: background-color 0.16s ease;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.44);
}

.data-table-sticky-actions th:last-child,
.data-table-sticky-actions td:last-child {
    background: rgba(248, 252, 255, 0.96);
}

.modal-card,
.modal-card-medium,
.modal-card-small {
    border-radius: 26px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    box-shadow: 0 30px 70px rgba(11, 44, 66, 0.2);
}

@media (max-width: 1080px) {
    .layout,
    .layout.has-preview {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 960px) {
    .details-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .compact-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .page-shell {
        width: min(100% - 20px, 100%);
        margin: 10px auto 20px;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
    }

    .topbar-side {
        justify-content: flex-start;
    }

    .brand-card {
        min-width: 0;
        align-items: flex-start;
    }

    .brand-logo {
        width: 64px;
    }

    .dashboard-logo {
        width: 84px;
    }

    .form-panel,
    .preview-wrapper {
        padding: 18px;
        border-radius: 18px;
    }

    .unit-panel {
        padding: 14px;
    }

    .grid-3,
    .search-grid,
    .compact-grid-3,
    .compact-grid-4,
    .details-grid {
        grid-template-columns: 1fr;
    }

    .field-span-2 {
        grid-column: auto;
    }

    .select-with-tool {
        grid-template-columns: minmax(0, 1fr) 38px;
    }

    .preview-actions {
        width: 100%;
    }

    .preview-actions .primary-button,
    .preview-actions .ghost-button {
        width: 100%;
    }

    .qr-layout {
        grid-template-columns: 1fr;
        width: 100%;
        gap: 16px;
        text-align: center;
    }

    .qr-panel-centered {
        width: 100%;
    }

    .qr-copy .preview-actions,
    .qr-copy .form-actions {
        justify-content: center;
    }

    .qr-main-actions {
        flex-direction: column;
    }

    .qr-card {
        width: 100%;
        padding: 12px;
    }

    .qr-card img {
        width: min(100%, 260px);
        margin: 0 auto;
    }

    .public-mobile-card {
        display: block;
        margin-bottom: 12px;
    }

    .public-inline-meta {
        flex-direction: column;
        gap: 6px;
    }

    .public-panel .pdf-viewer-shell,
    .public-panel .help-box {
        display: none;
    }

    .pdf-viewer-shell {
        min-height: 56vh;
        border-radius: 16px;
    }

    .pdf-viewer-frame {
        min-height: 56vh;
        height: 56vh;
    }

    .modal-card,
    .modal-card-medium {
        width: calc(100% - 16px);
        height: calc(100% - 16px);
        margin: 8px auto;
        border-radius: 18px;
    }
}

@media print {
    @page {
        size: A4 landscape;
        margin: 0;
    }

    body {
        background: #fff;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .topbar,
    .form-panel,
    .preview-actions,
    .preview-note,
    .no-print {
        display: none !important;
    }

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

    .layout,
    .layout.has-preview {
        display: block;
    }

    .preview-wrapper {
        border: 0;
        box-shadow: none;
        background: transparent;
        padding: 0;
        margin: 0;
    }

    .certificate-preview,
    .pdf-viewer-shell {
        border: 0;
        border-radius: 0;
        background: transparent;
        padding: 0;
        overflow: visible;
        box-shadow: none;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .certificate-canvas {
        width: 100%;
        min-width: 0;
        break-inside: avoid;
    }

    .pdf-viewer-frame {
        min-height: auto;
        height: 100vh;
    }
}
