/*
 * Оформление админки.
 *
 * Токены, компоненты и геометрия взяты из эталона Kasso (файлы кабинета
 * лежат у владельца проекта): палитра, радиус 12, тень 0 4px 20px,
 * градиентная главная кнопка, KPI-карточки, меню с красной полосой слева.
 *
 * Django темизируется своими CSS-переменными, поэтому основную работу
 * делает их переопределение, а не борьба с чужими селекторами.
 */

/* --- Токены эталона --------------------------------------------------- */

:root {
    --bg: #F2F2F2;
    --bg2: #FFFFFF;
    --bg3: #E8E8E8;
    --card: #FFFFFF;
    --border: rgba(0, 0, 0, 0.10);
    --border2: rgba(0, 0, 0, 0.16);

    --text: #1A1A1A;
    --text2: #444444;
    --text3: #6B6B6B;
    --heading: #1A1A1A;
    --on-dark: #FFFFFF;

    --red: #D92424;
    --red2: #B51818;
    --red-bg: rgba(217, 36, 36, 0.08);
    --green: #1F8F47;
    --green-bg: rgba(31, 143, 71, 0.10);
    --blue: #1D4ED8;
    --blue-bg: rgba(29, 78, 216, 0.10);
    --orange: #B86B00;
    --orange-bg: rgba(184, 107, 0, 0.10);

    --primary: #D92424;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);

    --rs-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --rs-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Эталон светлый. Тёмная — только по явному выбору в переключателе Django. */
html[data-theme="dark"] {
    --bg: #101113;
    --bg2: #17191C;
    --bg3: #23262A;
    --card: #17191C;
    --border: rgba(255, 255, 255, 0.10);
    --border2: rgba(255, 255, 255, 0.18);

    --text: #ECEDEF;
    --text2: #A8ACB3;
    --text3: #7C8089;
    --heading: #F4F5F7;

    --red: #E5484D;
    --red2: #C93B40;
    --red-bg: rgba(229, 72, 77, 0.14);
    --green: #3FBF7F;
    --green-bg: rgba(63, 191, 127, 0.14);
    --blue: #6E93F7;
    --blue-bg: rgba(110, 147, 247, 0.14);
    --orange: #E0A72C;
    --orange-bg: rgba(224, 167, 44, 0.14);

    --primary: #E5484D;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

/* --- Переменные Django через токены эталона --------------------------- */

:root, html[data-theme="dark"], html[data-theme="light"] {
    --secondary: var(--bg2);
    --accent: var(--red);
    --primary-fg: var(--on-dark);

    --body-fg: var(--text);
    --body-bg: var(--bg);
    --body-quiet-color: var(--text2);
    --body-medium-color: var(--text2);
    --body-loud-color: var(--heading);

    --header-color: var(--text);
    --header-branding-color: var(--heading);
    --header-bg: var(--bg2);
    --header-link-color: var(--text);

    --breadcrumbs-fg: var(--text3);
    --breadcrumbs-link-fg: var(--text2);
    --breadcrumbs-bg: transparent;

    --link-fg: var(--red);
    --link-hover-color: var(--red2);
    --link-selected-fg: var(--red);

    --hairline-color: var(--border);
    --border-color: var(--border);
    --error-fg: var(--red);

    --message-success-bg: var(--green-bg);
    --message-warning-bg: var(--orange-bg);
    --message-error-bg: var(--red-bg);

    --darkened-bg: var(--bg3);
    --selected-bg: var(--bg3);
    --selected-row: var(--red-bg);

    --button-fg: var(--on-dark);
    --button-bg: var(--red);
    --button-hover-bg: var(--red2);
    --default-button-bg: var(--red);
    --default-button-hover-bg: var(--red2);
    --close-button-bg: var(--bg2);
    --close-button-hover-bg: var(--bg3);
    --delete-button-bg: var(--red-bg);
    --delete-button-hover-bg: var(--red-bg);

    --object-tools-fg: var(--text);
    --object-tools-bg: var(--bg2);
    --object-tools-hover-bg: var(--bg3);

    --font-family-primary: var(--rs-font);
    --font-family-monospace: var(--rs-font-mono);
}

/* --- Основа ----------------------------------------------------------- */

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--rs-font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 2px;
}

#content {
    box-sizing: border-box;
    padding: 24px 32px 88px;
}

#content > h1 {
    margin: 0 0 16px;
    font-size: 24px;
    font-weight: 700;
    color: var(--heading);
}

/* --- Шапка ------------------------------------------------------------ */

#header {
    background: var(--bg2);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    padding: 14px 32px;
    align-items: center;
}

#branding h1, #site-name a {
    font-size: 18px;
    font-weight: 700;
    color: var(--heading);
}

#branding h1 a:hover { text-decoration: none; }

/* Логотип эталона: градиентная плитка с буквой. */
#branding h1::before {
    content: "R";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-right: 10px;
    border-radius: 8px;
    background: linear-gradient(135deg, #D92424, #B51818);
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 800;
    vertical-align: middle;
}

#user-tools {
    font-size: 13px;
    font-weight: 500;
    color: var(--text2);
    text-transform: none;
    letter-spacing: 0;
}

#user-tools a { border-bottom: none; color: var(--text2); }
#user-tools a:hover { color: var(--red); }

div.breadcrumbs {
    background: transparent;
    color: var(--text3);
    border-bottom: none;
    padding: 16px 32px 0;
    font-size: 13px;
}

div.breadcrumbs a { color: var(--text2); }

/* --- Боковое меню ----------------------------------------------------- */

/* box-sizing обязателен: ширина меню у Django фиксирована и под неё же
   отведено место справа. Без него поле расширяло меню, и правый край
   страницы уезжал за окно. */
#nav-sidebar {
    box-sizing: border-box;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    padding: 12px 0 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Высота меню ограничена окном. Без запрета на сжатие блоки flex-колонки
   ужимаются под неё и наезжают друг на друга. */
#nav-sidebar > * { flex: 0 0 auto; }

/* Django рисует меню таблицей внутри .module — фон снимаем со всех
   уровней разом, иначе вокруг групп остаются серые прямоугольники. */
#nav-sidebar .module, #nav-sidebar table, #nav-sidebar tbody,
#nav-sidebar tr, #nav-sidebar th, #nav-sidebar td, #nav-sidebar caption {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

#nav-sidebar .module { margin: 0; }
#nav-sidebar table { width: 100%; }
#nav-sidebar tbody th { width: 100%; padding: 0; }
#nav-sidebar tbody td { padding: 0; }
#nav-sidebar tbody tr { line-height: 1; }

#nav-sidebar caption, #nav-sidebar .module caption {
    color: var(--text3);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 14px 20px 4px;
    text-align: left;
}

#nav-sidebar caption a.section {
    color: inherit; font-size: inherit; font-weight: inherit;
    letter-spacing: inherit; text-transform: inherit;
}

#nav-sidebar caption a.section:hover { text-decoration: none; }

#nav-sidebar tbody th a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text2);
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: 0.2s;
}

#nav-sidebar tbody th a:hover { text-decoration: none; }

/* Метка на месте иконки эталона: набор моделей меняется, рисовать
   два десятка значков ради меню не стоит. */
#nav-sidebar tbody th a::before {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: var(--text3);
    opacity: 0.5;
}

#nav-sidebar tbody tr:hover th a {
    color: var(--text);
    background: rgba(0, 0, 0, 0.04);
}

#nav-sidebar tr.current-model th a {
    color: var(--text);
    background: var(--red-bg);
    border-left-color: var(--red);
    font-weight: 600;
}

#nav-sidebar tr.current-model th a::before { background: var(--red); opacity: 1; }

/* Меню — список разделов. «Добавить» есть на самом списке. */
#nav-sidebar .addlink { display: none; }

#nav-filter {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: 8px;
    color: var(--text);
    margin: 4px 16px 8px;
    padding: 9px 12px;
    width: calc(100% - 32px);
    box-sizing: border-box;
    font-size: 13px;
}

#nav-filter::placeholder { color: var(--text3); }
#nav-filter:focus {
    border-color: rgb(154, 161, 171);
    box-shadow: rgba(17, 24, 39, 0.06) 0 0 0 3px;
    outline: none;
}

/* Кто вошёл — внизу меню, как в эталоне. */
.rs-side-user {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg2);
}

.rs-side-user__email {
    display: block;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    word-break: break-all;
    margin-bottom: 10px;
}

.rs-side-user__links { display: flex; gap: 8px; }

.rs-side-user__links a {
    flex: 1;
    text-align: center;
    padding: 7px 12px;
    border-radius: 8px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
}

.rs-side-user__links a:hover { background: #F7F7F7; text-decoration: none; }
html[data-theme="dark"] .rs-side-user__links a:hover { background: var(--bg3); }

/* --- Карточки и модули ------------------------------------------------ */

.module, .inline-group, #changelist-filter, .submit-row, .dashboard .module {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.module h2, .module caption, .inline-group h2, #changelist-filter h2 {
    background: transparent;
    color: var(--heading);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

/* --- Таблицы ---------------------------------------------------------- */

#changelist { background: transparent; }
#changelist table { background: var(--card); }

#changelist table thead th {
    background: transparent;
    color: var(--text2);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-align: left;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

#changelist table tbody td, #changelist table tbody th {
    padding: 14px 20px;
    font-size: 14px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

#changelist table tbody tr:last-child td,
#changelist table tbody tr:last-child th { border-bottom: none; }

#changelist table tbody tr:hover { background: rgba(0, 0, 0, 0.02); }
html[data-theme="dark"] #changelist table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

.row1, .row2 { background: var(--card); }

#result_list .field-number, #result_list .field-article,
#result_list .field-bin, #result_list .field-idempotency_key {
    white-space: nowrap;
    font-family: var(--rs-font-mono);
    font-size: 13px;
}

/* --- Кнопки эталона --------------------------------------------------- */

.button, input[type=submit], input[type=button], .submit-row input, a.button {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    background: linear-gradient(135deg, var(--red), var(--red2));
    color: var(--on-dark);
    box-shadow: rgba(217, 36, 36, 0.25) 0 4px 15px;
    line-height: normal;
    height: auto;
}

.button:hover, input[type=submit]:hover, .submit-row input:hover {
    box-shadow: rgba(217, 36, 36, 0.35) 0 6px 25px;
    transform: translateY(-1px);
    color: var(--on-dark);
    text-decoration: none;
}

.button[disabled], input[type=submit][disabled] {
    opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none;
}

/* Вторичное действие — белая кнопка с обводкой. */
.object-tools a, .submit-row a.closelink, .submit-row a.deletelink,
.button.cancel-link {
    display: inline-block;
    background: var(--bg2);
    color: var(--text);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    box-shadow: none;
    line-height: normal;
    height: auto;
}

.object-tools a:hover, .submit-row a.closelink:hover {
    background: #F7F7F7; color: var(--text); text-decoration: none;
    transform: none; box-shadow: none;
}

html[data-theme="dark"] .object-tools a:hover { background: var(--bg3); }

.submit-row a.deletelink { background: var(--red-bg); color: var(--red); border-color: transparent; }
.submit-row a.deletelink:hover { background: var(--red-bg); color: var(--red2); text-decoration: none; }

.object-tools { margin-top: 0; }
.object-tools li { margin-left: 8px; }

.submit-row {
    padding: 16px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* --- Формы эталона ---------------------------------------------------- */

.form-row { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.form-row:last-child { border-bottom: none; }

label {
    display: block;
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

input[type=text], input[type=password], input[type=email], input[type=url],
input[type=number], input[type=tel], input[type=search],
textarea, select, .vTextField {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--rs-font);
    outline: none;
    transition: border 0.2s;
    box-sizing: border-box;
}

input:focus, textarea:focus, select:focus, .vTextField:focus {
    border-color: rgb(154, 161, 171);
    box-shadow: rgba(17, 24, 39, 0.06) 0 0 0 3px;
}

.help, .helptext, div.help {
    color: var(--text3);
    font-size: 13px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    padding-top: 4px;
}

/* --- Сообщения -------------------------------------------------------- */

ul.messagelist li {
    background: var(--green-bg);
    color: var(--green);
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    padding: 14px 18px;
    margin: 0 0 12px;
}

ul.messagelist li.warning { background: var(--orange-bg); color: var(--orange); }
ul.messagelist li.error { background: var(--red-bg); color: var(--red); }

.errornote, ul.errorlist li {
    background: var(--red-bg);
    color: var(--red);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 14px;
}

/* --- Панель списка ---------------------------------------------------- */

#toolbar {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}

#toolbar form#changelist-search { display: flex; gap: 10px; align-items: center; }
#toolbar form input[type=text] { flex: 1; max-width: 300px; }
#toolbar #searchbar { margin: 0; }

.actions {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    font-size: 13px;
    color: var(--text2);
}

.paginator {
    background: transparent;
    border-top: 1px solid var(--border);
    color: var(--text2);
    font-size: 13px;
    padding: 14px 20px;
}

.paginator a, .paginator .this-page {
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg2);
    border: 1px solid var(--border2);
    color: var(--text);
}

.paginator a:hover { background: #F7F7F7; text-decoration: none; }
.paginator .this-page {
    background: linear-gradient(135deg, var(--red), var(--red2));
    border-color: transparent;
    color: var(--on-dark);
}

/* Цветные значки Django глушим — цвет в эталоне несёт смысл. */
.related-widget-wrapper-link img, .related-lookup img,
.addlink img, .changelink img, .viewlink img, .deletelink img {
    filter: grayscale(1) opacity(0.45);
    transition: filter 0.15s ease;
}

.related-widget-wrapper-link:hover img { filter: grayscale(0) opacity(1); }

/* --- Вход ------------------------------------------------------------- */

body.login { background: var(--bg); }

.login #container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding-bottom: 12px;
    width: 25em;
}

.login #header {
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: 1px solid var(--border);
    justify-content: center;
    padding: 22px 20px;
}

.login .form-row { border-bottom: none; padding: 8px 24px; }
.login .form-row input { width: 100%; }
.login .submit-row { border: none; box-shadow: none; padding: 14px 24px 4px; margin: 0; }
.login .submit-row input[type=submit] { width: 100%; }

/* --- Сводка на главной ------------------------------------------------ */

/* В dashboard.css у Django «#content { width: 600px }» под свою главную. */
.dashboard #content { width: auto; max-width: none; margin-right: 0; }

.rs-dash { max-width: 1400px; }

.rs-page-help {
    font-size: 14px;
    color: var(--text2);
    margin: -8px 0 24px;
    max-width: 760px;
    line-height: 1.5;
}

/* KPI-карточки эталона */
.rs-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.rs-card {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: 0.2s;
}

.rs-card:hover { border-color: rgba(217, 36, 36, 0.25); text-decoration: none; }

.rs-card__title {
    display: block;
    font-size: 12px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.rs-card__value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--heading);
    font-variant-numeric: tabular-nums;
}

/* Цвет числа несёт смысл: красное — есть что разбирать. */
.rs-card--urgent .rs-card__value { color: var(--red); }

.rs-card__hint {
    display: block;
    font-size: 12px;
    color: var(--text2);
    margin-top: 4px;
    line-height: 1.45;
}

/* Сетка панелей */
.rs-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

@media (max-width: 1100px) { .rs-grid { grid-template-columns: minmax(0, 1fr); } }

.rs-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.rs-block {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.rs-block__title {
    margin: 0 0 18px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Деньги */
.rs-money { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.rs-money__item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

html[data-theme="dark"] .rs-money__item { background: var(--bg3); }

.rs-eyebrow {
    display: block;
    font-size: 12px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rs-money__sum {
    display: block;
    margin: 8px 0 4px;
    font-size: 24px;
    font-weight: 700;
    color: var(--heading);
    font-variant-numeric: tabular-nums;
}

.rs-money__count { display: block; font-size: 12px; color: var(--text2); }

/* График */
.rs-chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 8px; }

.rs-chart__col {
    display: flex; flex: 1; flex-direction: column;
    align-items: center; justify-content: flex-end; height: 100%; min-width: 0;
}

.rs-chart__bar {
    width: 100%;
    min-height: 4px;
    border-radius: 6px 6px 2px 2px;
    background: linear-gradient(180deg, var(--red), var(--red2));
    transition: height 0.25s ease;
}

.rs-chart__col:has(.rs-chart__bar[style*="height: 0%"]) .rs-chart__bar {
    background: var(--bg3);
}

.rs-chart__label {
    margin-top: 8px; font-size: 11px; color: var(--text3);
    font-variant-numeric: tabular-nums;
}

/* Таблица последних заказов */
.rs-table { width: 100%; border-collapse: collapse; }

.rs-table td {
    padding: 12px 8px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.rs-table tr:last-child td { border-bottom: none; }
.rs-table a { color: var(--text); font-weight: 500; }
.rs-table a:hover { color: var(--red); }

.rs-mono { font-family: var(--rs-font-mono); font-size: 13px; }
.rs-muted { color: var(--text2); }
.rs-nowrap { white-space: nowrap; }

.rs-num {
    text-align: right; font-weight: 600;
    font-variant-numeric: tabular-nums; white-space: nowrap;
}

.rs-table .rs-mono, .rs-table .rs-num, .rs-table .rs-pill { white-space: nowrap; }

.rs-table td:nth-child(2) {
    max-width: 0; width: 99%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.rs-table td:first-child, .rs-table td:last-child,
.rs-table td:nth-child(3), .rs-table td:nth-child(4) { width: 1%; }

/* Значки статусов эталона */
.rs-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg3);
    color: var(--text2);
    white-space: nowrap;
}

.rs-pill--awaiting_payment, .rs-pill--needs_payment { background: var(--orange-bg); color: var(--orange); }
.rs-pill--paid, .rs-pill--delivered { background: var(--green-bg); color: var(--green); }
.rs-pill--cancelled { background: var(--red-bg); color: var(--red); }
.rs-pill--measurement, .rs-pill--cutting, .rs-pill--shipping { background: var(--blue-bg); color: var(--blue); }

/* Статистика каталога */
.rs-stats { margin: 0; display: flex; flex-direction: column; }

.rs-stats > div {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border);
}

.rs-stats > div:last-child { border-bottom: none; }
.rs-stats dt { color: var(--text2); font-size: 14px; }

.rs-stats dd {
    margin: 0; color: var(--heading);
    font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums;
}

.rs-stats__of { margin-left: 6px; color: var(--text3); font-size: 12px; font-weight: 400; }

/* Заметки */
.rs-note { margin: 16px 0 0; color: var(--text3); font-size: 12px; line-height: 1.5; }

.rs-alert {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--orange-bg);
    color: var(--orange);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
}

.rs-alert__detail {
    display: block; margin-top: 5px;
    font-family: var(--rs-font-mono); font-size: 11px; font-weight: 400;
    opacity: 0.85; overflow-wrap: anywhere;
}

/* Пустое состояние эталона */
.rs-empty {
    margin: 0; padding: 40px 20px;
    color: var(--text2); font-size: 15px; text-align: center;
}

/* Журнал действий */
.rs-log { display: flex; flex-direction: column; }

.rs-log__row {
    display: flex; gap: 12px; align-items: baseline;
    padding: 12px 0; border-bottom: 1px solid var(--border);
}

.rs-log__row:last-child { border-bottom: none; }

.rs-log__mark {
    flex: none; width: 7px; height: 7px;
    border-radius: 999px; background: var(--text3);
}

.rs-log__mark--add { background: var(--green); }
.rs-log__mark--delete { background: var(--red); }

.rs-log__body { min-width: 0; flex: 1; }

.rs-log__object {
    display: block; color: var(--text);
    font-size: 14px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

a.rs-log__object:hover { color: var(--red); }
.rs-log__meta { display: block; margin-top: 2px; color: var(--text3); font-size: 12px; }

/* Первый столбец списка у Django — ссылка на каждую строку. Красным
   он превращает таблицу в сплошную простыню акцента, поэтому здесь
   ссылка ведёт себя как текст, а красный остаётся на наведении. */
#result_list tbody a, #result_list tbody a:visited { color: var(--text); }
#result_list tbody a:hover { color: var(--red); }
#changelist-form .action-checkbox-column a { color: var(--text); }

/* --- Список: шапка, панель, фильтры ----------------------------------- */

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

.rs-page-head h1 { margin: 0; font-size: 24px; font-weight: 700; color: var(--heading); }

.rs-btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}

/* Псевдокласс обязателен: у Django «a:link» специфичнее одного класса,
   и белый текст кнопки перебивался красным цветом ссылок — выходил
   красный прямоугольник без надписи. */
.rs-btn--primary,
.rs-btn--primary:link,
.rs-btn--primary:visited {
    background: linear-gradient(135deg, var(--red), var(--red2));
    color: var(--on-dark);
    box-shadow: rgba(217, 36, 36, 0.25) 0 4px 15px;
}

.rs-btn--primary:hover {
    box-shadow: rgba(217, 36, 36, 0.35) 0 6px 25px;
    transform: translateY(-1px);
    color: var(--on-dark);
    text-decoration: none;
}

.rs-btn--ghost,
.rs-btn--ghost:link,
.rs-btn--ghost:visited {
    background: var(--bg2);
    color: var(--text);
    border: 1px solid var(--border2);
}

.rs-btn--ghost:hover { background: #F7F7F7; text-decoration: none; }
html[data-theme="dark"] .rs-btn--ghost:hover { background: var(--bg3); }

/* Панель над таблицей */
.rs-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.rs-search { display: flex; gap: 10px; align-items: center; flex: 1 1 320px; max-width: 420px; }
.rs-search input[type=search] { flex: 1; min-width: 0; }

.rs-toolbar__count {
    font-size: 13px;
    color: var(--text2);
    white-space: nowrap;
    margin-left: auto;
}

.rs-toolbar__reset { font-size: 13px; font-weight: 600; color: var(--red); white-space: nowrap; }

/* Фильтры строкой */
.rs-filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

html[data-theme="dark"] .rs-filters { background: rgba(255, 255, 255, 0.02); }

.rs-filter { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.rs-filter__title {
    flex: 0 0 132px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rs-filter__choices { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }

.rs-chip,
.rs-chip:link,
.rs-chip:visited {
    display: inline-block;
    padding: 6px 13px;
    border-radius: 999px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    color: var(--text2);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.rs-chip:hover { border-color: var(--red); color: var(--text); text-decoration: none; }

.rs-chip--on,
.rs-chip--on:link,
.rs-chip--on:visited {
    background: linear-gradient(135deg, var(--red), var(--red2));
    border-color: transparent;
    color: var(--on-dark);
    font-weight: 600;
}

.rs-chip--on:hover { color: var(--on-dark); }

@media (max-width: 900px) {
    .rs-filter__title { flex-basis: 100%; }
}

/* Таблица занимает всю карточку — колонки справа больше нет. */
#changelist.filtered .changelist-form-container { margin-right: 0; }
#changelist .changelist-form-container { width: 100%; }

/* Django задаёт списку свою высоту — 30 пикселей. С полями 10 сверху
   и снизу на текст оставалось десять, и значение обрезалось. */
select, .vTextField, input[type=text], input[type=password], input[type=email],
input[type=url], input[type=number], input[type=tel], input[type=search] {
    height: auto;
    min-height: 40px;
}

select { padding-right: 32px; }

/* Поля формы во всю ширину колонки — как в эталоне. */
.form-row input[type=text], .form-row input[type=email], .form-row input[type=url],
.form-row input[type=tel], .form-row textarea, .form-row .vTextField {
    width: 100%;
    max-width: 560px;
}

.form-row textarea { min-height: 96px; }
