/*
 * Общая тема панели lk.1grm.ru — поверх стандартных стилей Filament 3.
 * Подключается и в админ-разделе, и в кабинете клиента (см. App\Filament\Theme).
 * Идея: спокойный «облачный» интерфейс — белое поле, карточки на мягкой тени,
 * сгруппированное меню, кнопки-пилюли. Акцент: зелёный в светлой теме, лаймовый в тёмной.
 */

:root {
    --lk-bg: #ffffff;
    --lk-surface: #ffffff;
    --lk-sunken: #f3f5f8;
    --lk-line: #e6e9ef;
    --lk-ink: #1d232e;
    --lk-ink-soft: #6b7482;
    --lk-accent: #0f9d63;
    --lk-accent-ink: #ffffff;
    --lk-accent-soft: #e7f6ee;
    --lk-shadow: 0 1px 2px rgba(23, 32, 51, .04), 0 6px 28px rgba(23, 32, 51, .08);
    --lk-radius: 16px;
}

.dark {
    --lk-bg: #272c36;
    --lk-surface: #2d333e;
    --lk-sunken: #232831;
    --lk-line: #3a414e;
    --lk-ink: #f2f4f7;
    --lk-ink-soft: #a3acba;
    --lk-accent: #d3f36b;
    --lk-accent-ink: #1c2410;
    --lk-accent-soft: rgba(211, 243, 107, .12);
    --lk-shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 8px 30px rgba(0, 0, 0, .28);
}

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

.fi-body,
.dark .fi-body,
.fi-layout,
.dark .fi-layout,
.fi-main-ctn,
.dark .fi-main-ctn {
    background: var(--lk-bg);
}

.fi-body {
    color: var(--lk-ink);
    font-feature-settings: "tnum" 1, "ss01" 1;
    -webkit-font-smoothing: antialiased;
}

.fi-main {
    padding-top: .25rem;
    max-width: 1560px;
}

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

.fi-sidebar,
.dark .fi-sidebar {
    background: var(--lk-bg);
    border-inline-end: 1px solid var(--lk-line);
    box-shadow: none;
}

.fi-sidebar-header,
.dark .fi-sidebar-header {
    background: transparent;
    box-shadow: none;
    border: 0;
    height: 5rem;
    padding-inline: 1.5rem;
}

.fi-sidebar-nav {
    padding: .5rem 1rem 1.5rem;
    gap: 1.25rem;
}

.fi-sidebar-group-label {
    font-size: .875rem;
    font-weight: 700;
    letter-spacing: -.005em;
    color: var(--lk-ink);
}

.fi-sidebar-item-button {
    border-radius: 8px;
    padding: .55rem .75rem;
    gap: .8rem;
    transition: background-color .15s ease, transform .15s ease;
}

.fi-sidebar-item-button:hover,
.dark .fi-sidebar-item-button:hover {
    background: var(--lk-sunken);
}

.fi-sidebar-item-active > .fi-sidebar-item-button,
.dark .fi-sidebar-item-active > .fi-sidebar-item-button {
    background: var(--lk-sunken);
}

.fi-sidebar-item-label,
.dark .fi-sidebar-item-label {
    font-size: .9375rem;
    font-weight: 450;
    color: var(--lk-ink);
}

.fi-sidebar-item-active .fi-sidebar-item-label,
.dark .fi-sidebar-item-active .fi-sidebar-item-label {
    font-weight: 650;
    color: var(--lk-ink);
}

.fi-sidebar-item-icon,
.dark .fi-sidebar-item-icon {
    color: var(--lk-ink-soft);
}

.fi-sidebar-item-active .fi-sidebar-item-icon,
.dark .fi-sidebar-item-active .fi-sidebar-item-icon {
    color: var(--lk-accent);
}

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

.fi-topbar nav,
.dark .fi-topbar nav {
    background: var(--lk-bg);
    box-shadow: none;
    border: 0;
    min-height: 5rem;
    padding-inline: 1.5rem;
}

.lk-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    color: var(--lk-ink);
    font-weight: 700;
    font-size: 1.45rem;
    letter-spacing: -.035em;
    line-height: 1;
    white-space: nowrap;
}

.lk-brand-mark {
    width: 2.1rem;
    height: 2.1rem;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 11px 11px 11px 3px;
    background: var(--lk-accent);
    color: var(--lk-accent-ink);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -.06em;
}

.lk-brand small {
    font-size: .8rem;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--lk-ink-soft);
    align-self: flex-end;
    padding-bottom: .12rem;
}

.lk-pills {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-inline-end: .25rem;
}

.lk-pill {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    height: 2.5rem;
    padding: 0 1rem;
    border: 1px solid var(--lk-line);
    border-radius: 999px;
    font-size: .9rem;
    font-weight: 500;
    color: var(--lk-ink);
    background: var(--lk-bg);
    white-space: nowrap;
    max-width: 26rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lk-pill svg {
    width: 1.15rem;
    height: 1.15rem;
    flex: none;
    color: var(--lk-ink-soft);
}

.lk-pill span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.lk-dot {
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    flex: none;
    background: #22b36b;
    box-shadow: 0 0 0 4px rgba(34, 179, 107, .16);
}

.lk-dot--bad {
    background: #e5484d;
    box-shadow: 0 0 0 4px rgba(229, 72, 77, .18);
    animation: lk-pulse 1.6s ease-in-out infinite;
}

@keyframes lk-pulse {
    50% { box-shadow: 0 0 0 7px rgba(229, 72, 77, 0); }
}

@media (max-width: 900px) {
    .lk-pills { display: none; }
}

/* ---------- Заголовок страницы ---------- */

.fi-header-heading {
    font-size: 1.7rem;
    font-weight: 650;
    letter-spacing: -.03em;
    color: var(--lk-ink);
}

.fi-header-subheading,
.dark .fi-header-subheading {
    color: var(--lk-ink-soft);
    font-size: .95rem;
}

.fi-breadcrumbs-item-label,
.dark .fi-breadcrumbs-item-label {
    color: var(--lk-ink-soft);
}

/* ---------- Карточки ---------- */

.fi-section,
.dark .fi-section,
.fi-ta-ctn,
.dark .fi-ta-ctn,
.fi-wi-stats-overview-stat,
.dark .fi-wi-stats-overview-stat {
    background: var(--lk-surface);
    border-radius: var(--lk-radius);
    box-shadow: var(--lk-shadow);
    --tw-ring-shadow: 0 0 #0000;
    --tw-ring-color: transparent;
    border: 0;
}

.fi-section-header {
    padding: 1.4rem 1.5rem .25rem;
}

.fi-section-header-heading {
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -.01em;
}

.fi-section-content {
    padding: 1.25rem 1.5rem 1.5rem;
}

.fi-section-content-ctn,
.dark .fi-section-content-ctn {
    border-top: 0;
}

/* Появление карточек при загрузке страницы */
@media (prefers-reduced-motion: no-preference) {
    .fi-main .fi-ta-ctn {
        animation: lk-fade .35s ease both;
    }

    .fi-main .fi-section,
    .fi-main .fi-wi-stats-overview-stat {
        animation: lk-rise .45s cubic-bezier(.2, .7, .2, 1) both;
    }

    .fi-wi-stats-overview-stat:nth-child(2) { animation-delay: .05s; }
    .fi-wi-stats-overview-stat:nth-child(3) { animation-delay: .1s; }
    .fi-wi-stats-overview-stat:nth-child(4) { animation-delay: .15s; }
    .fi-wi-stats-overview-stat:nth-child(5) { animation-delay: .2s; }
}

@keyframes lk-fade {
    from { opacity: 0; }
}

@keyframes lk-rise {
    from { opacity: 0; transform: translateY(10px); }
}

/* ---------- Сводка ---------- */

.fi-wi-stats-overview-stat {
    padding: 1.4rem 1.5rem 1.3rem;
    transition: transform .2s ease, box-shadow .2s ease;
}

a.fi-wi-stats-overview-stat:hover {
    transform: translateY(-2px);
}

.fi-wi-stats-overview-stat-label,
.dark .fi-wi-stats-overview-stat-label {
    font-size: .95rem;
    font-weight: 650;
    color: var(--lk-ink);
}

.fi-wi-stats-overview-stat-value,
.dark .fi-wi-stats-overview-stat-value {
    font-size: 2.3rem;
    line-height: 1.1;
    font-weight: 650;
    letter-spacing: -.04em;
    margin-top: .6rem;
    color: var(--lk-ink);
}

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

/* Содержимое таблицы не обрезаем: иначе выпадающее меню действий режется краем таблицы. */
.fi-ta-ctn,
.dark .fi-ta-ctn {
    overflow: visible;
}

.fi-ta-content {
    border-radius: 0 0 var(--lk-radius) var(--lk-radius);
}

.fi-ta-header-toolbar,
.dark .fi-ta-header-toolbar {
    padding: 1rem 1.25rem;
    border-bottom: 0;
}

.fi-ta-content,
.dark .fi-ta-content {
    border-top: 0;
}

.fi-ta-table thead,
.dark .fi-ta-table thead {
    background: transparent;
}

.fi-ta-table thead tr,
.dark .fi-ta-table thead tr {
    background: transparent;
}

.fi-ta-header-cell {
    padding-block: .7rem;
}

.fi-ta-header-cell-label,
.dark .fi-ta-header-cell-label {
    font-size: .82rem;
    font-weight: 500;
    color: var(--lk-ink-soft);
}

.fi-ta-table > tbody,
.dark .fi-ta-table > tbody,
.fi-ta-table > thead,
.dark .fi-ta-table > thead {
    border-color: var(--lk-line);
}

.fi-ta-table > tbody > tr,
.dark .fi-ta-table > tbody > tr {
    border-color: var(--lk-line);
    transition: background-color .12s ease;
}

.fi-ta-table > tbody > tr:hover,
.dark .fi-ta-table > tbody > tr:hover {
    background: var(--lk-sunken);
}

.fi-ta-text-item-label {
    font-size: .92rem;
}

.fi-ta-cell .fi-ta-text {
    padding-block: .95rem;
}

.fi-ta-empty-state-heading {
    font-size: 1.15rem;
    font-weight: 650;
}

.fi-ta-empty-state-icon-ctn,
.dark .fi-ta-empty-state-icon-ctn {
    background: var(--lk-accent-soft);
}

.fi-ta-empty-state-icon,
.dark .fi-ta-empty-state-icon {
    color: var(--lk-accent);
}

/* ---------- Кнопки ---------- */

.fi-btn {
    border-radius: 8px;
    font-weight: 550;
    transition: transform .12s ease, filter .12s ease, background-color .12s ease;
}

.fi-btn:active {
    transform: scale(.98);
}

/* Главные действия в шапке страницы — пилюли, как кнопка «Новый ресурс» */
.fi-header .fi-btn,
.fi-ta-actions .fi-btn {
    border-radius: 999px;
    padding-inline: 1.15rem;
}

.fi-btn.fi-color-primary,
.dark .fi-btn.fi-color-primary {
    background: var(--lk-accent);
    color: var(--lk-accent-ink);
    box-shadow: none;
}

.fi-btn.fi-color-primary:hover,
.dark .fi-btn.fi-color-primary:hover {
    background: var(--lk-accent);
    filter: brightness(1.07);
}

.fi-btn.fi-color-primary .fi-btn-icon,
.dark .fi-btn.fi-color-primary .fi-btn-icon,
.fi-btn.fi-color-primary .fi-btn-label {
    color: var(--lk-accent-ink);
}

.fi-btn.fi-color-gray,
.dark .fi-btn.fi-color-gray {
    background: var(--lk-bg);
    color: var(--lk-ink);
    box-shadow: inset 0 0 0 1px var(--lk-line);
}

.fi-btn.fi-color-gray:hover,
.dark .fi-btn.fi-color-gray:hover {
    background: var(--lk-sunken);
}

.fi-link.fi-color-primary,
.dark .fi-link.fi-color-primary,
.fi-link.fi-color-primary .fi-link-icon {
    color: var(--lk-accent);
}

.dark .text-primary-400,
.text-primary-600 {
    color: var(--lk-accent);
}

/* ---------- Метки состояния ---------- */

.fi-badge {
    border-radius: 999px;
    padding: .2rem .65rem;
    font-weight: 550;
    --tw-ring-shadow: 0 0 #0000;
    box-shadow: none;
}

/* ---------- Поля ввода, меню, окна ---------- */

.fi-input-wrp,
.dark .fi-input-wrp {
    border-radius: 8px;
    background: var(--lk-bg);
    box-shadow: inset 0 0 0 1px var(--lk-line);
    --tw-ring-shadow: 0 0 #0000;
}

.fi-input-wrp:focus-within,
.dark .fi-input-wrp:focus-within {
    box-shadow: inset 0 0 0 2px var(--lk-accent);
}

.fi-dropdown-panel,
.dark .fi-dropdown-panel,
.fi-modal-window,
.dark .fi-modal-window {
    background: var(--lk-surface);
    border-radius: var(--lk-radius);
    box-shadow: var(--lk-shadow);
    --tw-ring-color: var(--lk-line);
}

.fi-avatar {
    border-radius: 50%;
}

/* ---------- Карточка базы: строки с отточиями ---------- */

.lk-leaders .fi-in-entry-wrp > div {
    display: flex;
    align-items: baseline;
    gap: .6rem;
}

.lk-leaders .fi-in-entry-wrp-label {
    flex: none;
    color: var(--lk-ink-soft);
}

.lk-leaders .fi-in-entry-wrp-label,
.lk-leaders .fi-in-entry-wrp-label span {
    font-weight: 450;
    color: var(--lk-ink-soft);
}

.lk-leaders .fi-in-entry-wrp > div > div:first-child {
    flex: 1 1 auto;
    display: flex;
    align-items: baseline;
    gap: .6rem;
    min-width: 6rem;
}

.lk-leaders .fi-in-entry-wrp > div > div:first-child::after {
    content: "";
    flex: 1;
    border-bottom: 1px dotted var(--lk-ink-soft);
    opacity: .55;
    transform: translateY(-3px);
}

.lk-leaders .fi-in-entry-wrp > div > div:last-child {
    flex: 0 1 auto;
    min-width: 0;
    text-align: end;
}

/* ---------- Таблица копий в карточке ---------- */

.lk-table {
    width: 100%;
    font-size: .92rem;
    border-collapse: collapse;
}

.lk-table th {
    text-align: start;
    font-size: .82rem;
    font-weight: 500;
    color: var(--lk-ink-soft);
    padding: .5rem 1rem .6rem 0;
    border-bottom: 1px solid var(--lk-line);
}

.lk-table td {
    padding: .8rem 1rem .8rem 0;
    border-bottom: 1px solid var(--lk-line);
    white-space: nowrap;
}

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

.lk-table td:last-child,
.lk-table th:last-child {
    text-align: end;
    padding-inline-end: 0;
}

.lk-table a {
    color: var(--lk-accent);
    font-weight: 550;
}

.lk-table a:hover {
    text-decoration: underline;
}

.lk-muted {
    color: var(--lk-ink-soft);
    font-size: .92rem;
}

/* ---------- Страница входа ---------- */

.fi-simple-layout {
    background:
        radial-gradient(60rem 30rem at 12% -10%, var(--lk-accent-soft), transparent 60%),
        radial-gradient(40rem 26rem at 105% 110%, var(--lk-accent-soft), transparent 60%),
        var(--lk-sunken);
}

.fi-simple-main,
.dark .fi-simple-main {
    background: var(--lk-surface);
    border-radius: 22px;
    box-shadow: var(--lk-shadow);
    --tw-ring-color: transparent;
    padding: 2.5rem 2.25rem;
}

.fi-simple-header-heading {
    font-size: 1.5rem;
    font-weight: 650;
    letter-spacing: -.03em;
}

.fi-simple-main .fi-btn {
    border-radius: 999px;
    padding-block: .7rem;
}

/* ---------- Главная кнопка в шапке кабинета ---------- */

.lk-cta {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    height: 2.5rem;
    padding: 0 1.15rem 0 .9rem;
    border-radius: 999px;
    background: var(--lk-accent);
    color: var(--lk-accent-ink);
    font-size: .92rem;
    font-weight: 600;
    white-space: nowrap;
    transition: filter .12s ease, transform .12s ease;
}

.lk-cta:hover { filter: brightness(1.07); }
.lk-cta:active { transform: scale(.98); }
.lk-cta svg { width: 1.1rem; height: 1.1rem; }

/* ---------- Ход подключения программы ---------- */

.lk-orders {
    display: grid;
    gap: .75rem;
}

.lk-order {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.4rem;
    border-radius: var(--lk-radius);
    background: var(--lk-accent-soft);
    color: var(--lk-ink);
}

.lk-order--failed {
    background: rgba(229, 72, 77, .1);
}

.lk-order-text {
    display: grid;
    gap: .15rem;
    font-size: .92rem;
}

.lk-order-text strong { font-weight: 650; font-size: 1rem; }
.lk-order-text span { color: var(--lk-ink-soft); }

.lk-order-mark {
    flex: none;
    width: 1.6rem;
    height: 1.6rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e5484d;
    color: #fff;
    font-weight: 700;
}

.lk-spinner {
    flex: none;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 2.5px solid color-mix(in srgb, var(--lk-accent) 25%, transparent);
    border-top-color: var(--lk-accent);
    animation: lk-spin .8s linear infinite;
}

@keyframes lk-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Полоса состояния над карточкой базы ---------- */

.lk-notes {
    display: grid;
    gap: .6rem;
}

.lk-note {
    display: flex;
    align-items: flex-start;
    gap: .9rem;
    padding: 1rem 1.3rem;
    border-radius: var(--lk-radius);
    background: var(--lk-sunken);
}

.lk-note .lk-spinner { margin-top: .1rem; }

.lk-note-dot {
    flex: none;
    width: .6rem;
    height: .6rem;
    margin-top: .45rem;
    border-radius: 50%;
    background: var(--lk-ink-soft);
}

.lk-note--wait { background: var(--lk-accent-soft); }
.lk-note--info .lk-note-dot { background: var(--lk-accent); }
.lk-note--warn { background: rgba(245, 166, 35, .13); }
.lk-note--warn .lk-note-dot { background: #f5a623; }
.lk-note--bad { background: rgba(229, 72, 77, .1); }
.lk-note--bad .lk-note-dot { background: #e5484d; }

/* ---------- Результат в истории ---------- */

.lk-tone { font-weight: 550; }
.lk-tone--ok { color: var(--lk-accent); }
.lk-tone--bad { color: #e5484d; }
.lk-tone--wait { color: #d98a00; }
.lk-tone--info { color: var(--lk-ink-soft); font-weight: 450; }

/* ---------- Вкладки карточки ---------- */

.fi-tabs,
.dark .fi-tabs {
    background: transparent;
    box-shadow: none;
    --tw-ring-color: transparent;
    border-bottom: 1px solid var(--lk-line);
    border-radius: 0;
    padding: 0 1.25rem;
    gap: 1.5rem;
}

.fi-tabs-item,
.dark .fi-tabs-item {
    border-radius: 0;
    padding: .95rem 0;
    background: transparent;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.fi-tabs-item:hover,
.dark .fi-tabs-item:hover {
    background: transparent;
}

.fi-tabs-item-active,
.dark .fi-tabs-item-active {
    background: transparent;
    border-bottom-color: var(--lk-accent);
}

.fi-tabs-item-active .fi-tabs-item-label,
.dark .fi-tabs-item-active .fi-tabs-item-label,
.fi-tabs-item-active .fi-tabs-item-icon,
.dark .fi-tabs-item-active .fi-tabs-item-icon {
    color: var(--lk-ink);
}

.fi-in-tabs,
.dark .fi-in-tabs {
    background: var(--lk-surface);
    border-radius: var(--lk-radius);
    box-shadow: var(--lk-shadow);
    --tw-ring-color: transparent;
}

/* ---------- Переписка с поддержкой ---------- */

.lk-thread {
    display: grid;
    gap: 1.4rem;
    max-width: 62rem;
}

.lk-msg {
    display: grid;
    gap: .4rem;
    max-width: 85%;
}

.lk-msg--mine { justify-self: end; }
.lk-msg--theirs { justify-self: start; }

.lk-msg-body {
    padding: 1.1rem 1.35rem;
    border-radius: var(--lk-radius);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.55;
    font-size: .95rem;
}

.lk-msg--mine .lk-msg-body {
    background: var(--lk-sunken);
    border-bottom-right-radius: 5px;
}

.lk-msg--theirs .lk-msg-body {
    background: var(--lk-surface);
    box-shadow: inset 0 0 0 1px var(--lk-line);
    border-bottom-left-radius: 5px;
}

.lk-msg-meta {
    font-size: .8rem;
    color: var(--lk-ink-soft);
}

.lk-msg--mine .lk-msg-meta { text-align: end; }

.lk-rate {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    font-size: .88rem;
    color: var(--lk-ink-soft);
}

.lk-rate-btn {
    padding: .35rem .9rem;
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px var(--lk-line);
    color: var(--lk-ink);
    font-weight: 500;
    transition: background-color .12s ease, box-shadow .12s ease;
}

.lk-rate-btn:hover { background: var(--lk-sunken); }
.lk-rate-btn.is-on { background: var(--lk-accent-soft); box-shadow: inset 0 0 0 2px var(--lk-accent); }
.lk-rate-btn--bad.is-on { background: rgba(229, 72, 77, .1); box-shadow: inset 0 0 0 2px #e5484d; }

.lk-reply {
    position: sticky;
    bottom: 0;
    display: grid;
    gap: .6rem;
    max-width: 62rem;
    padding: 1rem 0 1.25rem;
    background: var(--lk-bg);
    border-top: 1px solid var(--lk-line);
}

.lk-reply textarea {
    width: 100%;
    padding: .85rem 1rem;
    border: 0;
    border-radius: 12px;
    background: var(--lk-bg);
    color: var(--lk-ink);
    box-shadow: inset 0 0 0 1px var(--lk-line);
    font-size: .95rem;
    line-height: 1.5;
    resize: vertical;
}

.lk-reply textarea:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--lk-accent);
}

.lk-reply-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.lk-reply-bar .fi-btn { border-radius: 999px; padding-inline: 1.15rem; }

/* Вкладки-пилюли над списками («Открытые / Закрытые / Все») */
.fi-resource-list-records-page .fi-tabs,
.dark .fi-resource-list-records-page .fi-tabs {
    width: fit-content;
    margin-inline: 0;
    padding: .25rem;
    gap: .15rem;
    border: 0;
    border-radius: 999px;
    background: var(--lk-sunken);
}

.fi-resource-list-records-page .fi-tabs-item,
.dark .fi-resource-list-records-page .fi-tabs-item {
    padding: .45rem 1rem;
    margin: 0;
    border: 0;
    border-radius: 999px;
}

.fi-resource-list-records-page .fi-tabs-item-active,
.dark .fi-resource-list-records-page .fi-tabs-item-active {
    background: var(--lk-surface);
    box-shadow: 0 1px 3px rgba(23, 32, 51, .12);
}
