:root {
    color-scheme: light;
    --bg: #f3f7f6;
    --bg-strong: #e7efed;
    --surface: #ffffff;
    --surface-soft: #f7faf9;
    --surface-muted: #edf3f1;
    --border: #9bb2b6;
    --border-strong: #8fa9ad;
    --text: #1b262c;
    --muted: #65777b;
    --primary: #467b79;
    --primary-dark: #345d5c;
    --primary-soft: #e8f3f2;
    --accent: #b69256;
    --accent-soft: #fbf3e1;
    --warning: #b69256;
    --warning-soft: #fbf3e1;
    --danger: #b85a5a;
    --danger-soft: #fff1f1;
    --success: #3f8b74;
    --success-soft: #ebf7f2;
    --info: #5a8798;
    --info-soft: #edf5f8;
    --shadow: 0 14px 38px rgba(28, 43, 46, 0.08);
    --shadow-lg: 0 24px 60px rgba(28, 43, 46, 0.12);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

html.dark {
    color-scheme: dark;
    --bg: #0d1418;
    --bg-strong: #090f12;
    --surface: #162126;
    --surface-soft: #1b2930;
    --surface-muted: #22333a;
    --border: #39525a;
    --border-strong: #4f6f78;
    --text: #f2f7f5;
    --muted: #b3c1c0;
    --primary: #78b9ad;
    --primary-dark: #5d9d94;
    --primary-soft: rgba(120, 185, 173, 0.15);
    --accent: #e1bf7f;
    --accent-soft: rgba(225, 191, 127, 0.16);
    --warning: #e1bf7f;
    --warning-soft: rgba(225, 191, 127, 0.16);
    --danger: #ef9b9b;
    --danger-soft: rgba(239, 155, 155, 0.16);
    --success: #85c7ad;
    --success-soft: rgba(133, 199, 173, 0.16);
    --info: #9ec6d6;
    --info-soft: rgba(158, 198, 214, 0.16);
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
    --shadow-lg: 0 30px 70px rgba(0, 0, 0, 0.46);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Inter", "Inter var", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(70, 123, 121, 0.12), transparent 24%),
        radial-gradient(circle at top right, rgba(90, 135, 152, 0.08), transparent 18%),
        linear-gradient(180deg, #f9fbfa 0%, var(--bg) 100%);
}

html.dark body {
    background:
        radial-gradient(circle at top left, rgba(120, 185, 173, 0.12), transparent 24%),
        radial-gradient(circle at top right, rgba(225, 191, 127, 0.08), transparent 18%),
        linear-gradient(180deg, #0a1013 0%, var(--bg) 52%, #090e11 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none !important;
    outline-offset: 0;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

*,
*:focus,
*:focus-visible,
*:focus-within {
    -webkit-tap-highlight-color: transparent;
}

img {
    display: block;
    max-width: 100%;
}

.ui-icon {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    display: inline-block;
    vertical-align: middle;
}

.ui-icon-xs {
    width: 0.95rem;
    height: 0.95rem;
}

.ui-icon-sm {
    width: 1rem;
    height: 1rem;
}

.ui-icon-lg {
    width: 2.2rem;
    height: 2.2rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: transform 0.16s ease, opacity 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}

.button:hover {
    transform: translateY(-1px);
}

.button:active:not(:disabled) {
    transform: translateY(2px) scale(0.97);
    box-shadow:
        inset 0 3px 8px rgba(15, 23, 42, 0.24),
        0 2px 5px rgba(15, 23, 42, 0.14);
    filter: brightness(0.96);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.is-disabled-button {
    cursor: not-allowed;
    opacity: 0.7;
    pointer-events: none;
}

.button-primary {
    background: linear-gradient(180deg, #4a8482 0%, #3b6f6d 100%);
    color: #ffffff;
    box-shadow: 0 10px 18px rgba(70, 123, 121, 0.22);
}

.button-save {
    border-color: #3b6f6d;
    background: linear-gradient(180deg, #4f8f8c 0%, #3b6f6d 100%);
    color: #ffffff;
    box-shadow: 0 10px 18px rgba(70, 123, 121, 0.22);
}

.button-light {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
    color: var(--text);
    border-color: var(--border);
}

.button-cancel {
    border-color: #bd5f5f;
    background: #b85a5a;
    color: #ffffff;
}

.button-cancel:hover {
    border-color: #9f3333;
    background: #9f3333;
    color: #ffffff;
}

.button-secondary {
    background: linear-gradient(180deg, #eef6f8 0%, #e3edf1 100%);
    color: var(--info);
    border-color: #cfdee3;
}

.form-control,
.form-select {
    width: 100%;
    min-height: 42px;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    color: var(--text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

:where(.card, .dropdown-menu, .modal-content, .list-group-item, .table, .form-control, .form-select, .input-group-text, .button-light) {
    border-color: var(--border) !important;
}

.form-control::placeholder,
textarea.form-control::placeholder,
input.form-control::placeholder {
    color: color-mix(in srgb, var(--muted) 82%, transparent);
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: rgba(70, 123, 121, 0.48);
    box-shadow: 0 0 0 4px rgba(70, 123, 121, 0.12);
    background: #ffffff;
}

textarea.form-control {
    min-height: 110px;
    resize: vertical;
}

.form-error {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(178, 68, 68, 0.16);
    background: linear-gradient(180deg, rgba(255, 251, 251, 0.98), rgba(255, 241, 241, 0.94));
    color: var(--danger);
    font-size: 0.92rem;
}

.message-stack {
    display: grid;
    gap: 12px;
}

.message-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 254, 0.95));
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.message-item::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--info);
    flex: 0 0 auto;
}

.message-success {
    border-color: #c8e7d7;
    background: linear-gradient(180deg, #f4fbf7 0%, #edf8f1 100%);
}

.message-success::before {
    background: var(--success);
}

.message-warning {
    border-color: #edd8b1;
    background: linear-gradient(180deg, #fffdf7 0%, #fff5e3 100%);
}

.message-warning::before {
    background: var(--accent);
}

.message-error,
.message-danger {
    border-color: #eccccc;
    background: linear-gradient(180deg, #fff8f8 0%, #fff1f1 100%);
}

.message-error::before,
.message-danger::before {
    background: var(--danger);
}

.is-toast-source-hidden {
    display: none !important;
}

.sige-toast-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 2147483000;
    width: min(380px, calc(100vw - 32px));
    display: grid;
    gap: 10px;
    pointer-events: none;
}

.sige-toast {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) 30px;
    align-items: start;
    gap: 12px;
    padding: 14px 14px;
    border: 1px solid rgba(126, 155, 165, 0.24);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    color: #172a34;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    pointer-events: auto;
}

.sige-toast-mark {
    width: 10px;
    height: 10px;
    margin-top: 6px;
    border-radius: 999px;
    background: var(--info);
}

.sige-toast p {
    margin: 0;
    line-height: 1.45;
    font-size: 0.92rem;
    font-weight: 700;
}

.sige-toast-close {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    color: inherit;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}

.sige-toast-close:hover {
    background: rgba(15, 23, 42, 0.14);
}

.sige-toast-success {
    border-color: rgba(55, 143, 104, 0.24);
    background: rgba(241, 251, 246, 0.96);
}

.sige-toast-success .sige-toast-mark {
    background: var(--success);
}

.sige-toast-warning {
    border-color: rgba(198, 138, 59, 0.28);
    background: rgba(255, 250, 238, 0.96);
}

.sige-toast-warning .sige-toast-mark {
    background: var(--accent);
}

.sige-toast-error {
    border-color: rgba(178, 68, 68, 0.24);
    background: rgba(255, 246, 246, 0.96);
}

.sige-toast-error .sige-toast-mark {
    background: var(--danger);
}

.app-shell {
    min-height: 100vh;
}

.app-skip-link {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 80;
    padding: 10px 14px;
    border-radius: 14px;
    background: #0f172a;
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-140%);
    transition: transform 0.16s ease;
}

.app-skip-link:focus {
    transform: translateY(0);
}

.app-layout-solo {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-theme-toggle-wrap {
    width: calc(100% - 32px);
    max-width: 1120px;
    margin: 24px auto 0;
    display: flex;
    justify-content: flex-end;
}

.theme-toggle {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 14px;
    gap: 0;
}

.theme-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle .ui-icon-sm {
    width: 1.05rem;
    height: 1.05rem;
}

.app-layout-content {
    flex: 1;
    width: calc(100% - 32px);
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 0 24px;
}

.app-footer {
    width: calc(100% - 32px);
    max-width: 1120px;
    margin: 0 auto 24px;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.76);
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .app-footer {
        background: rgba(255, 255, 255, 0.96);
    }
}

.app-footer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-footer-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(180deg, #eef5fb 0%, #dfeaf4 100%);
    color: #17384d;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.app-footer-kicker,
.app-footer-copy {
    margin: 0;
}

.app-footer-kicker {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.app-footer-copy {
    color: var(--muted);
    line-height: 1.5;
}

html.dark .button-light {
    background: linear-gradient(180deg, #213139 0%, #18252b 100%);
    color: var(--text);
    border-color: rgba(158, 198, 214, 0.22);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html.dark .button-secondary {
    background: linear-gradient(180deg, rgba(158, 198, 214, 0.18) 0%, rgba(158, 198, 214, 0.1) 100%);
    color: #c6e1e8;
    border-color: rgba(158, 198, 214, 0.28);
}

html.dark .button-primary {
    background: linear-gradient(180deg, #72b2a8 0%, #4f8b83 100%);
    color: #081113;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.34);
}

html.dark .button-save {
    border-color: rgba(120, 185, 173, 0.46);
    background: linear-gradient(180deg, #72b2a8 0%, #4f8b83 100%);
    color: #081113;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.34);
}

html.dark .form-control,
html.dark .form-select {
    background: linear-gradient(180deg, #111b20 0%, #17252b 100%);
    border-color: rgba(158, 198, 214, 0.22);
    color: var(--text);
}

html.dark .form-control::placeholder,
html.dark textarea.form-control::placeholder,
html.dark input.form-control::placeholder {
    color: rgba(154, 176, 172, 0.82);
}

html.dark .form-control:focus,
html.dark .form-select:focus {
    background: #17252b;
    box-shadow: 0 0 0 4px rgba(120, 185, 173, 0.18);
    border-color: rgba(120, 185, 173, 0.52);
}

html.dark .message-item {
    border-color: rgba(158, 198, 214, 0.2);
    background: linear-gradient(180deg, rgba(27, 41, 48, 0.98), rgba(18, 29, 34, 0.96));
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
}

html.dark .sige-toast {
    border-color: rgba(158, 198, 214, 0.22);
    background: rgba(18, 29, 34, 0.96);
    color: var(--text);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
}

html.dark .sige-toast-close {
    background: rgba(220, 236, 238, 0.1);
}

html.dark .sige-toast-close:hover {
    background: rgba(220, 236, 238, 0.18);
}

html.dark .sige-toast-success {
    background: rgba(15, 42, 36, 0.96);
}

html.dark .sige-toast-warning {
    background: rgba(48, 39, 22, 0.96);
}

html.dark .sige-toast-error {
    background: rgba(48, 25, 28, 0.96);
}

html.dark .card,
html.dark .modal-content,
html.dark .dropdown-menu,
html.dark .list-group-item {
    background-color: var(--surface);
    border-color: rgba(158, 198, 214, 0.2);
    color: var(--text);
}

html.dark .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: rgba(158, 198, 214, 0.18);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.025);
    --bs-table-hover-bg: rgba(120, 185, 173, 0.08);
}

html.dark ::selection {
    background: rgba(120, 185, 173, 0.34);
    color: var(--text);
}

html.dark .app-footer {
    border-color: rgba(41, 66, 68, 0.92);
    background: rgba(20, 32, 34, 0.84);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

html.dark .app-footer-mark {
    background: linear-gradient(180deg, #223637 0%, #1a2b2d 100%);
    color: #eef4f8;
}

html.dark :where(
    body,
    main,
    section,
    article,
    aside,
    header,
    footer,
    .card,
    .modal-content,
    .dropdown-menu,
    .list-group-item,
    .tab-content,
    .accordion-item,
    .offcanvas,
    .popover,
    .toast,
    .table,
    .form-control,
    .form-select,
    .input-group-text
) {
    color: var(--text);
}

html.dark :where(h1, h2, h3, h4, h5, h6, strong, b, th, legend) {
    color: #f2f7f5;
}

html.dark :where(
    p,
    span,
    small,
    td,
    li,
    label,
    .text-muted,
    .form-text,
    .helptext,
    .breadcrumb-item,
    .dropdown-item,
    .nav-link,
    .page-link
) {
    color: #b8c8c7;
}

html.dark :where(
    .card,
    .modal-content,
    .dropdown-menu,
    .list-group-item,
    .accordion-item,
    .offcanvas,
    .popover,
    .toast
) {
    background-color: var(--surface) !important;
    border-color: var(--border) !important;
}

html.dark :where(.nav-tabs, .nav-pills, .tab-content, .accordion-button, .page-link) {
    background-color: var(--surface-soft) !important;
    border-color: var(--border) !important;
    color: #f2f7f5 !important;
}

html.dark :where(
    .nav-link.active,
    .nav-pills .nav-link.active,
    .nav-tabs .nav-link.active,
    .accordion-button:not(.collapsed),
    .page-item.active .page-link
) {
    background-color: var(--surface-muted) !important;
    border-color: var(--border-strong) !important;
    color: #ffffff !important;
}

html.dark :where(.dropdown-item:hover, .dropdown-item:focus, .nav-link:hover, .page-link:hover) {
    background-color: var(--surface-muted) !important;
    color: #ffffff !important;
}

html.dark :where(input, select, textarea, .form-control, .form-select, .input-group-text) {
    background-color: #111d23 !important;
    border-color: var(--border-strong) !important;
    color: #f2f7f5 !important;
}

html.dark :where(input, textarea, .form-control)::placeholder {
    color: #9fb2b1 !important;
    opacity: 1;
}

html.dark :where(
    input:disabled,
    select:disabled,
    textarea:disabled,
    .form-control:disabled,
    .form-select:disabled,
    input[readonly],
    textarea[readonly]
) {
    background-color: #1c2a31 !important;
    color: #c9d8d6 !important;
}

html.dark :where(.table) {
    --bs-table-bg: #17252b;
    --bs-table-color: #f2f7f5;
    --bs-table-border-color: #39525a;
    --bs-table-striped-bg: #1b2a31;
    --bs-table-striped-color: #f2f7f5;
    --bs-table-hover-bg: #22333a;
    --bs-table-hover-color: #ffffff;
}

html.dark :where(.table th, .table thead th) {
    background-color: #1f3038 !important;
    color: #d8e5e3 !important;
}

html.dark :where(.table td) {
    color: #f2f7f5 !important;
}

html.dark :where(.btn-light, .btn-outline-secondary, .button-light) {
    background-color: #1b2930 !important;
    border-color: var(--border) !important;
    color: #f2f7f5 !important;
}

html.dark :where(.btn-light:hover, .btn-outline-secondary:hover, .button-light:hover) {
    background-color: #22333a !important;
    color: #ffffff !important;
}

@media (max-width: 720px) {
    .app-theme-toggle-wrap {
        width: calc(100% - 24px);
        max-width: 100%;
        margin-top: 16px;
    }

    .app-layout-content {
        width: calc(100% - 24px);
        max-width: 100%;
        padding-top: 18px;
    }

    .app-footer {
        width: calc(100% - 24px);
        max-width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }

    .message-item {
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
