/*
 * TZ43 static UI prototype
 * ------------------------------------------------------------
 * Технічна примітка:
 * - Файл навмисно не залежить від Bootstrap/Tailwind або build-pipeline.
 * - Стилі організовані за блоками, щоб під час перенесення в Yii2 AssetBundle
 *   можна було зберегти структуру без переписування селекторів.
 * - Кольорова схема побудована навколо синього акценту логотипа 02 (>AL_).
 */

:root {
    --bg: #05070b;
    --bg-elevated: #080b11;
    --surface: #0b0f16;
    --surface-2: #10151f;
    --surface-3: #151b27;
    --border: #1c2432;
    --border-strong: #2a3446;
    --text: #f0f3f8;
    --text-soft: #b8c0ce;
    --text-dim: #768195;
    --accent: #2d55ff;
    --accent-2: #1742dd;
    --accent-soft: rgba(45, 85, 255, .12);
    --success: #56d59a;
    --warning: #f0c45d;
    --danger: #ff646b;
    --info: #68b8ff;
    --sidebar: 238px;
    --sidebar-collapsed: 76px;
    --topbar: 62px;
    --radius: 12px;
    --radius-sm: 9px;
    --shadow: 0 22px 60px rgba(0, 0, 0, .32);
    --transition: 180ms ease;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    color-scheme: dark;
    background: var(--bg);
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text);
    background:
        radial-gradient(circle at 85% -5%, rgba(45, 85, 255, .12), transparent 32rem),
        radial-gradient(circle at 16% 115%, rgba(23, 66, 221, .075), transparent 34rem),
        var(--bg);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

body.is-modal-open,
body.is-mobile-nav-open {
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

button {
    color: inherit;
}

::selection {
    background: rgba(45, 85, 255, .45);
    color: #fff;
}

/* --------------------------------------------------------------------------
 * Базові utilities
 * -------------------------------------------------------------------------- */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

.text-soft {
    color: var(--text-soft);
}

.mono {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.nowrap {
    white-space: nowrap;
}

.stack {
    display: grid;
    gap: 12px;
}

.stack--sm {
    gap: 8px;
}

.inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
 * Login
 * -------------------------------------------------------------------------- */

.auth-page {
    position: relative;
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 28px 18px;
    overflow: hidden;
}

.auth-page::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .22;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(circle at center, #000 0, transparent 72%);
}

.auth-page::after {
    content: "";
    position: absolute;
    width: min(620px, 85vw);
    height: min(620px, 85vw);
    border-radius: 50%;
    border: 1px solid rgba(45, 85, 255, .13);
    box-shadow:
        0 0 0 80px rgba(45, 85, 255, .018),
        0 0 0 160px rgba(45, 85, 255, .012);
    pointer-events: none;
}

.auth-card {
    position: relative;
    z-index: 1;
    width: min(100%, 386px);
    padding: 34px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(155deg, rgba(16, 21, 31, .97), rgba(8, 11, 17, .97));
    box-shadow: var(--shadow);
}

.auth-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 2px;
    border-radius: 18px 0 0 18px;
    background: linear-gradient(180deg, transparent, var(--accent), transparent);
}

.auth-logo {
    display: block;
    width: 168px;
    max-width: 65%;
    height: auto;
    margin: 2px auto 30px;
    filter: drop-shadow(0 10px 28px rgba(45, 85, 255, .16));
}

.auth-eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .18em;
    text-transform: uppercase;
}

.auth-title {
    margin: 0;
    font-size: 24px;
    font-weight: 680;
    letter-spacing: -.035em;
}

.auth-subtitle {
    margin: 8px 0 24px;
    color: var(--text-dim);
    font-size: 13px;
}

.auth-footnote {
    margin: 20px 0 0;
    color: var(--text-dim);
    font-size: 11px;
    text-align: center;
}

/* --------------------------------------------------------------------------
 * Forms
 * -------------------------------------------------------------------------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-grid--1 {
    grid-template-columns: 1fr;
}

.field-group {
    min-width: 0;
}

.field-group--full {
    grid-column: 1 / -1;
}

.field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 7px;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 650;
}

.field-hint {
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 500;
}

.input,
.select,
.textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    background: #080b11;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.input,
.select {
    height: 40px;
    padding: 0 12px;
}

.textarea {
    min-height: 96px;
    padding: 11px 12px;
    resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
    color: #576276;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: rgba(45, 85, 255, .72);
    background: #0a0e15;
    box-shadow: 0 0 0 3px rgba(45, 85, 255, .09);
}

.field-group.has-error .input,
.field-group.has-error .select,
.field-group.has-error .textarea {
    border-color: rgba(255, 100, 107, .72);
    box-shadow: 0 0 0 3px rgba(255, 100, 107, .07);
}

.field-error {
    display: none;
    margin-top: 6px;
    color: var(--danger);
    font-size: 11px;
}

.field-group.has-error .field-error {
    display: block;
}

.checkbox-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-soft);
    font-size: 12px;
    cursor: pointer;
}

.checkbox-line input {
    accent-color: var(--accent);
}

/* --------------------------------------------------------------------------
 * Buttons
 * -------------------------------------------------------------------------- */

.btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-soft);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: transform var(--transition), border-color var(--transition), background var(--transition), color var(--transition);
}

.btn:hover {
    border-color: var(--border-strong);
    background: var(--surface-3);
    color: var(--text);
}

.btn:active {
    transform: translateY(1px);
}

.btn--primary {
    border-color: var(--accent);
    background: linear-gradient(180deg, #315aff, #2148e6);
    color: #fff;
    box-shadow: 0 9px 25px rgba(45, 85, 255, .17);
}

.btn--primary:hover {
    border-color: #5475ff;
    background: linear-gradient(180deg, #3c63ff, #2850ea);
    color: #fff;
}

.btn--danger {
    border-color: rgba(255, 100, 107, .26);
    background: rgba(255, 100, 107, .07);
    color: #ff858b;
}

.btn--danger:hover {
    border-color: rgba(255, 100, 107, .48);
    background: rgba(255, 100, 107, .11);
    color: #ff9ba0;
}

.btn--ghost {
    background: transparent;
}

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

.btn--icon {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
}

.btn[disabled] {
    opacity: .48;
    cursor: not-allowed;
    transform: none;
}

/* --------------------------------------------------------------------------
 * Application shell
 * -------------------------------------------------------------------------- */

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    z-index: 600;
    inset: 0 auto 0 0;
    width: var(--sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background:
        linear-gradient(180deg, rgba(12, 16, 24, .98), rgba(7, 10, 15, .98));
    transition: width var(--transition), transform var(--transition);
}

.sidebar__brand {
    min-height: var(--topbar);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.sidebar__logo {
    width: 92px;
    height: auto;
    flex: 0 0 auto;
    filter: drop-shadow(0 6px 18px rgba(45, 85, 255, .12));
    transition: width var(--transition);
}

.sidebar__brand-meta {
    min-width: 0;
    display: grid;
    gap: 1px;
    opacity: 1;
    transition: opacity var(--transition), width var(--transition);
}

.sidebar__brand-meta strong {
    overflow: hidden;
    font-size: 11px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar__brand-meta span {
    color: var(--text-dim);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 8px;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.sidebar__nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 10px;
}

.nav-label {
    padding: 8px 10px 6px;
    color: #5d687b;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item,
.nav-subitem {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 11px;
    border: 0;
    color: #8e99aa;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.nav-item {
    min-height: 42px;
    padding: 0 11px;
    border-radius: 10px;
}

.nav-item + .nav-item,
.nav-group + .nav-item,
.nav-item + .nav-group {
    margin-top: 3px;
}

.nav-item:hover,
.nav-subitem:hover {
    background: rgba(255,255,255,.035);
    color: #dce3ed;
}

.nav-item.is-active {
    background: var(--accent-soft);
    color: #dfe6ff;
}

.nav-item.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 2px;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 14px rgba(45, 85, 255, .7);
}

.nav-item__text,
.nav-subitem__text {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition), width var(--transition);
}

.nav-item__chevron {
    width: 14px;
    height: 14px;
    margin-left: auto;
    opacity: .6;
    transition: transform var(--transition);
}

.nav-group.is-open .nav-item__chevron {
    transform: rotate(90deg);
}

.nav-submenu {
    display: none;
    margin: 4px 0 6px 37px;
    padding-left: 9px;
    border-left: 1px solid var(--border);
}

.nav-group.is-open .nav-submenu {
    display: grid;
    gap: 2px;
}

.nav-subitem {
    min-height: 32px;
    padding: 0 8px;
    border-radius: 7px;
    font-size: 11px;
}

.nav-subitem.is-active {
    color: #dfe6ff;
    background: rgba(45, 85, 255, .08);
}

.sidebar__footer {
    padding: 10px;
    border-top: 1px solid var(--border);
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 6px 8px;
    overflow: hidden;
}

.avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border: 1px solid rgba(45, 85, 255, .32);
    border-radius: 10px;
    background: rgba(45, 85, 255, .08);
    color: #dfe6ff;
    font-size: 11px;
    font-weight: 800;
}

.sidebar__user-meta {
    min-width: 0;
    display: grid;
    line-height: 1.25;
    transition: opacity var(--transition), width var(--transition);
}

.sidebar__user-meta strong {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar__user-meta span {
    overflow: hidden;
    color: var(--text-dim);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar {
    position: fixed;
    z-index: 500;
    top: 0;
    right: 0;
    left: var(--sidebar);
    height: var(--topbar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 22px;
    border-bottom: 1px solid var(--border);
    background: rgba(5, 7, 11, .88);
    backdrop-filter: blur(18px);
    transition: left var(--transition);
}

.topbar__left,
.topbar__right {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar__title {
    min-width: 0;
    display: grid;
}

.topbar__title strong {
    overflow: hidden;
    font-size: 13px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar__title span {
    overflow: hidden;
    color: var(--text-dim);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-menu-btn {
    display: none;
}

.app-main {
    min-height: 100vh;
    margin-left: var(--sidebar);
    padding-top: var(--topbar);
    transition: margin-left var(--transition);
}

.app-content {
    width: min(calc(100% - 42px), 1480px);
    margin: 0 auto;
    padding: 28px 0 44px;
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

body.sidebar-collapsed .topbar {
    left: var(--sidebar-collapsed);
}

body.sidebar-collapsed .app-main {
    margin-left: var(--sidebar-collapsed);
}

body.sidebar-collapsed .sidebar__brand {
    justify-content: center;
    padding: 0 9px;
}

body.sidebar-collapsed .sidebar__logo {
    width: 52px;
}

body.sidebar-collapsed .sidebar__brand-meta,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-item__text,
body.sidebar-collapsed .nav-item__chevron,
body.sidebar-collapsed .sidebar__user-meta {
    width: 0;
    opacity: 0;
    pointer-events: none;
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 0;
}

body.sidebar-collapsed .nav-submenu {
    display: none !important;
}

body.sidebar-collapsed .sidebar__user {
    justify-content: center;
    padding-inline: 0;
}

/* Tooltip для collapsed-sidebar: текст береться з data-tooltip. */
body.sidebar-collapsed .nav-item[data-tooltip]::after {
    content: attr(data-tooltip);
    position: fixed;
    z-index: 1000;
    left: 70px;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #0d121b;
    color: var(--text-soft);
    font-size: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.3);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-4px);
    transition: opacity var(--transition), transform var(--transition);
}

body.sidebar-collapsed .nav-item[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(0);
}

.mobile-backdrop {
    position: fixed;
    z-index: 580;
    inset: 0;
    display: none;
    background: rgba(0, 0, 0, .62);
    backdrop-filter: blur(3px);
}

/* --------------------------------------------------------------------------
 * Page header / cards / metrics
 * -------------------------------------------------------------------------- */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 20px;
}

.page-head__main {
    min-width: 0;
}

.page-kicker {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    color: var(--accent);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.page-kicker::before {
    content: "";
    width: 15px;
    height: 1px;
    background: var(--accent);
}

.page-title {
    margin: 0;
    font-size: clamp(24px, 2.2vw, 32px);
    font-weight: 680;
    letter-spacing: -.04em;
}

.page-subtitle {
    max-width: 700px;
    margin: 6px 0 0;
    color: var(--text-dim);
    font-size: 12px;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.card {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(11, 15, 22, .91);
    box-shadow: 0 12px 34px rgba(0,0,0,.11);
}

.card__head {
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
}

.card__head h2,
.card__head h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
}

.card__body {
    padding: 16px;
}

.card--accent {
    position: relative;
    overflow: hidden;
}

.card--accent::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.grid {
    display: grid;
    gap: 14px;
}

.grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.metric {
    min-width: 0;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(11,15,22,.74);
}

.metric__label {
    color: var(--text-dim);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.metric__value {
    margin-top: 5px;
    font-size: 20px;
    font-weight: 690;
    letter-spacing: -.035em;
}

.metric__meta {
    margin-top: 2px;
    color: var(--text-dim);
    font-size: 9px;
}

/* --------------------------------------------------------------------------
 * Toolbar
 * -------------------------------------------------------------------------- */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(11,15,22,.72);
}

.toolbar__group {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.toolbar .input,
.toolbar .select {
    height: 36px;
    font-size: 11px;
}

.toolbar .search-input {
    min-width: 240px;
}

.toolbar .select {
    min-width: 130px;
}


/*
 * Clients filters
 * --------------------------------------------------------------------------
 * Desktop: усі основні критерії тримаємо в одному горизонтальному рядку.
 * На вузьких viewport елементи можуть переноситися, щоб не створювати
 * горизонтальний overflow у робочій області адміністративної панелі.
 */
.clients-filter-toolbar {
    flex-wrap: nowrap;
}

.clients-filter-row {
    flex: 1 1 auto;
    flex-wrap: nowrap;
}

.toolbar .clients-filter-field {
    width: 112px;
    min-width: 112px;
    flex: 0 0 112px;
}

.toolbar .clients-filter-value {
    width: clamp(210px, 24vw, 310px);
    min-width: 210px;
    flex: 0 1 310px;
}

.logic-switch {
    display: inline-flex;
    align-items: stretch;
    flex: 0 0 auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #080b11;
}

.logic-switch__option {
    position: relative;
    display: inline-flex;
    min-width: 46px;
    height: 34px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 750;
    white-space: nowrap;
}

.logic-switch__option + .logic-switch__option {
    border-left: 1px solid var(--border);
}

.logic-switch__option:last-child {
    min-width: 82px;
}

.logic-switch__option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.logic-switch__option span {
    width: 100%;
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.logic-switch__option:hover span {
    color: var(--text-soft);
    background: rgba(255,255,255,.025);
}

.logic-switch__option input:checked + span {
    background: rgba(45, 85, 255, .11);
    color: #dfe6ff;
    box-shadow: inset 0 0 0 1px rgba(45, 85, 255, .18);
}

.logic-switch__option input:focus-visible + span {
    box-shadow: inset 0 0 0 2px rgba(84, 117, 255, .72);
}

.status-filter {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
}

.status-filter__label {
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.toolbar .status-filter__select {
    width: 122px;
    min-width: 122px;
}

.status-filter__select:disabled {
    opacity: .42;
    cursor: not-allowed;
}

.toolbar__group--actions {
    flex: 0 0 auto;
}


/*
 * Orders filters + searchable client select
 * --------------------------------------------------------------------------
 * У production значенням фільтра лишається client_id. Пошук усередині
 * випадаючого списку — тільки UX-шар для швидкого вибору клієнта і не змінює
 * контракт GET /orders?status=...&client_id=...
 */
.orders-filter-toolbar {
    flex-wrap: nowrap;
}

.orders-filter-row {
    width: 100%;
    flex: 1 1 auto;
    flex-wrap: nowrap;
}

.toolbar .orders-status-select {
    width: 148px;
    min-width: 128px;
    flex: 0 1 148px;
}

.toolbar .orders-client-select {
    width: 240px;
    min-width: 180px;
    flex: 1 1 240px;
    max-width: 320px;
}

.orders-filter-clear {
    flex: 0 0 auto;
}

/*
 * Native <select> не видаляємо: JS лише прогресивно додає searchable UI.
 * Тому контракт форми/значення select зберігається, а без JavaScript сторінка
 * все одно має звичайний робочий select.
 */
.select.is-search-enhanced {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.search-select {
    position: relative;
    min-width: 180px;
    flex: 1 1 240px;
    max-width: 320px;
}

.search-select__control {
    width: 100%;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #080b11;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    text-align: left;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.search-select__control:hover,
.search-select.is-open .search-select__control {
    border-color: rgba(84, 117, 255, .48);
    background: #0a0e16;
}

.search-select.is-open .search-select__control {
    box-shadow: 0 0 0 3px rgba(45, 85, 255, .08);
}

.search-select__value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-select__chevron {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-size: 10px;
    transition: transform var(--transition);
}

.search-select.is-open .search-select__chevron {
    transform: rotate(180deg);
}

.search-select__menu {
    position: absolute;
    z-index: 120;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    display: none;
    padding: 7px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #090d14;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .42);
}

.search-select.is-open .search-select__menu {
    display: block;
}

.search-select__search {
    width: 100%;
    height: 34px;
    margin-bottom: 6px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: 0;
    background: #06090e;
    color: var(--text);
    font: inherit;
    font-size: 10px;
}

.search-select__search:focus {
    border-color: rgba(84, 117, 255, .62);
    box-shadow: 0 0 0 3px rgba(45, 85, 255, .08);
}

.search-select__options {
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.search-select__option {
    width: 100%;
    min-height: 32px;
    display: flex;
    align-items: center;
    padding: 6px 9px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    font: inherit;
    font-size: 10px;
    text-align: left;
}

.search-select__option:hover,
.search-select__option.is-selected {
    background: rgba(45, 85, 255, .11);
    color: #e7ebff;
}

.search-select__empty {
    padding: 10px 9px;
    color: var(--text-dim);
    font-size: 10px;
}

.field-group .search-select {
    width: 100%;
    max-width: none;
}

/* --------------------------------------------------------------------------
 * Tables
 * -------------------------------------------------------------------------- */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(9, 13, 19, .9);
}

.data-table {
    width: 100%;
    min-width: 780px;
    border-collapse: collapse;
    font-size: 11px;
}

.data-table th,
.data-table td {
    height: 45px;
    padding: 8px 12px;
    border-bottom: 1px solid #171e2a;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: #6f7a8c;
    background: #0c1119;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}


.sortable-th {
    padding: 0 !important;
}

.table-sort-button {
    width: 100%;
    height: 45px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
}

.table-sort-button:hover,
.table-sort-button:focus-visible {
    color: #cfd8e6;
    outline: none;
}

.sort-indicator {
    color: var(--accent-soft);
    font-size: 11px;
    line-height: 1;
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: rgba(255,255,255,.018);
}

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

.cell-main {
    color: #dce2eb;
    font-weight: 600;
}

.cell-sub {
    display: block;
    margin-top: 2px;
    color: #687387;
    font-size: 9px;
}

.table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
}

.table-link {
    border: 0;
    background: transparent;
    color: #8c9bb2;
    cursor: pointer;
    font-size: 10px;
    font-weight: 650;
    text-decoration: none;
}

.table-link:hover {
    color: #dfe6ff;
}

.table-link--danger {
    color: #d77b80;
}

.table-link--danger:hover {
    color: #ff9398;
}

/* --------------------------------------------------------------------------
 * Status badges
 * -------------------------------------------------------------------------- */

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-soft);
    font-size: 9px;
    font-weight: 750;
    white-space: nowrap;
}

.status::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.status--active,
.status--paid {
    border-color: rgba(86, 213, 154, .2);
    background: rgba(86, 213, 154, .055);
    color: #69dda8;
}

.status--pending {
    border-color: rgba(240, 196, 93, .2);
    background: rgba(240, 196, 93, .055);
    color: #efc966;
}

.status--blocked,
.status--canceled {
    border-color: rgba(255, 100, 107, .2);
    background: rgba(255, 100, 107, .055);
    color: #ff777e;
}

.status--processing {
    border-color: rgba(104, 184, 255, .2);
    background: rgba(104, 184, 255, .055);
    color: #7bc1ff;
}

/* --------------------------------------------------------------------------
 * Pagination
 * -------------------------------------------------------------------------- */

.pagination-bar {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 2px 0;
    color: var(--text-dim);
    font-size: 10px;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.page-btn {
    min-width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #0b1018;
    color: #8490a2;
    cursor: pointer;
    font-size: 10px;
}

.page-btn:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.page-btn.is-active {
    border-color: rgba(45, 85, 255, .5);
    background: rgba(45, 85, 255, .1);
    color: #dfe6ff;
}

.page-btn[disabled] {
    opacity: .35;
    cursor: default;
}

.page-gap {
    min-width: 22px;
    text-align: center;
}

/* --------------------------------------------------------------------------
 * Empty / feedback blocks
 * -------------------------------------------------------------------------- */

.empty-state {
    display: grid;
    place-items: center;
    min-height: 210px;
    padding: 30px;
    text-align: center;
}

.empty-state__icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-dim);
    background: #0c1119;
}

.empty-state h3 {
    margin: 0;
    font-size: 13px;
}

.empty-state p {
    max-width: 420px;
    margin: 6px 0 0;
    color: var(--text-dim);
    font-size: 10px;
}

.notice {
    padding: 11px 12px;
    border: 1px solid rgba(104, 184, 255, .18);
    border-radius: 9px;
    background: rgba(104, 184, 255, .05);
    color: #a4cceb;
    font-size: 10px;
}

.notice--warning {
    border-color: rgba(240, 196, 93, .2);
    background: rgba(240, 196, 93, .045);
    color: #d9bd78;
}

.notice--danger {
    border-color: rgba(255, 100, 107, .2);
    background: rgba(255, 100, 107, .045);
    color: #e6969a;
}

/* --------------------------------------------------------------------------
 * Profile / entity view
 * -------------------------------------------------------------------------- */

.entity-layout {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    gap: 14px;
}

.entity-card {
    padding: 18px;
}

.entity-avatar {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    margin-bottom: 14px;
    border: 1px solid rgba(45, 85, 255, .32);
    border-radius: 15px;
    background: linear-gradient(145deg, rgba(45,85,255,.16), rgba(45,85,255,.04));
    color: #e2e8ff;
    font-size: 16px;
    font-weight: 800;
}

.entity-name {
    margin: 0;
    font-size: 18px;
    letter-spacing: -.025em;
}

.entity-email {
    margin: 3px 0 14px;
    color: var(--text-dim);
    font-size: 10px;
}

.entity-kv {
    display: grid;
    gap: 0;
    margin-top: 14px;
    border-top: 1px solid var(--border);
}

.entity-kv__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 39px;
    border-bottom: 1px solid var(--border);
}

.entity-kv__row span:first-child {
    color: var(--text-dim);
    font-size: 10px;
}

.entity-kv__row strong {
    font-size: 11px;
    font-weight: 650;
    text-align: right;
}

.balance-value {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 16px !important;
    color: #dfe6ff;
}

.entity-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-top: 14px;
}

/* --------------------------------------------------------------------------
 * Order create result
 * -------------------------------------------------------------------------- */

.result-panel {
    display: none;
    margin-top: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #090d14;
}

.result-panel.is-visible {
    display: block;
}

.result-panel__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 8px;
}

.result-item {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0c1119;
}

.result-item span {
    display: block;
    margin-bottom: 4px;
    color: var(--text-dim);
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.result-item strong {
    font-size: 11px;
}

/* --------------------------------------------------------------------------
 * Modal
 * -------------------------------------------------------------------------- */

.modal-layer {
    position: fixed;
    z-index: 1300;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(1, 3, 7, .76);
    backdrop-filter: blur(6px);
}

.modal-layer.is-open {
    display: flex;
}

.modal {
    width: min(100%, 520px);
    max-height: min(760px, calc(100vh - 38px));
    overflow: auto;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: #0b0f16;
    box-shadow: 0 35px 100px rgba(0, 0, 0, .55);
    animation: modal-in 150ms ease-out;
}

.modal--sm {
    width: min(100%, 420px);
}

.modal__head {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
}

.modal__title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.modal__subtitle {
    margin: 2px 0 0;
    color: var(--text-dim);
    font-size: 9px;
}

.modal__body {
    padding: 16px;
}

.modal__foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

/*
 * Закриття модалки використовується і для icon-button у header, і для кнопки
 * «Скасувати» у footer. Розмір 34x34 застосовуємо лише до icon-button, інакше
 * footer-action стискається до квадрата та обрізає текст.
 */
.modal-close {
    cursor: pointer;
}

.modal-close--icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-dim);
}

.modal-close--icon:hover {
    border-color: var(--border);
    color: var(--text);
}

.modal__foot .btn {
    width: auto;
    min-width: 96px;
    height: auto;
    min-height: 38px;
}

.modal-balance-notice {
    margin-top: 12px;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --------------------------------------------------------------------------
 * Toasts
 * -------------------------------------------------------------------------- */

.toast-host {
    position: fixed;
    z-index: 1600;
    right: 18px;
    bottom: 18px;
    width: min(350px, calc(100vw - 36px));
    display: grid;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: grid;
    grid-template-columns: 5px minmax(0,1fr);
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #0f141d;
    box-shadow: 0 18px 50px rgba(0,0,0,.4);
    animation: toast-in 180ms ease-out;
}

.toast__line {
    border-radius: 999px;
    background: var(--info);
}

.toast--success .toast__line { background: var(--success); }
.toast--danger .toast__line { background: var(--danger); }
.toast--warning .toast__line { background: var(--warning); }

.toast strong {
    display: block;
    margin-bottom: 2px;
    font-size: 10px;
}

.toast p {
    margin: 0;
    color: var(--text-dim);
    font-size: 9px;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --------------------------------------------------------------------------
 * Responsive
 * -------------------------------------------------------------------------- */

@media (max-width: 1120px) {
    .clients-filter-toolbar,
    .clients-filter-row {
        flex-wrap: wrap;
    }

    .clients-filter-row {
        row-gap: 8px;
    }

    .metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .entity-layout {
        grid-template-columns: 270px minmax(0, 1fr);
    }

    .result-panel__grid {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }
}

@media (max-width: 860px) {
    .orders-filter-toolbar {
        align-items: center;
        flex-direction: row;
    }

    .orders-filter-row {
        width: 100%;
        flex-wrap: nowrap;
    }

    .sidebar {
        width: min(270px, calc(100vw - 58px));
        transform: translateX(-101%);
        box-shadow: 24px 0 60px rgba(0,0,0,.42);
    }

    body.sidebar-collapsed .sidebar {
        width: min(270px, calc(100vw - 58px));
    }

    body.is-mobile-nav-open .sidebar {
        transform: translateX(0);
    }

    body.is-mobile-nav-open .mobile-backdrop {
        display: block;
    }

    .topbar,
    body.sidebar-collapsed .topbar {
        left: 0;
        padding-inline: 14px;
    }

    .app-main,
    body.sidebar-collapsed .app-main {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: inline-flex;
    }

    .desktop-collapse-btn {
        display: none;
    }

    /* На mobile sidebar завжди показує текст, незалежно від desktop localStorage. */
    body.sidebar-collapsed .sidebar__brand {
        justify-content: flex-start;
        padding: 0 16px;
    }

    body.sidebar-collapsed .sidebar__logo {
        width: 92px;
    }

    body.sidebar-collapsed .sidebar__brand-meta,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .nav-item__text,
    body.sidebar-collapsed .nav-item__chevron,
    body.sidebar-collapsed .sidebar__user-meta {
        width: auto;
        opacity: 1;
        pointer-events: auto;
    }

    body.sidebar-collapsed .nav-item {
        justify-content: flex-start;
        padding: 0 11px;
    }

    body.sidebar-collapsed .nav-submenu {
        display: none;
    }

    body.sidebar-collapsed .nav-group.is-open .nav-submenu {
        display: grid;
    }

    body.sidebar-collapsed .sidebar__user {
        justify-content: flex-start;
        padding: 6px 8px;
    }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-actions {
        justify-content: flex-start;
    }

    .toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .toolbar__group {
        width: 100%;
    }

    .toolbar .search-input {
        min-width: 0;
        flex: 1 1 230px;
    }

    .clients-filter-row {
        align-items: center;
    }

    .toolbar .clients-filter-field {
        flex: 0 1 120px;
        min-width: 104px;
    }

    .logic-switch,
    .status-filter {
        flex: 0 0 auto;
    }

    .entity-layout,
    .grid--2,
    .grid--3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .orders-filter-row {
        flex-wrap: wrap;
    }

    .toolbar .orders-status-select,
    .orders-filter-row .search-select {
        max-width: none;
        flex: 1 1 180px;
    }

    :root {
        --topbar: 58px;
    }

    .app-content {
        width: min(calc(100% - 24px), 1480px);
        padding-top: 20px;
    }

    .topbar__right .topbar-context {
        display: none;
    }

    .auth-card {
        padding: 28px 22px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .field-group--full {
        grid-column: auto;
    }

    .metrics {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .metric {
        padding: 11px;
    }

    .metric__value {
        font-size: 17px;
    }

    .toolbar__group > .select {
        flex: 1 1 140px;
        min-width: 0;
    }

    .clients-filter-row {
        align-items: stretch;
    }

    .toolbar .clients-filter-field,
    .toolbar .clients-filter-value,
    .status-filter,
    .logic-switch {
        width: 100%;
        flex: 1 1 100%;
    }

    .status-filter {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
    }

    .toolbar .status-filter__select {
        width: 100%;
        min-width: 0;
    }

    .logic-switch__option {
        flex: 1 1 0;
    }

    .pagination-bar {
        align-items: flex-start;
        flex-direction: column;
    }

    .result-panel__grid {
        grid-template-columns: 1fr;
    }

    .entity-actions {
        grid-template-columns: 1fr;
    }

    .modal-layer {
        padding: 10px;
    }

    .modal {
        max-height: calc(100vh - 20px);
    }

    .modal__foot {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .modal__foot .btn {
        width: 100%;
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* Початковий content прихований до того, як jQuery перенесе його в application shell. */
.page-source {
    display: none;
}

.app-content > .page-source {
    display: block;
}

/* --------------------------------------------------------------------------
 * Final static-prototype refinements
 * -------------------------------------------------------------------------- */

/* Логотип 02 використовується як прозорий crop зі спрайта користувача. */
.sidebar__logo,
.auth-logo {
    object-fit: contain;
}

.profile-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 22px;
    max-width: 760px;
}

.profile-card .entity-avatar {
    margin: 0;
}

.profile-card__body {
    min-width: 0;
}

.profile-card__notice {
    max-width: 620px;
    margin-top: 18px;
}

@media (max-width: 640px) {
    .profile-card {
        grid-template-columns: 1fr;
        align-items: start;
    }
}

/* --------------------------------------------------------------------------
 * Yii2 integration fixes
 * --------------------------------------------------------------------------
 * Ці правила не змінюють затверджений дизайн. Вони лише нормалізують
 * server-rendered POST logout forms, яких не було у статичному prototype.
 */

.nav-form,
.topbar-logout-form {
    margin: 0;
}

.nav-item--button {
    background: transparent;
    text-align: left;
}

body.sidebar-collapsed .nav-item--button {
    text-align: center;
}
