/*
 * msg2cart panels in the website style: ink on a neutral ramp, hue only for
 * good and bad. Token names and values come from resources/css/app.css in
 * kommandhub-website. Filament's CSS sits in cascade layers, so these unlayered
 * rules win without !important.
 */

:root {
    --kh-canvas: #ffffff;
    --kh-surface: #ffffff;
    --kh-surface-2: #fafafa;
    --kh-surface-3: #f4f4f5;
    --kh-line: #e6e6e8;
    --kh-line-strong: #d1d1d6;
    --kh-field: #8f8f98;
    --kh-ink: #0a0a0a;
    --kh-ink-2: #52525b;
    --kh-ink-3: #71717a;
    --kh-positive: #15803d;
    --kh-negative: #b91c1c;
    --kh-shadow-color: 10 10 10;

    --radius-card: 0.875rem;
    --radius-field: 0.625rem;
    --shadow-float: 0 2px 4px rgb(var(--kh-shadow-color) / 0.04), 0 18px 48px -20px rgb(var(--kh-shadow-color) / 0.22);
    --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
}

.dark {
    --kh-canvas: #0a0a0a;
    --kh-surface: #111112;
    --kh-surface-2: #161617;
    --kh-surface-3: #1f1f22;
    --kh-line: #272729;
    --kh-line-strong: #3f3f45;
    --kh-field: #6b6b75;
    --kh-ink: #fafafa;
    --kh-ink-2: #a1a1aa;
    --kh-ink-3: #7f7f88;
    --kh-positive: #4ade80;
    --kh-negative: #f87171;
    --kh-shadow-color: 0 0 0;

    /* Filament reads 400 to 600 for primary in dark mode: ink turns light. */
    --primary-400: #fafafa;
    --primary-500: #a1a1aa;
    --primary-600: #fafafa;
}

/* Page and chrome */
.fi-body,
.dark .fi-body {
    background-color: var(--kh-canvas);
    color: var(--kh-ink);
    font-feature-settings: 'cv11', 'ss01';
    text-rendering: optimizeLegibility;
}

.fi-topbar,
.fi-sidebar,
.fi-sidebar-header {
    background-color: var(--kh-surface);
}

.fi-sidebar-item-btn {
    border-radius: var(--radius-field);
}

/* Filament switches the desktop sidebar width instantly; ease it, the content follows. */
@media (min-width: 1024px) {
    .fi-sidebar {
        transition: width 200ms var(--ease-out-soft);
    }
}

.fi-sidebar-item.fi-active > .fi-sidebar-item-btn {
    background-color: var(--kh-surface-3);
}

::selection {
    background-color: var(--kh-ink);
    color: var(--kh-canvas);
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--kh-ink);
    outline-offset: 2px;
}

/* Type */
.fi-header-heading,
.fi-simple-header-heading {
    font-weight: 600;
    letter-spacing: -0.03em;
}

.fi-section-header-heading,
.fi-ta-header-heading,
.fi-modal-heading {
    letter-spacing: -0.015em;
}

.fi-breadcrumbs-item-label,
.fi-in-placeholder,
.fi-ta-placeholder {
    color: var(--kh-ink-3);
}

.fi-fo-field-label-content {
    color: var(--kh-ink-2);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Help (App\Filament\Help): a quiet question mark; the padding widens the tap target without moving the layout. */
.kh-help {
    display: inline-flex;
    vertical-align: middle;
    padding: 0.375rem;
    margin: -0.375rem -0.125rem;
    border-radius: 999px;
    color: var(--kh-ink-3);
    cursor: help;
    transition: color 150ms var(--ease-out-soft);
}

.kh-help:hover,
.kh-help:focus-visible {
    color: var(--kh-ink);
}

/* Cards: surface and hairline, no shadow */
.fi-section:not(.fi-section-not-contained):not(.fi-aside),
.fi-ta-ctn,
.fi-wi-stats-overview-stat,
.fi-simple-main {
    background-color: var(--kh-surface);
    border-radius: var(--radius-card);
    box-shadow: 0 0 0 1px var(--kh-line);
}

/* Tables */
.fi-ta-header-cell {
    color: var(--kh-ink-2);
    font-weight: 600;
}

.fi-ta-row {
    border-color: var(--kh-line);
}

/* Buttons: pills, solid ink for the primary action, field outline otherwise */
.fi-btn {
    border-radius: 9999px;
    font-weight: 600;
    transition:
        background-color 180ms var(--ease-out-soft),
        color 180ms var(--ease-out-soft),
        opacity 180ms var(--ease-out-soft);
}

.fi-btn-group .fi-btn {
    border-radius: 0;
}

.fi-btn.fi-color-primary:not(.fi-outlined) {
    --bg: var(--kh-ink);
    --text: var(--kh-canvas);
    --hover-bg: var(--kh-ink-2);
    --hover-text: var(--kh-canvas);
    --dark-bg: var(--kh-ink);
    --dark-text: var(--kh-canvas);
    --dark-hover-bg: var(--kh-ink-2);
    --dark-hover-text: var(--kh-canvas);
}

.fi-btn:not(.fi-color) {
    --tw-ring-color: var(--kh-field);
    background-color: transparent;
    box-shadow: inset 0 0 0 1px var(--kh-field);
}

.fi-btn:not(.fi-color):hover {
    background-color: var(--kh-surface-3);
}

/* Fields: one step off the card, field boundary when idle */
.fi-input-wrp {
    border-radius: var(--radius-field);
}

.fi-input-wrp:not(.fi-disabled) {
    background-color: var(--kh-surface-2);
}

.fi-input-wrp:not(.fi-invalid):not(.fi-disabled):not(:focus-within) {
    --tw-ring-color: var(--kh-field);
}

/* Badges: the website's bordered tag */
.fi-badge {
    --tw-ring-color: var(--kh-line);
    background-color: var(--kh-surface);
    border-radius: 9999px;
    font-weight: 500;
    letter-spacing: 0.02em;
    padding-inline: 0.625rem;
}

.fi-badge:not(.fi-color),
.fi-badge.fi-color-gray,
.fi-badge.fi-color-primary,
.fi-badge.fi-color-warning,
.fi-badge.fi-color-info {
    --text: var(--kh-ink-2);
    --dark-text: var(--kh-ink-2);
}

.fi-badge.fi-color-success {
    --text: var(--kh-positive);
    --dark-text: var(--kh-positive);
    --tw-ring-color: color-mix(in srgb, var(--kh-positive) 35%, transparent);
}

.fi-badge.fi-color-danger {
    --text: var(--kh-negative);
    --dark-text: var(--kh-negative);
    --tw-ring-color: color-mix(in srgb, var(--kh-negative) 35%, transparent);
}

/* Dialogs */
.fi-modal-window {
    background-color: var(--kh-surface);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-float);
}

/* App shell: content on a tinted canvas, white cards on it; sidebar and topbar are the white frame around it,
   separated by hairlines (Linear / Vercel style). Dark mode keeps the same steps on the dark ramp. */
.fi-main-ctn {
    background-color: color-mix(in srgb, var(--kh-surface-2) 50%, var(--kh-surface-3));
}

.dark .fi-main-ctn {
    background-color: var(--kh-canvas);
}

.fi-topbar {
    box-shadow: 0 1px 0 var(--kh-line);
}

@media (min-width: 1024px) {
    .fi-sidebar {
        box-shadow: 1px 0 0 var(--kh-line);
    }
}

.fi-logo {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* Sidebar: small uppercase group labels, compact items, the active one bold on a tint */
.fi-sidebar-group-label {
    color: var(--kh-ink-3);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.fi-sidebar-item-btn {
    padding-block: 0.375rem;
}

.fi-sidebar-item-label {
    color: var(--kh-ink-2);
    font-size: 0.875rem;
    font-weight: 500;
}

.fi-sidebar-item-btn:hover {
    background-color: var(--kh-surface-2);
}

.fi-sidebar-item.fi-active > .fi-sidebar-item-btn .fi-sidebar-item-label {
    color: var(--kh-ink);
    font-weight: 600;
}

/* Page header: a calmer title */
.fi-header-heading {
    font-size: 1.5rem;
    line-height: 2rem;
}

/* Section headers sit on a hairline, like a card title bar */
.fi-section:not(.fi-section-not-contained):not(.fi-aside) > .fi-section-header {
    border-bottom: 1px solid var(--kh-line);
}

/* Stats: label above, big tabular number, quiet description; no extra height */
.fi-wi-stats-overview-stat {
    padding: 1rem 1.25rem;
}

.fi-wi-stats-overview-stat-label {
    color: var(--kh-ink-3);
    font-size: 0.8125rem;
    font-weight: 500;
}

.fi-wi-stats-overview-stat-value {
    font-size: 1.75rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.fi-wi-stats-overview-stat-description {
    color: var(--kh-ink-3);
    font-size: 0.75rem;
}

/* Tables: a tinted header row with small caps, a quiet hover */
.fi-ta-header-cell {
    background-color: var(--kh-surface-2);
    color: var(--kh-ink-3);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.fi-ta-row:hover {
    background-color: var(--kh-surface-2);
}

.fi-ta-cell {
    font-variant-numeric: tabular-nums;
}

/* A sticky Save bar (Actions::sticky()): the frame's surface with a hairline, not a floating shadow */
.fi-sc-actions.fi-sticky .fi-ac {
    background-color: var(--kh-surface);
    box-shadow: 0 -1px 0 var(--kh-line);
}

/* Apply page: story on the left, the form on the right, stacked on small screens */
.fi-simple-main:has(.kh-apply) {
    margin: 0;
    padding: 0;
    max-width: none;
    background: none;
    border-radius: 0;
    box-shadow: none;
}

.kh-apply {
    display: grid;
    min-height: 100dvh;
    width: 100%;
}

.kh-apply-story {
    /* Always dark, in both modes: the website's ink block. */
    --s-ink: #fafafa;
    --s-ink-2: #a1a1aa;
    --s-line: rgb(255 255 255 / 0.12);
    --s-card: #161617;
    --px: 0;
    --py: 0;
    position: relative;
    overflow: hidden;
    background-color: #0a0a0a;
    background-image: radial-gradient(rgb(255 255 255 / 0.07) 1px, transparent 1px);
    background-size: 22px 22px;
    color: var(--s-ink);
    padding: 2rem 1rem;
}

.dark .kh-apply-story {
    box-shadow: inset -1px 0 0 var(--kh-line);
}

.kh-apply-glow {
    position: absolute;
    inset: -20% -10% auto auto;
    width: 36rem;
    height: 36rem;
    border-radius: 9999px;
    background: radial-gradient(closest-side, rgb(255 255 255 / 0.1), transparent);
    transform: translate3d(calc(var(--px) * -40px), calc(var(--py) * -40px), 0);
    transition: transform 900ms var(--ease-out-soft);
    pointer-events: none;
}

.kh-apply-story-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    max-width: 34rem;
    margin-inline: auto;
}

.kh-apply-wordmark {
    display: inline-flex;
    align-items: baseline;
    gap: 0.5rem;
    color: var(--s-ink);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.kh-apply-wordmark span {
    color: var(--s-ink-2);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.kh-apply-eyebrow {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--s-line);
    border-radius: 9999px;
    color: var(--s-ink-2);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.kh-apply-headline {
    font-size: clamp(1.875rem, 1.2rem + 2.4vw, 3rem);
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.kh-apply-lead {
    margin-top: 1rem;
    color: var(--s-ink-2);
    font-size: 1rem;
    line-height: 1.6;
}

/* Product visual: a chat card and two status chips at different depths */
.kh-apply-visual {
    position: relative;
    display: none;
    height: 16.5rem;
}

.kh-layer {
    position: absolute;
    transform: translate3d(calc(var(--px) * var(--depth) * 1px), calc(var(--py) * var(--depth) * 1px), 0);
    transition: transform 700ms var(--ease-out-soft);
}

.kh-chat {
    width: 20rem;
    padding: 1rem;
    border: 1px solid var(--s-line);
    border-radius: var(--radius-card);
    background-color: var(--s-card);
    box-shadow: 0 30px 60px -30px rgb(0 0 0 / 0.8);
}

.kh-chat-head {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--s-line);
}

.kh-chat-head strong,
.kh-chip strong {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
}

.kh-chat-head small,
.kh-chip small {
    display: block;
    color: var(--s-ink-2);
    font-size: 0.6875rem;
}

.kh-chat-avatar {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background-color: var(--s-ink);
    color: #0a0a0a;
    font-size: 0.8125rem;
    font-weight: 700;
}

.kh-bubble {
    max-width: 85%;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.875rem;
    font-size: 0.8125rem;
    line-height: 1.45;
    animation: kh-rise 600ms var(--ease-out-soft) both;
    animation-delay: calc(300ms + var(--i) * 450ms);
}

.kh-bubble-in {
    border-bottom-left-radius: 0.25rem;
    background-color: rgb(255 255 255 / 0.08);
}

.kh-bubble-out {
    margin-left: auto;
    border-bottom-right-radius: 0.25rem;
    background-color: var(--s-ink);
    color: #0a0a0a;
}

.kh-order {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-weight: 600;
}

.kh-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.5rem;
    border: 1px solid rgb(21 128 61 / 0.35);
    border-radius: 9999px;
    color: #15803d;
    font-size: 0.6875rem;
}

.kh-status i {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 9999px;
    background-color: #15803d;
}

.kh-chip {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--s-line);
    border-radius: 9999px;
    background-color: rgb(22 22 23 / 0.85);
    backdrop-filter: blur(8px);
    box-shadow: 0 20px 40px -24px rgb(0 0 0 / 0.9);
    animation: kh-float 7s ease-in-out infinite;
}

.kh-chip .fi-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--s-ink-2);
}

.kh-chip-a {
    top: 1rem;
    right: 0;
}

.kh-chip-b {
    bottom: 0.5rem;
    right: 2rem;
}

.kh-chip-b .kh-chip {
    animation-delay: -3.5s;
}

/* Value and steps */
.kh-apply-props {
    display: grid;
    gap: 1rem;
}

.kh-apply-props li {
    display: flex;
    gap: 0.75rem;
    color: var(--s-ink-2);
    font-size: 0.875rem;
    line-height: 1.5;
}

.kh-apply-props strong {
    display: block;
    color: var(--s-ink);
    font-weight: 600;
}

.kh-apply-props .fi-icon {
    flex: none;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.125rem;
    color: var(--s-ink);
}

.kh-apply-steps {
    display: none;
    gap: 0.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--s-line);
    color: var(--s-ink-2);
    font-size: 0.8125rem;
}

.kh-apply-steps li {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.kh-apply-steps span {
    display: grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    border: 1px solid var(--s-line);
    border-radius: 9999px;
    color: var(--s-ink);
    font-size: 0.75rem;
    font-weight: 600;
}

/* Form column */
.kh-apply-form {
    background-color: var(--kh-canvas);
    padding: 2rem 1rem 3rem;
}

.kh-apply-form-inner {
    max-width: 44rem;
    margin-inline: auto;
}

.kh-apply-form-narrow {
    max-width: 26rem;
}

.kh-apply-form-head {
    margin-bottom: 1.5rem;
}

.kh-apply-form-head .fi-simple-header-heading {
    font-size: 1.75rem;
    line-height: 1.15;
}

.kh-apply-form-head .fi-simple-header-subheading {
    margin-top: 0.5rem;
    color: var(--kh-ink-2);
}

.kh-legal-link,
.kh-apply-footer nav a {
    color: var(--kh-ink);
    text-decoration: underline;
    text-decoration-color: var(--kh-line-strong);
    text-underline-offset: 3px;
}

.kh-legal-link:hover,
.kh-apply-footer nav a:hover {
    text-decoration-color: currentColor;
}

.kh-apply-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--kh-line);
    color: var(--kh-ink-2);
    font-size: 0.8125rem;
}

.kh-apply-footer nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.kh-apply-footer nav a {
    color: var(--kh-ink-2);
}

/* Small screens: the story shrinks to a short intro above the form */
@media (max-width: 1023px) {
    .kh-apply-props {
        gap: 0.5rem;
    }

    .kh-apply-props li {
        align-items: center;
    }

    .kh-prop-text {
        display: none;
    }
}

@media (min-width: 640px) {
    .kh-apply-story,
    .kh-apply-form {
        padding-inline: 2rem;
    }
}

@media (min-width: 1024px) {
    .kh-apply {
        grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    }

    /* Sized to the window and never scrolls: spacing and the visual shrink with the height. */
    .kh-apply-story {
        position: sticky;
        top: 0;
        height: 100dvh;
        padding: clamp(1.5rem, 5vh, 3rem) 3rem;
        overflow: hidden;
    }

    .kh-apply-story-inner {
        gap: clamp(0.75rem, 2.4vh, 1.75rem);
    }

    .kh-apply-headline {
        font-size: clamp(1.75rem, 5.2vh, 3rem);
    }

    .kh-apply-lead {
        margin-top: clamp(0.5rem, 1.5vh, 1rem);
        font-size: clamp(0.875rem, 1.9vh, 1rem);
    }

    .kh-apply-eyebrow {
        margin-bottom: clamp(0.5rem, 1.5vh, 1rem);
    }

    /* The visual takes whatever height is left and sheds bubbles as that shrinks. */
    .kh-apply-visual {
        display: flex;
        flex: 1 1 0;
        align-items: center;
        min-height: 0;
        height: auto;
        container-type: size;
    }

    .kh-apply-visual > .kh-layer:first-child {
        position: relative;
    }

    .kh-apply-props {
        gap: clamp(0.5rem, 1.6vh, 1rem);
    }

    .kh-apply-story-inner {
        min-height: 100%;
        justify-content: space-between;
    }

    .kh-apply-steps {
        display: grid;
    }

    .kh-apply-form {
        display: flex;
        align-items: center;
        padding: 4rem 3rem;
    }

    .kh-apply-form-inner {
        width: 100%;
    }

    .kh-apply-form-head .fi-simple-header-heading,
    .kh-apply-form-head .fi-simple-header-subheading {
        text-align: start;
    }
}

/* Short desktop windows: drop detail, tallest first, so the story always fits. */
@media (min-width: 1024px) and (max-height: 980px) {
    .kh-apply-steps {
        display: none;
    }
}

@media (min-width: 1024px) and (max-height: 820px) {
    .kh-prop-text {
        display: none;
    }

}

@container (max-height: 290px) {
    .kh-chat .kh-bubble-out:not(.kh-order) {
        display: none;
    }
}

@container (max-height: 200px) {
    .kh-chip-a,
    .kh-chip-b {
        display: none;
    }
}

@container (max-height: 185px) {
    .kh-chat {
        display: none;
    }
}

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

@keyframes kh-float {
    50% {
        transform: translateY(-6px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .fi-btn {
        transition-duration: 0.01ms;
    }

    .kh-bubble,
    .kh-chip {
        animation: none;
    }

    .kh-layer,
    .kh-apply-glow {
        transform: none;
        transition: none;
    }

    .fi-sidebar {
        transition: none;
    }
}

/* A page whose only header action is its help icon: the icon stays beside the heading, also on phones. */
.fi-header:has(> .fi-header-actions-ctn > .kh-help:only-child) {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

/* An admin signed in to the portal as a merchant (App\Filament\Impersonation): above every page. */
/* At the top of the page content, above the title: scrolls with the page, covers no form, moves no sidebar. */
.kh-impersonation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1.5rem;
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  border-radius: 0.75rem;
  background: #fef3c7;
  color: #451a03;
  font-size: 0.875rem;
}

.kh-impersonation button {
  padding: 0.25rem 0.75rem;
  border: 1px solid currentColor;
  border-radius: 9999px;
  font-weight: 600;
  cursor: pointer;
}

.kh-impersonation button:hover {
  background: #fde68a;
}
