:root {
    color-scheme: light;
    --bg: #edf2f7;
    --surface: #ffffff;
    --surface-soft: #f4f7fb;
    --border: #cfd8e6;
    --text: #111827;
    --text-soft: #5f6b7c;
    --primary: #1d4ed8;
    --primary-dark: #163ea9;
    --danger: #c0392b;
    --danger-dark: #962d21;
    --success: #1f8f5f;
    --success-dark: #176847;
    --success-soft: #eefaf2;
    --success-soft-strong: #dcefe4;
    --danger-soft: #e11d48;
    --surface-hover: #eef3f8;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.05);
    --radius: 3px;
    --topbar-height: 74px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    background:
        radial-gradient(circle at top, rgba(29, 78, 216, 0.08) 0%, rgba(29, 78, 216, 0) 32%),
        linear-gradient(180deg, #f8fafc 0%, #edf2f7 55%, #e7edf5 100%);
    color: var(--text);
}

body[data-authenticated='true'] {
    padding-top: var(--topbar-height);
}

button,
input {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.app-shell {
    width: min(95vw, 1680px);
    margin: 0 auto;
    padding: 36px 0 64px;
}

body[data-authenticated='true'] .app-shell {
    padding-top: 0;
}

.app-topbar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.96);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(14px);
}

.app-topbar__inner {
    width: min(95vw, 1680px);
    min-height: var(--topbar-height);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.app-topbar__session {
    flex: 1 1 auto;
    min-width: 0;
}

.app-topbar__label {
    display: block;
    margin-bottom: 4px;
    color: rgba(226, 232, 240, 0.68);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.app-topbar__identity {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    min-width: 0;
}

.app-topbar__menu-toggle.button--secondary,
.app-topbar__logout.button--secondary {
    width: 46px;
    min-width: 46px;
    padding: 0;
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    box-shadow: none;
    flex: 0 0 46px;
}

.app-topbar__menu-toggle.button--secondary:hover,
.app-topbar__logout.button--secondary:hover {
    background: rgba(255, 255, 255, 0.14);
}

body[data-sidebar-open='true'] .app-topbar__menu-toggle.button--secondary {
    border-color: rgba(96, 165, 250, 0.4);
    background: rgba(37, 99, 235, 0.24);
}

.app-topbar__menu-icon,
.app-topbar__logout-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.app-topbar__menu-icon svg,
.app-topbar__logout-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.app-topbar__profile {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
    min-width: 0;
    max-width: 100%;
}

.app-topbar__profile:focus-visible {
    outline: 2px solid rgba(191, 219, 254, 0.88);
    outline-offset: 3px;
    border-radius: 3px;
}

.app-topbar__avatar {
    width: 50px;
    height: 50px;
    flex: 0 0 50px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
}

.app-topbar__avatar-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.app-topbar__avatar-fallback {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
}

.app-topbar__profile-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    overflow: hidden;
}

.app-topbar__profile:hover .app-topbar__name,
.app-topbar__profile:focus-visible .app-topbar__name {
    text-decoration: underline;
}

.app-topbar__name {
    color: #fff;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-topbar__role {
    color: rgba(226, 232, 240, 0.82);
    font-size: 0.9rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-shell__layout {
    position: relative;
    display: grid;
    grid-template-columns: 0 minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    transition: grid-template-columns 0.22s ease;
}

body[data-authenticated='true'][data-sidebar-open='true'] .app-shell__layout {
    grid-template-columns: 248px minmax(0, 1fr);
}

.app-sidebar {
    grid-column: 1;
    position: sticky;
    top: calc(var(--topbar-height) + 24px);
    align-self: start;
    max-height: calc(100vh - var(--topbar-height) - 48px);
    min-width: 0;
    overflow: visible;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-18px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

body[data-authenticated='true'][data-sidebar-open='true'] .app-sidebar {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.app-sidebar__panel {
    position: relative;
    top: 0;
    max-height: 100%;
    width: 248px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
    overflow-y: auto;
}

.app-sidebar__eyebrow {
    margin: 0 0 14px;
    color: var(--text-soft);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.app-sidebar__nav {
    display: grid;
    gap: 8px;
}

.app-sidebar__link {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    font-weight: 700;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.app-sidebar__link:hover {
    background: #f3f7fc;
    border-color: #d5dfec;
}

.app-sidebar__link:focus-visible {
    outline: 2px solid rgba(29, 78, 216, 0.18);
    outline-offset: 2px;
}

.app-sidebar__link.is-active {
    border-color: rgba(29, 78, 216, 0.24);
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-dark);
    box-shadow: var(--shadow-soft);
}

.app-sidebar__link-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 18px;
}

.app-sidebar__link-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.app-sidebar__link-label {
    min-width: 0;
}

.app-shell__overlay {
    display: none;
}

.app-eyebrow {
    margin: 0 0 6px;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--primary);
    font-weight: 700;
}

.app-title {
    margin: 0;
    font-size: clamp(1.9rem, 3vw, 2.9rem);
    letter-spacing: -0.03em;
}

.app-subtitle {
    max-width: 520px;
    margin: 0;
    color: var(--text-soft);
    line-height: 1.5;
}

.app-view {
    grid-column: 2;
    min-height: calc(100vh - 120px);
    min-width: 0;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel--compact {
    padding: 24px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: var(--shadow-soft);
    transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.button:hover {
    background: var(--surface-hover);
    border-color: #b7c5d9;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.08);
}

.button:disabled {
    opacity: 0.7;
    cursor: wait;
    box-shadow: none;
}

.button:focus-visible {
    outline: 2px solid rgba(29, 78, 216, 0.18);
    outline-offset: 2px;
}

.button--secondary {
    border-color: var(--border);
    background: #f7f9fc;
    color: var(--text);
    box-shadow: var(--shadow-soft);
}

.button--secondary:hover {
    background: #edf2f7;
    border-color: #bcc9db;
}

.button--success {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
    box-shadow: 0 10px 20px rgba(31, 143, 95, 0.18);
}

.button--success:hover {
    background: var(--success-dark);
    border-color: var(--success-dark);
    color: #fff;
    box-shadow: 0 14px 26px rgba(31, 143, 95, 0.22);
}

.button--danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
    box-shadow: 0 10px 20px rgba(192, 57, 43, 0.18);
}

.button--danger:hover {
    background: var(--danger-dark);
    border-color: var(--danger-dark);
    color: #fff;
    box-shadow: 0 14px 26px rgba(192, 57, 43, 0.22);
}

.input {
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: #fbfcfe;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input:not(:disabled):not([readonly]) {
    border-color: var(--success-soft-strong);
    background-color: var(--success-soft);
}

.input:disabled,
.input[readonly] {
    background-color: #f7f9fc;
    color: var(--text-soft);
}

.input:focus {
    outline: 2px solid rgba(29, 78, 216, 0.14);
    border-color: var(--primary);
    background-color: #fff;
}

.input:not(:disabled):not([readonly]):focus {
    outline: 2px solid rgba(31, 143, 95, 0.16);
    border-color: var(--success);
}

select.input {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text-soft) 50%),
        linear-gradient(135deg, var(--text-soft) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 2px),
        calc(100% - 12px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 36px;
}

label:has(> .input[required]) > span::after,
label:has(> input[required]) > span::after,
label:has(> select[required]) > span::after,
label:has(> textarea[required]) > span::after {
    content: '*';
    display: inline-block;
    margin-left: 4px;
    color: var(--danger-soft);
    font-weight: 700;
    line-height: 1;
    vertical-align: top;
}

.status {
    margin: 12px 0 0;
    font-size: 0.95rem;
}

.status--error {
    color: var(--danger);
}

.status--success {
    color: var(--success);
}

body[data-modal-open='true'] {
    overflow: hidden;
}

.app-modal-host {
    position: fixed;
    inset: 0;
    z-index: 2200;
    pointer-events: none;
}

.app-modal-layer {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    pointer-events: auto;
}

.app-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(6px);
}

.app-modal {
    position: relative;
    width: min(var(--app-modal-width, 680px), calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: #fff;
    border: 1px solid rgba(207, 216, 230, 0.95);
    box-shadow: 0 28px 64px rgba(15, 23, 42, 0.22);
}

.app-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 22px 24px 18px;
    border-bottom: 1px solid rgba(207, 216, 230, 0.9);
    background: linear-gradient(180deg, #fbfcfe 0%, #f7f9fc 100%);
}

.app-modal__copy {
    display: grid;
    gap: 6px;
}

.app-modal__title,
.app-modal__description,
.app-modal__message {
    margin: 0;
}

.app-modal__title {
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}

.app-modal__description {
    color: var(--text-soft);
    line-height: 1.6;
}

.app-modal__close {
    min-width: 92px;
}

.app-modal__body {
    padding: 24px;
    overflow: auto;
}

.app-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    padding: 18px 24px 24px;
    border-top: 1px solid rgba(207, 216, 230, 0.9);
    background: #f8fafc;
}

.app-modal__message {
    line-height: 1.7;
}
