/* App shell + page furniture on Slate tokens (см. css/design/). */

/* ---------- shell ---------- */

.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--surface-bar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.brand {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
}

.brand__logo {
    display: block;
    height: 22px;
    width: auto;
}

/* The wordmark is white — invert it to black in the light theme */
html[data-theme='light'] .brand__logo {
    filter: invert(1);
}

.brand__logo--login {
    height: 34px;
    margin: 0 auto;
}

.brand__sub {
    margin-top: 2px;
    font-family: var(--font-mono);
    font-size: var(--fs-caption);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.side-nav {
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    gap: 2px;
}

.side-nav__group {
    margin: 14px 0 2px;
    padding: 0 16px;
    font-family: var(--font-mono);
    font-size: var(--fs-caption);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.side-nav__group:first-child {
    margin-top: 0;
}

.side-nav .nav-link {
    display: block;
    padding: 9px 16px;
    font-size: var(--fs-body);
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
}

.side-nav .nav-link:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}

.side-nav .nav-link.active {
    background: var(--surface-2);
    color: var(--text-primary);
    box-shadow: var(--indicator);
}

main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 0 24px;
    background: var(--surface-bar);
    border-bottom: 1px solid var(--border);
}

.topbar__user {
    font-family: var(--font-mono);
    font-size: var(--fs-small);
    color: var(--text-muted);
}

/* Full-width content: tables get all the horizontal space the window offers,
   forms stay narrow through their own max-widths (.form-stack etc.).
   No explicit width: as a block it fills <main>, and without a global
   border-box reset "width: 100%" would overflow by the padding. */
.content {
    padding: 24px;
}

/* ---------- page furniture ---------- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

h2.section-title {
    margin: 0 0 12px;
    font-size: var(--fs-h2);
    font-weight: 600;
    color: var(--text-primary);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.muted {
    color: var(--text-muted);
}

.mono {
    font-family: var(--font-mono);
    font-size: var(--fs-small);
}

a {
    color: var(--accent-hover);
}

/* ---------- data table ---------- */

.table-wrap {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-3);
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-body);
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}

.data-table td {
    padding: 9px 14px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:nth-child(odd) td {
    background: var(--grid-row-odd, transparent);
}

.data-table tbody tr:hover td {
    background: var(--surface-2);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table td.actions {
    text-align: right;
    white-space: nowrap;
}

.data-table .cell-primary {
    color: var(--text-primary);
}

/* Long values (uids, titles, external file names) must not stretch the table and
   push the row actions out of the horizontal scroll — clip them with a tooltip. */
.data-table .cell-clip {
    display: inline-block;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Guid-like values (file names) carry no meaning — clip them harder so the
   actions column always fits without a horizontal scroll */
.data-table .cell-clip--narrow {
    max-width: 140px;
    vertical-align: bottom;
}

.pager {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.data-table td.num,
.data-table th.num {
    text-align: center;
    font-family: var(--font-mono);
}

/* ---------- forms ---------- */

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 480px;
}

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

.atas-input.invalid,
.atas-select.invalid {
    border-color: var(--risk-crit);
}

.validation-message {
    margin-top: 4px;
    font-size: var(--fs-small);
    color: var(--risk-crit);
}

input[type='date'].atas-input {
    color-scheme: dark;
}

html[data-theme='light'] input[type='date'].atas-input {
    color-scheme: light;
}

/* ---------- login ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--canvas);
}

.login-card {
    width: 380px;
    padding: 28px;
}

.login-card .brand__name {
    font-size: 17px;
}

/* ---------- blazor boot screen ---------- */

html, body {
    background: var(--canvas);
    color: var(--text-primary);
    font-family: var(--font-sans);
}

.loading-logo {
    display: block;
    width: 84px;
    margin: 18vh auto 2rem;
}

.loading-progress {
    position: relative;
    display: block;
    width: 6rem;
    height: 6rem;
    margin: 0 auto 1rem;
}

.loading-progress circle {
    fill: none;
    stroke: var(--surface-3);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    text-align: center;
    font-family: var(--font-mono);
    font-size: var(--fs-small);
    color: var(--text-muted);
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 10px 20px;
    background: var(--surface-2);
    border-top: 2px solid var(--risk-crit);
    color: var(--text-primary);
    font-size: var(--fs-body);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 12px;
    top: 8px;
    color: var(--text-muted);
}
