:root {
    --t-primary:       #233876;
    --t-primary-ch:    35 56 118;
    --t-secondary:     #5b6a9c;
    --t-surface:       #ffffff;
    --t-surface-alt:   #f5f7fc;
    --t-border-light:  #eef1fa;
    --t-border:        #e8ecf7;
    --t-border-strong: #d6ddf0;
    --t-error:         #d1242f;
    --t-success:       #1a7f37;
    --t-warning:       #a86500;
}
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    background: var(--t-surface);
    color: var(--t-primary);
}
.topbar {
    background: var(--t-primary);
    color: var(--t-surface);
    padding: 4px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    min-height: 32px;
}
.topbar-left { display: flex; align-items: center; flex-wrap: wrap; gap: 24px; }
.topbar-brand { font-weight: 700; font-size: 15px; }
.topbar-nav { display: flex; gap: 16px; flex-wrap: wrap; }
.topbar-nav a, .topbar-account a {
    color: var(--t-surface);
    font-size: 13px;
    text-decoration: none;
    opacity: .9;
}
.topbar-nav a:hover, .topbar-account a:hover { opacity: 1; text-decoration: underline; }
.topbar-account { display: flex; gap: 16px; align-items: center; }
.topbar-account button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    color: var(--t-surface);
    font-size: 13px;
    opacity: .9;
}
.topbar-account button:hover { opacity: 1; }
.topbar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: var(--t-surface);
    text-decoration: none;
    opacity: .85;
    transition: opacity .15s, background .15s;
}
.topbar-icon-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, .15);
    text-decoration: none;
}
.account-menu { position: relative; }
.account-menu > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--t-surface);
    font-size: 13px;
    font-weight: 600;
    opacity: .9;
    padding: 4px 8px;
    border-radius: 6px;
    user-select: none;
    transition: opacity .15s, background .15s;
}
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary::marker { display: none; content: ''; }
.account-menu > summary:hover { opacity: 1; background: rgba(255, 255, 255, .15); }
.account-chevron { font-size: 10px; transition: transform .2s; }
.account-menu[open] .account-chevron { transform: rotate(180deg); }
.account-menu-card {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgb(var(--t-primary-ch) / .18);
    min-width: 200px;
    z-index: 500;
    overflow: hidden;
}
.account-menu-card a,
.account-menu-card button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    font: inherit;
    font-size: 13px;
    color: var(--t-primary);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background .12s;
}
.account-menu-card a:hover,
.account-menu-card button:hover {
    background: var(--t-surface-alt);
    text-decoration: none;
}
.account-menu-card i { width: 14px; text-align: center; opacity: .7; }
.menu-divider { height: 1px; background: var(--t-border-light); margin: 4px 0; }
.logout-item { color: var(--t-error) !important; }
.logout-item:hover { background: #fff5f5 !important; }
.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.user-badge-name { font-weight: 600; }
.user-badge-email { opacity: .75; }
.user-badge-role {
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.banner { background: var(--t-primary); color: var(--t-surface); padding: 24px 32px; }
.banner h1 { color: var(--t-surface); margin: 0; }
.content { padding: 24px 32px; }
p.subtitle { color: var(--t-primary); margin-top: 0; font-size: 14px; }

/* Copied from traki/traki/static/css/traki.css — see that file. */
.t-section + .t-section { margin-top: 32px; }
.t-section-heading {
    color: var(--t-primary);
    font-size: 18px;
    margin: 0 0 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--t-primary);
}
.t-wide-details-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px 32px;
    margin: 16px 0 0;
}
.t-wide-details-item dt {
    margin: 0;
    color: var(--t-secondary);
    font-size: 12px;
    font-weight: 400;
}
.t-wide-details-item dd {
    margin: 4px 0 0;
    margin-inline-start: 0;
    color: var(--t-primary);
    font-size: 14px;
    font-weight: 700;
}
.t-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 16px 0 0;
}

.n-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 6px;
    padding: 9px 16px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: opacity .15s ease;
}
.n-button:hover { opacity: .92; }
.n-button:disabled { opacity: .5; cursor: not-allowed; }
.n-button.full-width { width: 100%; }
.n-button.small { padding: 6px 12px; font-size: 12px; }
.n-button.tiny { padding: 3px 8px; font-size: 11px; gap: 4px; }
.n-button.icon-button { padding: 9px; }
.n-button.icon-button.small { padding: 6px; }
.n-button.icon-button.tiny { padding: 3px; }

.n-button.primary.filled { background: var(--t-primary); color: var(--t-surface); }
.n-button.primary.outlined {
    background: transparent;
    color: var(--t-primary);
    border-color: var(--t-primary);
}
.n-button.secondary.filled { background: var(--t-secondary); color: var(--t-surface); }
.n-button.secondary.outlined {
    background: transparent;
    color: var(--t-secondary);
    border-color: var(--t-secondary);
}
.n-button.success.filled { background: var(--t-success); color: var(--t-surface); }
.n-button.success.outlined {
    background: transparent;
    color: var(--t-success);
    border-color: var(--t-success);
}
.n-button.error.filled { background: var(--t-error); color: var(--t-surface); }
.n-button.error.outlined {
    background: transparent;
    color: var(--t-error);
    border-color: var(--t-error);
}
.n-button.warning.filled { background: var(--t-warning); color: var(--t-surface); }
.n-button.warning.outlined {
    background: transparent;
    color: var(--t-warning);
    border-color: var(--t-warning);
}
.n-button.info.filled { background: var(--t-primary); color: var(--t-surface); }
.n-button.info.outlined {
    background: transparent;
    color: var(--t-primary);
    border-color: var(--t-primary);
}

.n-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: var(--t-surface);
    border-radius: 50%;
    animation: n-spin .6s linear infinite;
}
.n-button.outlined .n-spinner {
    border-color: rgb(var(--t-primary-ch) / .3);
    border-top-color: currentColor;
}
@keyframes n-spin { to { transform: rotate(360deg); } }

dialog {
    border: none;
    border-radius: 10px;
    padding: 0;
    box-shadow: 0 12px 32px rgb(var(--t-primary-ch) / .25);
}
dialog::backdrop { background: rgb(var(--t-primary-ch) / .35); }
.dialog-content { padding: 20px; min-width: 280px; }
.dialog-actions { display: flex; gap: 8px; margin-top: 16px; }
.c-primary { color: var(--t-primary); }

.n-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgb(var(--t-primary-ch) / .35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.n-modal {
    background: var(--t-surface);
    border-radius: 10px;
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    box-shadow: 0 12px 32px rgb(var(--t-primary-ch) / .25);
}
.n-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--t-border-light);
}
.n-modal-title { margin: 0; font-size: 16px; color: var(--t-primary); }
.n-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.n-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--t-secondary);
    font-size: 15px;
    padding: 4px;
}
.n-modal-close:hover { color: var(--t-primary); }
.n-modal-body { padding: 20px; }
.n-modal-footer {
    padding: 12px 20px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
body.modal-open { overflow: hidden; }

.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--t-primary);
}
.modal-field input, .modal-field select {
    padding: 8px 10px;
    border: 1px solid var(--t-border-strong);
    border-radius: 6px;
    font: inherit;
    background: var(--t-surface-alt);
    color: var(--t-secondary);
}

/* ── n-flex / gap utilities ──────────────────────────────── */
.n-flex { display: flex; }
.n-col { flex-direction: column; }
.gap-s { gap: 6px; }
.gap-m { gap: 12px; }
.gap-l { gap: 20px; }
.gap-xl { gap: 32px; }
.align-center { align-items: center; }
.jus-center { justify-content: center; }
.h-100 { height: 100%; }

/* ── n-tooltip ───────────────────────────────────────────── */
.n-tooltip-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.n-tooltip-icon {
    color: var(--t-secondary);
    font-size: 13px;
    cursor: help;
}
.n-tooltip-box {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    min-width: 160px;
    max-width: 260px;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--t-primary);
    color: var(--t-surface);
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgb(0 0 0 / .18);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.n-tooltip-label { font-weight: 700; }

/* ── n-popper ────────────────────────────────────────────── */
.n-popper-wrapper { position: relative; display: inline-block; }
.n-popper-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 300;
    min-width: 160px;
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgb(var(--t-primary-ch) / .18);
}
.n-popper-panel--right { left: auto; right: 0; }

/* ── n-checkbox ──────────────────────────────────────────── */
.n-checkbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--t-border-strong);
    border-radius: 4px;
    cursor: pointer;
    color: var(--t-surface);
    font-size: 11px;
    transition: background .15s, border-color .15s;
}
.n-checkbox--checked {
    background: var(--t-primary);
    border-color: var(--t-primary);
}

/* ── t-input-history / t-save-loader ────────────────────── */
.t-input-history {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--t-secondary);
}
.t-input-history-restore {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--t-primary);
    cursor: pointer;
    padding: 2px;
}
.t-save-loader {
    display: inline-flex;
    align-items: center;
    color: var(--t-success);
    font-size: 13px;
}

/* ── t-select / t-text-input shared field chrome ────────── */
.input-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: max-content;
}
.input-container.full-width { width: 100%; }
.field-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--t-primary);
}
.n-optional-label {
    font-weight: 400;
    color: var(--t-secondary);
    font-style: normal;
}
.select, .textfield {
    padding: 8px 10px;
    border: 1px solid var(--t-border-strong);
    border-radius: 6px;
    font: inherit;
    background: var(--t-surface);
    color: var(--t-primary);
}
.select.full-width, .textfield.full-width { width: 100%; }
.select.disabled, .textfield.disabled {
    background: var(--t-surface-alt);
    color: var(--t-secondary);
    cursor: not-allowed;
}
.textfield.error { border-color: var(--t-error); }
.invalid-field-error {
    font-size: 12px;
    color: var(--t-error);
}
