/* ==========================================================================
   Translation Portal - design system & application styles
   --------------------------------------------------------------------------
   1.  Fonts
   2.  Design tokens
   3.  Base & reset
   4.  Layout primitives
   5.  Top bar
   6.  Page header
   7.  Buttons
   8.  Badges & chips
   9.  Stat cards
   10. Panel, toolbar, search & filters
   11. Data table
   12. Responsive table (mobile cards)
   13. States (empty / no results / loading)
   14. Flash & toast
   15. Modal & forms
   16. Login
   17. Document viewer
   18. Footer
   19. Responsive
   ========================================================================== */

/* 1. Fonts ----------------------------------------------------------------- */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/inter-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/inter-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/inter-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/inter-700.woff2') format('woff2');
}

/* 2. Design tokens --------------------------------------------------------- */
:root {
    --font-sans: 'Inter', system-ui, 'Segoe UI', Roboto, -apple-system, sans-serif;

    /* Neutrals */
    --bg:          #f4f5f7;
    --surface:     #ffffff;
    --surface-2:   #f9fafb;
    --surface-3:   #f3f4f6;

    --text:        #15181d;
    --text-2:      #586273;
    --text-3:      #8a93a2;

    --border:      #e7e9ee;
    --border-2:    #dcdfe6;

    /* Brand (indigo) */
    --brand:        #4f46e5;
    --brand-hover:  #4338ca;
    --brand-text:   #4338ca;
    --brand-soft:   #eef0fe;
    --brand-soft-2: #e2e5fd;
    --ring:         rgba(79, 70, 229, .32);

    /* Semantic */
    --success:        #15a34a;
    --success-soft:   #e8f8ef;
    --success-text:   #137a3a;
    --success-border: #bfe9cd;

    --warning:        #d98309;
    --warning-soft:   #fdf3e1;
    --warning-text:   #b06908;
    --warning-border: #f2dcab;

    --danger:         #dc2626;
    --danger-soft:    #fdecec;
    --danger-text:    #bb2020;
    --danger-border:  #f3c9c9;

    --info-soft:      #eef3ff;
    --info-text:      #2451c7;
    --info-border:    #cfdcfb;

    /* Stat accents */
    --c-blue:   #2563eb;  --c-blue-soft:   #e9f0ff;
    --c-green:  #15a34a;  --c-green-soft:  #e6f7ed;
    --c-amber:  #e0890b;  --c-amber-soft:  #fcf2dd;
    --c-indigo: #4f46e5;  --c-indigo-soft: #eaecfe;

    /* Source identity */
    --src-backstage:      #7c3aed;  --src-backstage-soft: #f1ecfe;
    --src-vts:            #0e8fab;  --src-vts-soft:       #e2f5f9;

    /* File types */
    --ft-pdf:  #d6443a;  --ft-pdf-soft:  #fdebe9;
    --ft-doc:  #2563eb;  --ft-doc-soft:  #e9f0ff;

    /* Spacing */
    --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
    --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 56px;

    /* Radius */
    --r-xs: 5px; --r-sm: 7px; --r: 10px; --r-lg: 13px; --r-xl: 18px; --r-full: 999px;

    /* Shadows */
    --sh-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --sh-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --sh-md: 0 6px 16px -4px rgba(16, 24, 40, .1), 0 2px 6px -2px rgba(16, 24, 40, .05);
    --sh-lg: 0 16px 36px -8px rgba(16, 24, 40, .16), 0 4px 10px -4px rgba(16, 24, 40, .07);
    --sh-xl: 0 28px 56px -12px rgba(16, 24, 40, .26);

    /* Layout & motion */
    --container: 1320px;
    --topbar-h: 64px;
    --t-fast: 120ms ease;
    --t: 160ms ease;
}

/* 3. Base & reset --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
    margin: 0;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: none; }
img, svg { display: block; }
button { font-family: inherit; }

.icon { flex: 0 0 auto; }
.muted { color: var(--text-3); }
::selection { background: rgba(79, 70, 229, .16); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* 4. Layout primitives ---------------------------------------------------- */
.shell {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--s-8) var(--s-6) var(--s-12);
    flex: 1 0 auto;
}

/* 5. Top bar -------------------------------------------------------------- */
.appbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: var(--s-4);
    padding: 0 var(--s-6);
    background: rgba(255, 255, 255, .9);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.appbar-brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    color: var(--text);
}
.appbar-logo {
    width: 38px;
    height: 38px;
    border-radius: var(--r);
    box-shadow: var(--sh-xs);
}
.appbar-title {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}
.appbar-title strong {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
}
.appbar-title small {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-3);
}

.appbar-spacer { flex: 1; }

.appbar-user { display: flex; align-items: center; gap: var(--s-2); }

.user-chip {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 5px 12px 5px 6px;
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    background: var(--surface);
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--r-full);
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
}
.user-chip-meta { display: flex; flex-direction: column; line-height: 1.3; }
.user-chip-name { font-size: 12.5px; font-weight: 600; }
.user-chip-role { font-size: 10.5px; color: var(--text-3); }

/* 6. Page header ---------------------------------------------------------- */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--s-4);
    flex-wrap: wrap;
    margin-bottom: var(--s-6);
}
.page-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.022em;
}
.page-summary {
    margin-top: 5px;
    font-size: 13px;
    color: var(--text-2);
}
.page-summary b { font-weight: 600; color: var(--text); }
.page-summary .dot { margin: 0 7px; color: var(--border-2); }

.page-head-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* 7. Buttons -------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast),
                color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-soft:disabled:hover { background: var(--brand-soft); }

.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; gap: 5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--sh-xs); }
.btn-primary:hover { background: var(--brand-hover); }

.btn-secondary {
    background: var(--surface);
    border-color: var(--border-2);
    color: var(--text-2);
    box-shadow: var(--sh-xs);
}
.btn-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-soft { background: var(--brand-soft); color: var(--brand-text); }
.btn-soft:hover { background: var(--brand-soft-2); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c01f1f; }

/* Compact icon action (table downloads) */
.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 0 9px;
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .03em;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--brand-soft); border-color: var(--brand-soft-2); color: var(--brand-text); }

/* 8. Badges & chips ------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 9px;
    border-radius: var(--r-full);
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
}
.badge .dot {
    width: 6px;
    height: 6px;
    border-radius: var(--r-full);
    background: currentColor;
    flex: 0 0 auto;
}
.badge-success { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.badge-pending { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning-border); }

.src-backstage { background: var(--src-backstage-soft); color: var(--src-backstage); }
.src-vts       { background: var(--src-vts-soft);       color: var(--src-vts); }

.ver-chip {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--r-xs);
    background: var(--brand-soft);
    color: var(--brand-text);
    font-size: 11.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.badge-xs { height: 18px; font-size: 9.5px; padding: 0 6px; }

/* File-type thumbnail */
.file-thumb {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r-sm);
    flex: 0 0 auto;
}
.file-thumb-pdf  { background: var(--ft-pdf-soft); color: var(--ft-pdf); }
.file-thumb-docx,
.file-thumb-doc  { background: var(--ft-doc-soft); color: var(--ft-doc); }

/* 9. Stat cards ----------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--s-4);
    margin-bottom: var(--s-6);
}
.stat-card {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-xs);
    transition: box-shadow var(--t), transform var(--t);
}
.stat-card:hover { box-shadow: var(--sh-sm); transform: translateY(-1px); }

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
}
.stat-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
}
.stat-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    flex: 0 0 auto;
}
.stat-icon-blue   { background: var(--c-blue-soft);   color: var(--c-blue); }
.stat-icon-green  { background: var(--c-green-soft);  color: var(--c-green); }
.stat-icon-amber  { background: var(--c-amber-soft);  color: var(--c-amber); }
.stat-icon-indigo { background: var(--c-indigo-soft); color: var(--c-indigo); }

.stat-value {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stat-hint {
    font-size: 11.5px;
    color: var(--text-3);
    font-weight: 500;
}

.progress {
    height: 8px;
    background: var(--surface-3);
    border-radius: var(--r-full);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--brand);
    border-radius: var(--r-full);
    transition: width .5s cubic-bezier(.4, 0, .2, 1);
}

/* 10. Panel, toolbar, search & filters ------------------------------------ */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-xs);
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    padding: var(--s-4) var(--s-5);
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex: 1 1 260px;
    max-width: 380px;
    height: 40px;
    padding: 0 var(--s-3);
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    color: var(--text-3);
    transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.search-box:focus-within {
    background: var(--surface);
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--ring);
}
.search-box input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 13.5px;
    outline: none;
}
.search-box input::placeholder { color: var(--text-3); }

.filters { display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: var(--s-2); }
.filter-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
}

.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--surface-3);
    border-radius: var(--r-sm);
}
.seg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 11px;
    border: 0;
    background: transparent;
    border-radius: var(--r-xs);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.seg:hover { color: var(--text); }
.seg.is-active {
    background: var(--surface);
    color: var(--brand-text);
    box-shadow: var(--sh-xs);
}
.seg-count {
    display: inline-flex;
    align-items: center;
    height: 16px;
    padding: 0 6px;
    border-radius: var(--r-full);
    background: rgba(20, 24, 31, .07);
    color: var(--text-2);
    font-size: 10px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.seg.is-active .seg-count { background: var(--brand-soft); color: var(--brand-text); }

.results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: 10px var(--s-5);
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-3);
}
.link-btn {
    border: 0;
    background: transparent;
    color: var(--brand-text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}
.link-btn:hover { text-decoration: underline; }
.link-btn[hidden] { display: none; }

/* 11. Data table ---------------------------------------------------------- */
.table-wrap { width: 100%; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13.5px;
}
.col-w-source      { width: 104px; }
.col-w-translation { width: 122px; }
.col-w-version     { width: 76px; }
.col-w-updated     { width: 128px; }
.col-w-actions     { width: 270px; }

.data-table thead th {
    position: sticky;
    top: var(--topbar-h);
    z-index: 5;
    text-align: left;
    padding: 11px 16px;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-3);
    white-space: nowrap;
}
.data-table thead th:first-child { padding-left: 20px; }
.data-table thead th:last-child  { padding-right: 20px; }

.data-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody td:first-child { padding-left: 20px; }
.data-table tbody td:last-child  { padding-right: 20px; }
.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table tbody tr { transition: background-color var(--t-fast); }
.data-table tbody tr:hover { background: #f7f8ff; }

.col-version { text-align: center; }
.col-actions { text-align: right; }

/* Document cell */
.doc-cell { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.doc-cell-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.doc-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.doc-name:hover { color: var(--brand-text); }
.doc-meta {
    font-size: 11.5px;
    color: var(--text-3);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.cell-date { display: flex; flex-direction: column; gap: 1px; }
.date-main { font-size: 13px; font-weight: 600; color: var(--text-2); }
.date-sub  { font-size: 11px; color: var(--text-3); }
.cell-empty { color: var(--text-3); }

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

/* 12. Responsive table (mobile cards) ------------------------------------- */
@media (max-width: 920px) {
    .data-table thead { display: none; }
    .data-table,
    .data-table tbody,
    .data-table tbody tr,
    .data-table tbody td { display: block; width: auto; }

    .data-table tbody tr {
        border: 1px solid var(--border);
        border-radius: var(--r);
        margin-bottom: var(--s-3);
        padding: 6px var(--s-4) var(--s-2);
        background: var(--surface);
        box-shadow: var(--sh-xs);
    }
    .data-table tbody tr:last-child { margin-bottom: 0; }
    .data-table tbody tr:hover { background: var(--surface); }

    .data-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--s-4);
        padding: 9px 0 !important;
        border-bottom: 1px solid var(--border);
    }
    .data-table tbody td::before {
        content: attr(data-label);
        font-size: 10.5px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: var(--text-3);
    }
    .data-table tbody td.col-doc,
    .data-table tbody td.col-actions {
        display: block;
    }
    .data-table tbody td.col-doc::before,
    .data-table tbody td.col-actions::before { content: none; }
    .data-table tbody td.col-doc {
        padding: 10px 0 12px !important;
    }
    .data-table tbody td.col-actions {
        border-bottom: 0;
        padding-bottom: 6px !important;
    }
    .col-version, .col-actions { text-align: left; }
    .row-actions { justify-content: flex-start; flex-wrap: wrap; }
    .row-actions .btn-soft { flex: 1; min-width: 88px; }
}

/* 13. States -------------------------------------------------------------- */
.state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--s-3);
    padding: var(--s-12) var(--s-6);
}
.state-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: var(--r-lg);
    background: var(--surface-3);
    color: var(--text-3);
}
.state-title { font-size: 15px; font-weight: 700; }
.state-text { font-size: 13px; color: var(--text-2); max-width: 360px; }
.state[hidden] { display: none; }

/* Loading skeleton & spinner */
.skeleton {
    background: linear-gradient(90deg, #edeef1 25%, #f6f7f8 37%, #edeef1 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: var(--r-xs);
}
@keyframes shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
.spinner {
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: var(--r-full);
    animation: spin .6s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 14. Flash & toast ------------------------------------------------------- */
.flash {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 12px 14px;
    margin-bottom: var(--s-5);
    border: 1px solid transparent;
    border-radius: var(--r);
    font-size: 13.5px;
    font-weight: 500;
}
.flash-icon { display: flex; flex: 0 0 auto; }
.flash-msg { flex: 1; }
.flash-close {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: var(--r-xs);
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: .7;
}
.flash-close:hover { opacity: 1; background: rgba(0, 0, 0, .06); }
.flash-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.flash-error   { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger-text); }
.flash-info    { background: var(--info-soft);    border-color: var(--info-border);    color: var(--info-text); }

.flash-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    min-width: 320px;
    max-width: 92vw;
    margin: 0;
    box-shadow: var(--sh-lg);
    animation: toast-in .2s ease-out;
}
@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, -10px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* 15. Modal & forms ------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--s-5);
    background: rgba(16, 22, 34, .5);
    backdrop-filter: blur(3px);
}
.modal-overlay[hidden] { display: none; }

.modal {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-xl);
    overflow: hidden;
    animation: modal-in .16s ease-out;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 15.5px; font-weight: 700; }
.modal-close {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }

.modal-body { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); }
.modal-doc {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 11px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
}
.modal-doc-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
}
.modal-doc-name { font-size: 13px; font-weight: 600; word-break: break-word; }

.upload-version-hint {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: var(--warning-soft);
    border: 1px solid var(--warning-border);
    border-radius: var(--r-sm);
    font-size: 12.5px;
    color: var(--warning-text);
    font-weight: 500;
}
.upload-version-hint.is-error {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger-text);
}
.upload-version-hint[hidden] { display: none; }

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-2);
    padding: var(--s-4) var(--s-5);
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; }
.field-help { font-size: 11.5px; color: var(--text-3); }
.req { color: var(--danger); }
.opt { color: var(--text-3); font-weight: 400; }

input[type="text"],
input[type="password"],
input[type="search"],
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--ring);
}
textarea { resize: vertical; min-height: 58px; }

.file-drop {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 22px 16px;
    border: 1.5px dashed var(--border-2);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    text-align: center;
    transition: border-color var(--t-fast), background var(--t-fast);
}
.file-drop:hover, .file-drop.is-drag { border-color: var(--brand); background: var(--brand-soft); }
.file-drop.has-file { border-style: solid; border-color: var(--success-border); background: var(--success-soft); }
.file-drop input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.file-drop-icon { color: var(--brand); }
.file-drop.has-file .file-drop-icon { color: var(--success); }
.file-drop-text { font-size: 13px; font-weight: 600; color: var(--text-2); }
.file-drop.has-file .file-drop-text { color: var(--success-text); }

/* 16. Login --------------------------------------------------------------- */
body.auth-body {
    background:
        radial-gradient(900px 480px at 50% -8%, #e7e9fb 0%, rgba(231, 233, 251, 0) 70%),
        var(--bg);
}
.auth-wrap {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--s-8) var(--s-5);
}
.auth-card {
    width: 100%;
    max-width: 392px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-lg);
    padding: var(--s-8) var(--s-8) var(--s-6);
}
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 3px;
    margin-bottom: var(--s-6);
}
.auth-logo { width: 56px; height: 56px; border-radius: var(--r-lg); margin-bottom: 10px; }
.auth-brand h1 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.auth-brand p { font-size: 12.5px; color: var(--text-3); }

.auth-form { display: flex; flex-direction: column; gap: var(--s-4); }
.auth-form .btn { margin-top: 4px; }
.auth-note {
    margin-top: var(--s-5);
    padding-top: var(--s-4);
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 11.5px;
    color: var(--text-3);
}

/* 17. Document viewer ----------------------------------------------------- */
body.viewer-body { height: 100%; overflow: hidden; }

.viewer-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 10px var(--s-5);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 20;
}
.viewer-doc { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.viewer-doc-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.viewer-doc-name {
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 38vw;
}
.viewer-doc-meta { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.viewer-ver { font-size: 11.5px; color: var(--text-2); }
.viewer-ver strong { color: var(--brand-text); }
.viewer-toolbar-spacer { flex: 1; }
.viewer-actions { display: flex; align-items: center; gap: 6px; }

.viewer-split {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
    background: var(--bg);
}
.viewer-split.is-resizing { cursor: col-resize; user-select: none; }
.viewer-split.is-resizing .vpane-frame { pointer-events: none; }

.vpane {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface);
}
.vpane-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: 9px var(--s-4);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.vpane-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-2);
    white-space: nowrap;
}
.lang-dot { width: 8px; height: 8px; border-radius: var(--r-full); flex: 0 0 auto; }
.lang-en { background: var(--c-blue); }
.lang-ro { background: var(--c-green); }
.vpane-file {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 11.5px;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.vpane-body {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    background: #51545a;
}
.vpane-frame { width: 100%; height: 100%; border: 0; }

.vsplitter {
    flex: 0 0 8px;
    background: var(--border-2);
    cursor: col-resize;
    position: relative;
    transition: background var(--t-fast);
}
.vsplitter::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 36px;
    border-radius: var(--r-full);
    background: var(--text-3);
    opacity: .6;
}
.vsplitter:hover, .viewer-split.is-resizing .vsplitter { background: var(--brand); }
.vsplitter:hover::before { background: #fff; opacity: .9; }

.vpane-empty, .doc-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 9px;
    padding: var(--s-8);
    background: var(--surface);
}
.vpane-empty-icon {
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    border-radius: var(--r-lg);
    background: var(--surface-3);
    color: var(--text-3);
    margin-bottom: 4px;
}
.vpane-empty-title { font-size: 15px; font-weight: 700; }
.vpane-empty-text { font-size: 13px; color: var(--text-2); max-width: 320px; }
.vpane-empty .btn, .doc-card .btn { margin-top: 8px; }

.doc-card-icon { width: 64px; height: 64px; border-radius: var(--r); margin-bottom: 4px; }
.doc-card-name { font-size: 14px; font-weight: 700; max-width: 340px; word-break: break-word; }
.doc-card-meta { font-size: 12px; color: var(--text-2); }
.doc-card-hint { font-size: 12px; color: var(--text-3); max-width: 320px; }

/* History dropdown */
.dropdown { position: relative; }
.dropdown-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 320px;
    max-height: 72vh;
    overflow-y: auto;
    padding: var(--s-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--sh-lg);
    z-index: 60;
}
.dropdown-panel[hidden] { display: none; }
.dropdown-title {
    padding: 6px 8px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
}
.history-row {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    margin-bottom: 6px;
}
.history-row:last-child { margin-bottom: 0; }
.history-row.is-current { border-color: var(--success-border); background: var(--success-soft); }
.history-main { display: flex; align-items: center; gap: 8px; }
.history-date { font-size: 12px; font-weight: 600; }
.history-note { margin-top: 6px; font-size: 12px; color: var(--text-2); line-height: 1.45; }
.history-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}
.history-by { font-size: 11px; color: var(--text-3); }
.history-dl {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
}

/* 18. Footer -------------------------------------------------------------- */
.app-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-4) var(--s-6);
    background: var(--surface);
    border-top: 1px solid var(--border);
    color: var(--text-3);
    font-size: 12px;
}
.footer-left { font-weight: 500; }
.footer-dot { margin: 0 5px; opacity: .55; }
.footer-right { display: flex; align-items: center; gap: 5px; }
.footer-brand { display: inline-flex; align-items: center; gap: 6px; }
.footer-brand strong { color: var(--text-2); font-weight: 700; }
.footer-brand:hover strong { color: var(--brand-text); }
.footer-logo { width: 17px; height: 17px; border-radius: 5px; }

.app-footer-minimal {
    background: transparent;
    border-top: 0;
    justify-content: center;
    gap: 5px;
}
.app-footer-slim { padding: 7px var(--s-5); font-size: 11px; }
.app-footer-slim .footer-logo { width: 15px; height: 15px; }

/* 19. Responsive ---------------------------------------------------------- */
@media (max-width: 1080px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
    .appbar { padding: 0 var(--s-4); }
    .appbar-title small { display: none; }
    .user-chip-meta { display: none; }
    .user-chip { padding: 5px; border: 0; background: transparent; }
    .shell { padding: var(--s-5) var(--s-4) var(--s-10); }
    .stat-grid { grid-template-columns: 1fr; }
    .page-head { gap: var(--s-3); }
    .page-head-actions { width: 100%; }
    .page-head-actions .btn { flex: 1; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-box { max-width: none; flex: 0 0 auto; }
    .filters { justify-content: space-between; gap: var(--s-3); }
    .filter-group { flex: 1; flex-direction: column; align-items: flex-start; gap: 5px; }
    .segmented { width: 100%; }
    .seg { flex: 1; justify-content: center; }
    .viewer-doc-name { max-width: 44vw; }
    .viewer-split { flex-direction: column; }
    .vsplitter { display: none; }
    .viewer-actions .btn-label { display: none; }
    .viewer-actions .btn { padding: 0 10px; }
}
