/* ==========================================================================
   ANXB.RU — Redesign Design System
   Scoped under body.redesign to avoid breaking existing pages
   ========================================================================== */

/* ---------- Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Golos+Text:wght@400;500;600;700&family=Onest:wght@500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- Design Tokens ---------- */
body.redesign {
    --bg-primary: #FAFAFA;
    --bg-secondary: #FFFFFF;
    --bg-sidebar: #F5F5F5;
    --text-primary: #1A1A1A;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;

    --accent: #2563EB;
    --accent-hover: #1D4ED8;
    --accent-light: #EFF6FF;

    --success: #16A34A;
    --success-light: #F0FDF4;
    --warning: #F59E0B;
    --warning-light: #FFFBEB;
    --error: #DC2626;
    --error-light: #FEF2F2;

    --border: #E5E7EB;
    --border-light: #F3F4F6;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --font-body: 'Golos Text', system-ui, sans-serif;
    --font-heading: 'Onest', 'Golos Text', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;

    --header-height: 56px;

    /* Override site variables for redesigned pages */
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.6;
}

/* ---------- Base Overrides ---------- */
body.redesign a {
    color: var(--accent);
}

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

body.redesign a.btn {
    color: inherit;
}

/* ---------- App Header ---------- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
}

.app-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
}

.app-header__logo {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.app-header__logo:hover {
    color: var(--text-primary);
    opacity: 0.8;
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-header__profile-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.app-header__profile-link:hover {
    background: var(--accent);
    color: #FFFFFF;
    box-shadow: var(--shadow-sm);
}

/* Header balance badge — кликабельный shortcut в журнал операций */
.app-header__balance {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.app-header__balance:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    color: var(--accent);
}

.app-header__balance-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.app-header__balance-value {
    font-variant-numeric: tabular-nums;
}

/* Header profile dropdown menu */
.app-header__menu {
    position: relative;
}

button.app-header__profile-link {
    border: 0;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

button.app-header__profile-link[aria-expanded="true"] {
    background: var(--accent);
    color: #FFFFFF;
}

.app-header__menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.375rem;
    z-index: 110;
    display: flex;
    flex-direction: column;
    gap: 1px;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.app-header__menu-panel[hidden] {
    display: none;
}

.app-header__menu-header {
    padding: 0.625rem 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.25rem;
}

.app-header__menu-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.app-header__menu-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
    word-break: break-all;
}

.app-header__menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 40px;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 0;
    text-align: left;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.app-header__menu-item:hover,
.app-header__menu-item:focus-visible {
    background: var(--accent-light);
    color: var(--accent);
    outline: none;
}

.app-header__menu-item--danger {
    color: var(--error);
}

.app-header__menu-item--danger:hover,
.app-header__menu-item--danger:focus-visible {
    background: var(--error-light);
    color: var(--error);
}

.app-header__menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0.25rem 0;
}

.app-header__menu-form {
    margin: 0;
    width: 100%;
}

/* Body offset for fixed header */
body.redesign {
    padding-top: var(--header-height);
    overflow-x: hidden;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn--primary {
    background: var(--accent);
    color: #FFFFFF;
    border-color: var(--accent);
}

.btn--primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn--secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border);
}

.btn--secondary:hover:not(:disabled) {
    background: var(--bg-sidebar);
    border-color: var(--border);
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
    padding: 0.5rem 0.75rem;
}

.btn--ghost:hover:not(:disabled) {
    background: var(--bg-sidebar);
    color: var(--text-primary);
}

.btn--danger {
    background: transparent;
    color: var(--error);
    border-color: transparent;
    padding: 0.5rem 0.75rem;
}

.btn--danger:hover:not(:disabled) {
    background: var(--error-light);
}

.btn--sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn--lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.btn--icon {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
}

.btn--icon svg {
    width: 18px;
    height: 18px;
}

.btn--full {
    width: 100%;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.card--elevated {
    box-shadow: var(--shadow-md);
}

.card--interactive {
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    cursor: pointer;
}

.card--interactive:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* ---------- Dashboard Actions ---------- */
.dashboard-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 1rem 2rem;
}

.dashboard-actions {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.dashboard-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 200px;
    height: 120px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--text-primary);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.dashboard-action:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
}

.dashboard-action__icon {
    width: 32px;
    height: 32px;
    color: var(--accent);
}

.dashboard-action__icon svg {
    width: 100%;
    height: 100%;
}

.dashboard-action__label {
    font-weight: 600;
    font-size: 0.9375rem;
}

.dashboard-action__sub {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: -0.25rem;
    text-align: center;
}

/* ---------- Case List (redesigned) ---------- */
.rd-case-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.rd-case-card {
    display: grid;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-primary);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.rd-case-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.rd-case-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
}

.rd-case-card__title {
    font-weight: 600;
    font-size: 0.9375rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rd-case-card__topic {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    background: var(--accent-light);
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0;
}

.rd-case-card__meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.rd-case-card__actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
    margin-left: auto;
}

.rd-case-card__delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted, #9CA3AF);
    cursor: pointer;
    border-radius: 6px;
    transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.rd-case-card__delete svg {
    width: 16px;
    height: 16px;
}

.rd-case-card__delete:hover {
    color: var(--error, #DC2626);
    background: var(--error-light, #FEF2F2);
}

/* ---------- Sidebar (generic) ---------- */
.sidebar {
    width: 260px;
    height: 100%;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar__header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-shrink: 0;
}

.sidebar__title {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar__case-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar__case-title:hover {
    color: var(--accent);
}

.sidebar__list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.sidebar__item {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.1s ease;
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar__item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

.sidebar__item--active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
}

.sidebar__item--active:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.sidebar__item-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.sidebar__item-delete {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.sidebar__item:hover .sidebar__item-delete,
.sidebar__item-wrapper:hover .sidebar__item-delete {
    display: flex;
}

.sidebar__item-delete:hover {
    color: var(--error);
    background: var(--error-light);
}

.sidebar__item-delete svg {
    width: 16px;
    height: 16px;
}

/* ---------- Sidebar sections (cases + chats unified) ---------- */
.sidebar__section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-light);
}

.sidebar__section:last-child {
    flex: 1 1 auto;
    min-height: 0;
    border-bottom: none;
}

.sidebar__section-title {
    margin: 0;
    padding: 0.65rem 0.85rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.sidebar__section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 0.5rem;
}

.sidebar__section-header .sidebar__section-title {
    padding-right: 0.25rem;
}

.sidebar__section-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.1s ease, background 0.1s ease;
}

.sidebar__section-action:hover {
    color: var(--accent);
    background: rgba(0, 0, 0, 0.05);
}

.sidebar__section-form {
    padding: 0 0.85rem 0.5rem;
    margin: 0;
    flex-shrink: 0;
}

.sidebar__section .sidebar__list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.25rem 0.5rem 0.5rem;
}

.sidebar__list--cases {
    max-height: 22vh;
    overflow-y: auto;
}

.sidebar__empty {
    margin: 0;
    padding: 0.75rem 0.85rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- Chat Bubbles (redesigned) ---------- */
.bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    max-width: 80%;
    animation: fadeSlideUp 0.25s ease-out;
    line-height: 1.6;
    font-size: 0.9375rem;
}

.bubble--user {
    background: var(--accent);
    color: #FFFFFF;
    margin-left: auto;
    border-bottom-right-radius: var(--radius-sm);
}

.bubble--user a {
    color: #FFFFFF;
    text-decoration: underline;
}

.bubble--assistant {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: var(--radius-sm);
}

.bubble--system {
    background: var(--warning-light);
    color: var(--text-primary);
    border: 1px solid var(--warning);
    font-size: 0.8125rem;
    text-align: center;
    max-width: 100%;
}

/* ---------- Chat Layout (two-panel) ---------- */
.chat-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    height: calc(100vh - var(--header-height));
    overflow: hidden;
    max-width: 100%;
}

.chat-layout__sidebar {
    height: 100%;
    overflow: hidden;
    min-width: 0;
}

.chat-layout__main {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.chat-layout__main > .chat-main,
.chat-layout__main > section {
    min-width: 0;
    width: 100%;
}

.chat-layout__thread {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-layout__composer {
    border-top: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

/* ---------- Composer ---------- */
.composer {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.composer__input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: transparent;
    max-height: 150px;
    min-height: 24px;
}

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

.composer__send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: #FFFFFF;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.composer__send:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.composer__send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.composer__send svg {
    width: 18px;
    height: 18px;
}

.composer__attach {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.composer__attach:hover {
    color: var(--text-primary);
    background: var(--bg-sidebar);
}

.composer__attach svg {
    width: 18px;
    height: 18px;
}

/* ---------- Typing Indicator ---------- */
.typing-indicator {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    width: fit-content;
    animation: fadeSlideUp 0.25s ease-out;
}

.typing-indicator__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator__dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator__dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* ---------- Inputs (redesigned) ---------- */
.input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

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

.textarea {
    min-height: 6rem;
    resize: vertical;
}

/* ---------- Form Components ---------- */
.form-section {
    display: grid;
    gap: 1rem;
}

.form-field {
    display: grid;
    gap: 0.375rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.form-error {
    font-size: 0.8125rem;
    color: var(--error);
}

/* ---------- Flash Messages ---------- */
body.redesign .flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.5;
    border: 1px solid;
}

body.redesign .flash--success {
    background: var(--success-light);
    border-color: var(--success);
    color: #166534;
}

body.redesign .flash--error {
    background: var(--error-light);
    border-color: var(--error);
    color: #991B1B;
}

body.redesign .flash--warning {
    background: var(--warning-light);
    border-color: var(--warning);
    color: #92400E;
}

/* ---------- Profile Page ---------- */
.profile-page {
    max-width: 640px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.profile-section {
    display: grid;
    gap: 0.75rem;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
}

.profile-section + .profile-section {
    margin-top: 1rem;
}

.profile-section__title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.profile-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
}

.profile-field__label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.profile-field__value {
    font-weight: 500;
    text-align: right;
}

.profile-links {
    display: grid;
    gap: 0.25rem;
    margin-top: 1rem;
}

.profile-links a {
    display: block;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: color 0.15s ease;
}

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

/* ---------- Empty State ---------- */
.rd-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.rd-empty__icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    color: var(--border);
}

.rd-empty__icon svg {
    width: 100%;
    height: 100%;
}

.rd-empty h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

.rd-empty p {
    margin: 0;
    font-size: 0.875rem;
}

/* ---------- Badge ---------- */
.rd-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

.rd-badge--accent {
    background: var(--accent-light);
    color: var(--accent);
}

.rd-badge--success {
    background: var(--success-light);
    color: var(--success);
}

.rd-badge--warning {
    background: var(--warning-light);
    color: #92400E;
}

.rd-badge--error {
    background: var(--error-light);
    color: var(--error);
}

/* ---------- Mobile Sidebar Toggle ---------- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 101;
    width: var(--header-height);
    height: var(--header-height);
    border-radius: 0;
    background: transparent;
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    box-shadow: none;
    padding: 0;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
    background: rgba(15, 23, 42, 0.05);
    outline: none;
}

.sidebar-toggle svg {
    width: 22px;
    height: 22px;
}

.sidebar-toggle--hidden {
    display: none !important;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(0, 0, 0, 0.3);
}

/* ---------- Animations ---------- */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    body.redesign *,
    body.redesign *::before,
    body.redesign *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Auth Pages ---------- */
body.redesign .auth-page {
    padding-top: var(--header-height);
    min-height: 100vh;
}

body.redesign .auth-layout {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
    max-width: 480px;
    margin: 2rem auto;
    padding: 0 1rem;
}

body.redesign .auth-info {
    order: 2;
}

body.redesign .auth-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    display: grid;
    gap: 1.25rem;
}

body.redesign .auth-form .form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

body.redesign .auth-form .field {
    display: grid;
    gap: 0.35rem;
}

body.redesign .auth-form .field__label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    font-family: var(--font-body);
}

body.redesign .auth-form .field__input {
    border-radius: var(--radius-md);
    min-height: 2.75rem;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

body.redesign .auth-form .field__input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: var(--bg-secondary);
    outline: none;
}

body.redesign .auth-form .field__error {
    font-size: 0.8125rem;
    color: var(--error);
}

body.redesign .auth-form .field__hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

body.redesign .captcha-box {
    padding: 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-sidebar);
    border: 1px dashed var(--border);
}

body.redesign .captcha-box__digits {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--text-primary);
    margin-top: 0.5rem;
}

body.redesign .captcha-input {
    font-family: var(--font-mono);
    letter-spacing: 0.15em;
    font-size: 1rem;
}

body.redesign .consent-box {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    box-shadow: none;
}

body.redesign .consent-box--alert {
    background: var(--warning-light);
    border-color: var(--warning);
    box-shadow: none;
}

body.redesign .consent-box--alert .consent-box__label,
body.redesign .consent-box--alert .field__hint,
body.redesign .consent-box--alert .field__error {
    color: var(--text-primary);
}

body.redesign .consent-box--alert .consent-box__label a {
    color: var(--accent);
}

body.redesign .consent-box--alert .consent-box__label input {
    accent-color: var(--accent);
}

body.redesign .consent-box__label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-primary);
}

body.redesign .consent-box__label input[type="checkbox"] {
    margin-top: 0.15rem;
    flex: 0 0 auto;
}

body.redesign .consent-box__label a {
    color: var(--accent);
}

body.redesign .app-note {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

body.redesign .app-note a {
    color: var(--accent);
    font-weight: 500;
}

body.redesign .auth-info h1 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.2;
    color: var(--text-primary);
}

body.redesign .auth-info .eyebrow {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.5rem;
}

body.redesign .auth-info .app-lead {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 0.75rem 0 0;
    line-height: 1.6;
}

body.redesign .auth-info .panel-list {
    margin: 1.25rem 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.75rem;
}

body.redesign .auth-info .panel-list li {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding-left: 1.25rem;
    position: relative;
    line-height: 1.5;
}

body.redesign .auth-info .panel-list li::before {
    content: "";
    position: absolute;
    top: 0.5rem;
    left: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

@media (min-width: 480px) {
    body.redesign .auth-form .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 599px) {
    body.redesign .auth-info {
        display: none;
    }
}

@media (min-width: 860px) {
    body.redesign .auth-layout {
        grid-template-columns: 1fr 1fr;
        max-width: 960px;
        align-items: start;
        gap: 3rem;
        margin: 3rem auto;
    }

    body.redesign .auth-info {
        order: -1;
    }

    body.redesign .auth-form {
        padding: 2rem;
    }
}

/* ---------- Responsive: Tablet ---------- */
@media (max-width: 1024px) {
    .chat-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .chat-layout__sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        width: min(280px, 86vw);
        z-index: 90;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        background: var(--bg-sidebar);
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
    }

    .chat-layout.sidebar-open .chat-layout__sidebar {
        transform: translateX(0);
    }

    .chat-layout.sidebar-open .sidebar-overlay {
        display: block;
    }

    .sidebar-toggle {
        display: flex;
    }

    body.has-mobile-sidebar .app-header__inner {
        padding-left: calc(var(--header-height) - 0.75rem);
    }

    .dashboard-actions {
        gap: 1rem;
    }

    .dashboard-action {
        width: 170px;
        height: 110px;
    }

    /* Sidebar height on tablet/mobile — лимит cases list, чтобы chats оставались видимы */
    .sidebar__list--cases {
        max-height: 30vh;
    }
}

/* ---------- Responsive: Mobile ---------- */
@media (max-width: 768px) {
    body.redesign {
        --header-height: 50px;
    }

    .app-header {
        padding: 0 1rem;
    }

    .app-header__balance {
        padding: 0.35rem 0.55rem;
        font-size: 0.75rem;
    }

    .app-header__balance-label {
        display: none;
    }

    .app-header__menu-panel {
        min-width: 220px;
        max-width: calc(100vw - 1.25rem);
    }

    .app-header__menu-item {
        min-height: 44px;
        font-size: 0.9375rem;
        padding: 0.625rem 0.875rem;
    }

    .dashboard-actions {
        flex-direction: column;
        align-items: center;
    }

    .dashboard-action {
        width: 100%;
        max-width: 300px;
        height: 100px;
    }

    .bubble {
        max-width: 90%;
    }

    /* Make case chat layout scrollable on mobile instead of fixed viewport height */
    .chat-layout {
        height: auto;
        min-height: calc(100vh - var(--header-height));
        overflow-y: auto;
    }

    .chat-layout__main {
        height: auto;
        overflow: visible;
    }

    /* Override inline height/overflow on chat section */
    .chat-layout__main > .chat-main {
        height: auto !important;
        overflow: visible !important;
    }

    .chat-thread {
        overflow: visible;
        max-height: none;
        min-height: 0;
    }

    .chat-composer-stack {
        position: static;
    }

    .chat-attachments-section {
        flex-shrink: 0;
    }

    .chat-layout__thread {
        padding: 1rem;
    }

    .chat-layout__composer {
        padding: 0.75rem 1rem;
    }

    /* Status badges переносятся под заголовок */
    .chat-main__header {
        padding: 0.75rem 1rem;
    }

    .chat-main__status {
        width: 100%;
        justify-content: flex-start;
    }

    .profile-page {
        margin: 1rem auto;
    }

    .dashboard-hero {
        padding: 2rem 0.75rem 1.5rem;
    }

    .rd-case-card__actions {
        opacity: 1;
    }

    .rd-file-card__actions {
        opacity: 1;
    }

    .rd-file-card__info {
        flex-wrap: wrap;
    }
}

/* ---------- Responsive: Small Mobile ---------- */
@media (max-width: 480px) {
    .rd-container {
        width: calc(100% - 1rem);
    }

    .dashboard-hero {
        padding: 1.5rem 0.5rem 1rem;
    }

    .dashboard-action {
        max-width: 100%;
        height: auto;
        min-height: 80px;
        padding: 0.75rem;
    }

    .bubble {
        max-width: 95%;
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
    }

    .chat-layout__thread {
        padding: 0.75rem;
    }

    .chat-layout__composer {
        padding: 0.5rem 0.75rem;
    }

    .composer {
        padding: 0.5rem 0.75rem;
    }

    .rd-case-card {
        padding: 0.75rem 1rem;
    }

    .profile-page {
        margin: 0.5rem auto;
        padding: 0 0.5rem;
    }

    .card {
        padding: 1rem;
    }

    .app-header__logo {
        font-size: 1rem;
    }
}

/* ---------- Scrollbar Styling ---------- */
body.redesign ::-webkit-scrollbar {
    width: 6px;
}

body.redesign ::-webkit-scrollbar-track {
    background: transparent;
}

body.redesign ::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

body.redesign ::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---------- Section Title ---------- */
.rd-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

/* ---------- File List (redesigned) ---------- */
.rd-file-list {
    display: grid;
    gap: 0.75rem;
}

.rd-file-card {
    display: grid;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease;
}

.rd-file-card:hover {
    border-color: var(--border);
}

.rd-file-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.rd-file-card__info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
}

.rd-file-card__title {
    font-weight: 600;
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rd-file-card__meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.rd-file-card__summary {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.rd-file-card__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.rd-file-card:hover .rd-file-card__actions {
    opacity: 1;
}

/* ---------- Create Block ---------- */
.rd-create-block {
    padding: 1rem 1.25rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

/* ---------- Page Intro ---------- */
.page-intro {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* ---------- Container (redesigned) ---------- */
.rd-container {
    width: min(1280px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0;
}

/* ==========================================================================
   Admin Panel
   ========================================================================== */

/* ---------- Admin Header Nav ---------- */
.app-header__nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0 1.5rem;
    flex: 1;
    justify-content: center;
}

.app-header__nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.app-header__nav-link:hover {
    background: var(--bg-sidebar);
    color: var(--text-primary);
}

.app-header__nav-link--active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.app-header__nav-link--active:hover {
    background: var(--accent-light);
    color: var(--accent);
}

/* ---------- Admin Stats Grid ---------- */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.admin-stat-card__label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.admin-stat-card__value {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.admin-stat-card__sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---------- Admin Recent List ---------- */
.admin-recent-list {
    display: flex;
    flex-direction: column;
}

.admin-recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
}

.admin-recent-item:last-child {
    border-bottom: none;
}

.admin-recent-item__info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    flex: 1;
}

.admin-recent-item__name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-recent-item__email {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-recent-item__date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ---------- Admin Quick Links ---------- */
.admin-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.admin-link-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.admin-link-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
    color: var(--text-primary);
}

.admin-link-card__title {
    font-weight: 600;
    font-size: 0.9375rem;
}

.admin-link-card__desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* ---------- Admin Section Title ---------- */
.admin-section-title {
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* ---------- Admin Responsive ---------- */
@media (max-width: 900px) {
    .admin-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .app-header__nav {
        gap: 0.125rem;
        margin: 0 0.5rem;
    }

    .app-header__nav-link {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .admin-stat-card__value {
        font-size: 1.375rem;
    }
}

@media (max-width: 480px) {
    .app-header__nav {
        display: none;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 360px) {
    .app-header__balance-value {
        font-size: 0.75rem;
    }
}
