:root {
    --canvas: #f6f6f8;
    --surface: #ffffff;
    --sidebar: #ffffff;
    --border: #e8e8ec;
    --border-strong: #dcdce2;
    --text: #17171a;
    --text-muted: #75758a;
    --text-faint: #a3a3b0;

    --accent: #5b5bf6;
    --accent-hover: #4a4af0;
    --accent-soft: #eeeeff;
    --accent-text: #4038d6;

    --danger: #e0392f;
    --danger-soft: #fdeceb;
    --success: #17875a;
    --success-soft: #e8f6ef;
    --warning: #b4700a;
    --warning-soft: #fdf3e2;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.05);
    --shadow: 0 4px 16px rgba(20, 20, 30, 0.06);
    --shadow-lg: 0 12px 32px rgba(20, 20, 30, 0.12);

    --sidebar-width: 264px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    display: flex;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--canvas);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); text-decoration: none; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 650; margin: 0 0 6px; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 32px 0 14px; }

/* ---------- Sidebar ---------- */

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 20px 16px;
    gap: 4px;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px;
}

.brand-mark {
    height: 30px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

.brand-name { font-weight: 650; font-size: 0.95rem; }

.sidebar__label {
    display: block;
    padding: 0 10px;
    margin-bottom: 6px;
    font-size: 0.7rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
}

/* Environment picker */

.env-picker {
    position: relative;
    margin-bottom: 18px;
}

.env-picker summary {
    display: flex;
    align-items: center;
    gap: 9px;
    list-style: none;
    cursor: pointer;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--canvas);
    font-size: 0.85rem;
    font-weight: 550;
}
.env-picker summary::-webkit-details-marker { display: none; }
.env-picker summary::marker { content: ""; }
.env-picker summary:hover { border-color: var(--text-faint); }
.env-picker[open] summary { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.env-picker__label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.env-picker__chevron { color: var(--text-faint); flex-shrink: 0; transition: transform 0.15s ease; }
.env-picker[open] .env-picker__chevron { transform: rotate(180deg); }

.env-picker__dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-faint);
}
.env-picker__dot--production { background: var(--success); }
.env-picker__dot--test { background: var(--danger); }
.env-picker__dot--sandbox { background: var(--success); }

.env-picker__panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 20;
}

.env-picker__option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 9px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text);
}
.env-picker__option:hover { background: var(--canvas); }
.env-picker__option.is-active { background: var(--accent-soft); color: var(--accent-text); }
.env-picker__option svg { margin-left: auto; flex-shrink: 0; }

.env-picker__option-text { display: flex; flex-direction: column; line-height: 1.3; overflow: hidden; }
.env-picker__option-name { font-weight: 550; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.env-picker__option-kind { font-size: 0.72rem; color: var(--text-muted); }
.env-picker__empty { padding: 10px 9px; font-size: 0.82rem; color: var(--text-muted); margin: 0; }

/* Nav */

.sidebar__nav { display: flex; flex-direction: column; gap: 18px; }

.nav-section { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 550;
}
.nav-link:hover { background: var(--canvas); color: var(--text); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent-text); }
.nav-link svg { flex-shrink: 0; }

.sidebar__spacer { flex: 1; }

/* User card */

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.user-card__avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 650;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.user-card__info { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; flex: 1; }
.user-card__name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card__role { font-size: 0.72rem; color: var(--text-muted); }

.user-card__logout button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    color: var(--text-faint);
    cursor: pointer;
}
.user-card__logout button:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Main content ---------- */

.content {
    flex: 1;
    min-width: 0;
    padding: 40px 48px;
}

.content--auth {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.content__inner {
    max-width: 880px;
    margin: 0 auto;
}

.content--auth .content__inner { margin: 0; max-width: none; }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

/* Cards */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}
.card--error { border-color: #f3c6c2; background: var(--danger-soft); }
.card > *:first-child { margin-top: 0; }
.card > *:last-child { margin-bottom: 0; }

/* Forms */

.field { margin-bottom: 18px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 0.9rem; }
.help { color: var(--text-muted); font-size: 0.8rem; margin: 0; }
.form-error { color: var(--danger); font-size: 0.85rem; margin: 0; }

input[type="text"], input[type="password"], input[type="file"], select, textarea {
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}
textarea { resize: vertical; }
input[type="text"]:focus, input[type="password"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Dropzone (file upload) */

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 40px 20px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--canvas);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover { border-color: var(--text-faint); }
.dropzone:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }

.dropzone__icon { color: var(--text-faint); }
.dropzone.is-dragover .dropzone__icon { color: var(--accent); }
.dropzone__text { font-size: 0.9rem; color: var(--text); margin: 4px 0 0; }
.dropzone__text strong { color: var(--accent-text); }
.dropzone__hint { font-size: 0.78rem; color: var(--text-muted); margin: 2px 0 0; }
.dropzone__filename { font-size: 0.85rem; font-weight: 600; color: var(--text); margin: 8px 0 0; }
.dropzone__filename:empty { display: none; }

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

.button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}
.button--primary { background: var(--accent); color: white; }
.button--primary:hover { background: var(--accent-hover); }
.button--secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.button--secondary:hover { background: var(--canvas); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button:disabled:hover { background: var(--accent); }

.progress-bar {
    height: 6px;
    margin-top: 14px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}
.progress-bar[hidden] { display: none; }
.progress-bar__fill {
    height: 100%;
    width: 40%;
    border-radius: 999px;
    background: var(--accent);
    animation: progress-indeterminate 1.1s ease-in-out infinite;
}
@keyframes progress-indeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

/* Determinate variant - a real known percentage (e.g. translation job
   progress), not the sliding indeterminate animation above. */
.progress-bar__fill--determinate {
    width: 0%;
    animation: none;
    transition: width 0.4s ease-out;
}

/* Table */

.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.87rem;
}
.table th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; background: var(--canvas); }
.table tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.table-scroll .table { border: none; box-shadow: none; border-radius: 0; }

/* Badges */

.badge { padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 650; }
.badge--uploaded { background: var(--canvas); color: var(--text-muted); }
.badge--pending { background: var(--canvas); color: var(--text-muted); }
.badge--processing { background: var(--warning-soft); color: var(--warning); }
.badge--ready { background: var(--success-soft); color: var(--success); }
.badge--done { background: var(--success-soft); color: var(--success); }
.badge--invalid { background: var(--warning-soft); color: var(--warning); }
.badge--failed { background: var(--danger-soft); color: var(--danger); }

/* Review groups (translation review screen, grouped by product) */

.review-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.review-summary p { margin: 0; }

.review-groups { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.review-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.review-group:hover { border-color: var(--border-strong); }
.review-group[open] { box-shadow: var(--shadow); }
.review-group--has-failures { border-color: #f3c6c2; }

/* Hide the native disclosure marker (Chrome/Safari use ::-webkit-details-
   marker, Firefox generates a ::marker on the list-item box) so only the
   custom chevron icon shows - list-style alone isn't enough cross-browser. */
.review-group__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 15px 20px;
    cursor: pointer;
    list-style: none;
}
.review-group__summary::-webkit-details-marker { display: none; }
.review-group__summary::marker { content: ""; }
.review-group__summary:hover { background: var(--canvas); }

.review-group__heading { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.review-group__sku {
    font-size: 0.72rem;
    font-weight: 650;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    background: var(--canvas);
    border: 1px solid var(--border);
    padding: 2px 9px;
    border-radius: 999px;
    flex-shrink: 0;
}
.review-group__name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.review-group__meta { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.review-group__chevron { color: var(--text-faint); transition: transform 0.15s ease; flex-shrink: 0; }
.review-group[open] .review-group__chevron { transform: rotate(180deg); }

.review-group__body { border-top: 1px solid var(--border); }

.review-row { display: flex; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.review-row:last-child { border-bottom: none; }
.review-row:nth-child(even) { background: var(--canvas); }

.review-row__content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.review-row__name { margin: 0; font-weight: 600; font-size: 0.88rem; }
.review-row__description { margin: 0; font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; }

/* Language chips - a fixed 8-color identity palette cycled by position (see
   LOCALE_CHIP_CLASSES in views.py), deliberately distinct from the
   success/warning/danger hues used for status. locale-chip--failed
   overrides to the danger color regardless of the numbered class, so a
   failed row breaks the color pattern and is easy to spot at a glance. */
.locale-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    align-self: flex-start;
}
.locale-chip--1 { background: #e8ecfd; color: #3348c9; }
.locale-chip--2 { background: #f4e8fd; color: #7d33c9; }
.locale-chip--3 { background: #e2f5f2; color: #0f7d6c; }
.locale-chip--4 { background: #fdf0e3; color: #b5670e; }
.locale-chip--5 { background: #fde8f0; color: #c23670; }
.locale-chip--6 { background: #e5f1fd; color: #1372c2; }
.locale-chip--7 { background: #f0ebe3; color: #8a5a2b; }
.locale-chip--8 { background: #eaeef5; color: #445069; }
.locale-chip.locale-chip--failed { background: var(--danger-soft); color: var(--danger); }
.locale-chip--failed::after { content: " !"; }

/* Push-to-ENAD status icon - sits right next to the locale chip, so a row's
   translation status (the chip) and its push status (this icon) stay
   visually distinct rather than overloading one indicator with two
   meanings. */
.push-status-icon { flex-shrink: 0; align-self: flex-start; margin-top: 4px; }
.push-status-icon--pushed { color: var(--success); }
.push-status-icon--failed { color: var(--danger); }

/* Messages (toasts) */

.messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(340px, calc(100vw - 40px));
}
.messages__item {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    animation: toast-in 0.15s ease-out;
}
.messages__item.is-leaving { animation: toast-out 0.15s ease-in forwards; }
.messages__item--success { background: var(--success-soft); color: var(--success); }
.messages__item--error { background: var(--danger-soft); color: var(--danger); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-6px); }
}

/* Auth page */

.auth-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 36px 32px;
}
.auth-card__brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 22px; }
.auth-card__brand .brand-mark { height: 38px; }
.auth-card__brand h1 { margin: 0; }
.auth-card h1 { text-align: center; font-size: 1.2rem; }
.auth-card .muted { text-align: center; display: block; margin-bottom: 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card button { justify-content: center; margin-top: 6px; }
