/* =========================================
   botCAL Mini App — Dark Theme
   ========================================= */

:root {
    --bg-primary: #0f1923;
    --bg-secondary: #1a2634;
    --bg-card: #1e2d3d;
    --bg-card-hover: #243447;
    --bg-input: #162029;
    --bg-modal: #1a2634;

    --text-primary: #e8edf2;
    --text-secondary: #8899aa;
    --text-muted: #5a6a7a;
    --text-heading: #ffffff;

    --accent: #4a9eff;
    --accent-hover: #3a8eef;
    --accent-light: rgba(74, 158, 255, 0.15);
    --green: #00d4aa;
    --green-light: rgba(0, 212, 170, 0.15);
    --red: #ff5c5c;
    --red-light: rgba(255, 92, 92, 0.15);
    --orange: #ffaa33;
    --orange-light: rgba(255, 170, 51, 0.15);
    --purple: #a78bfa;
    --purple-light: rgba(167, 139, 250, 0.15);

    --border: #2a3a4a;
    --border-light: #1e2e3e;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    --tab-height: 60px;
    --header-height: 52px;
    --sub-nav-height: 44px;
    --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-safe-top, 0px));
    --safe-left: max(env(safe-area-inset-left, 0px), var(--tg-safe-left, 0px));
    --safe-right: max(env(safe-area-inset-right, 0px), var(--tg-safe-right, 0px));
    --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-bottom, 0px));
    --header-offset: calc(var(--header-height) + var(--safe-top));
    --header-side-width: 64px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    overflow-x: clip;
}

.hidden { display: none !important; }

/* === Loading Screen === */
#loading-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 9999;
    gap: 16px;
}

#loading-screen p {
    color: var(--text-secondary);
    font-size: 14px;
}

.loader {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === Auth Error === */
#auth-error {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 9998;
}

.auth-error-content {
    text-align: center;
    padding: 32px;
}

.auth-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.auth-error-content h2 {
    color: var(--text-heading);
    margin-bottom: 8px;
}

.auth-error-content p {
    color: var(--text-secondary);
}

/* === Header === */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-offset);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    display: grid;
    grid-template-columns: var(--header-side-width) minmax(0, 1fr) var(--header-side-width);
    align-items: center;
    padding: var(--safe-top) calc(16px + var(--safe-right)) 0 calc(16px + var(--safe-left));
    gap: 8px;
    z-index: 100;
}

.header-side {
    min-width: 0;
    display: flex;
    align-items: center;
}

.header-left {
    justify-content: flex-start;
}

.header-center {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-title-wrap {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.header-right {
    justify-content: flex-end;
}

.header-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
}

#page-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-heading);
    text-align: center;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-badge {
    font-size: 11px;
    flex-shrink: 0;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-badge.owner { background: var(--accent-light); color: var(--accent); }
.role-badge.agent { background: var(--green-light); color: var(--green); }
.role-badge.user { background: var(--purple-light); color: var(--purple); }

.role-badge-inline {
    display: none !important;
    font-size: 10px;
    line-height: 1;
    padding: 2px 8px;
    letter-spacing: 0.25px;
}


.page-role-badge-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.page-role-badge {
    font-size: 10px;
    line-height: 1;
    padding: 3px 9px;
    letter-spacing: 0.3px;
}

.agent-profile-card {
    position: relative;
    overflow: hidden;
}

.agent-corner-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 10px;
    line-height: 1;
    padding: 3px 8px;
    letter-spacing: 0.3px;
}

/* === Sub Navigation === */
#sub-nav {
    position: fixed;
    top: var(--header-offset);
    left: 0;
    right: 0;
    height: var(--sub-nav-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    z-index: 99;
    overflow: hidden;
}

.sub-nav-scroll {
    display: flex;
    overflow-x: auto;
    padding: 0 12px;
    gap: 4px;
    height: 100%;
    align-items: center;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sub-nav-scroll::-webkit-scrollbar { display: none; }

.sub-nav-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.sub-nav-btn.active {
    background: var(--accent-light);
    color: var(--accent);
}

/* === Page Content === */
#page-content {
    padding-top: var(--header-offset);
    padding-bottom: calc(var(--tab-height) + 16px + var(--safe-bottom));
    min-height: 100vh;
}

#page-content.with-sub-nav {
    padding-top: calc(var(--header-offset) + var(--sub-nav-height));
}

.page-section {
    padding: 16px;
}

/* === Tab Bar === */
#tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: var(--safe-bottom);
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 0;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.tab-btn.active {
    color: var(--accent);
}

.tab-btn svg {
    transition: transform 0.2s;
}

.tab-btn.active svg {
    transform: scale(1.1);
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border-light);
    transition: background 0.2s;
}

.card:active {
    background: var(--bg-card-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-heading);
}

/* === KPI Grid === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
    border: 1px solid var(--border-light);
}

.kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-heading);
}

.kpi-value.accent { color: var(--accent); }
.kpi-value.green { color: var(--green); }
.kpi-value.orange { color: var(--orange); }

/* === Tables / List Items === */
.list-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 8px;
    border: 1px solid var(--border-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.15s;
}

.list-item:active {
    background: var(--bg-card-hover);
}

.list-item-left {
    flex: 1;
    min-width: 0;
}

.list-item-id {
    font-size: 11px;
    color: var(--text-muted);
    font-family: monospace;
}

.list-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.list-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 12px;
}

/* === Status Badges === */
.status-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.status-new { background: var(--accent-light); color: var(--accent); }
.status-active, .status-work { background: var(--orange-light); color: var(--orange); }
.status-delivery { background: var(--purple-light); color: var(--purple); }
.status-paid, .status-done { background: var(--green-light); color: var(--green); }
.status-cancelled, .status-frozen { background: var(--red-light); color: var(--red); }
.status-waiting { background: rgba(255,255,255,0.08); color: var(--text-secondary); }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:active { background: var(--accent-hover); transform: scale(0.97); }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--red-light);
    color: var(--red);
}

.btn-success {
    background: var(--green-light);
    color: var(--green);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238899aa' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

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

.form-row > * {
    min-width: 0;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Chip select (for method, split, etc) */
.chip-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chip.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* Toggle switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}

.toggle-label {
    font-size: 14px;
    color: var(--text-primary);
}

.toggle {
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
    border: none;
}

.toggle.active {
    background: var(--accent);
}

.toggle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.toggle.active::after {
    transform: translateX(20px);
}

/* === Modal === */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#modal-panel {
    background: var(--bg-modal);
    width: 100%;
    max-width: 480px;
    max-height: min(90vh, calc(100vh - var(--safe-top)));
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

#modal-body {
    padding: 20px 20px calc(20px + var(--safe-bottom));
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
}


#modal-overlay {
    overflow-x: hidden;
}

#modal-body {
    touch-action: pan-y;
}

#modal-body .form-group,
#modal-body .form-row,
#modal-body .form-input,
#modal-body .form-select,
#modal-body .form-textarea,
#modal-body .btn,
#modal-body .card {
    max-width: 100%;
    min-width: 0;
}

#modal-body input[type="date"].form-input,
#modal-body .crm-date-input {
    display: block;
    width: 100%;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
}

/* === Toast === */
#toast-container {
    position: fixed;
    top: calc(var(--header-offset) + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease-out;
    white-space: nowrap;
}

.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Comparison Block === */
.comparison-block {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
    border: 1px solid var(--border-light);
    margin-top: 12px;
}

.comparison-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.comparison-row.best {
    color: var(--green);
    font-weight: 600;
}

.comparison-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.comparison-value {
    font-size: 14px;
    font-weight: 600;
    font-family: monospace;
}

/* === Result Card === */
.result-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border-light);
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 13px;
}

.result-row .label {
    color: var(--text-secondary);
}

.result-row .value {
    color: var(--text-heading);
    font-weight: 600;
    font-family: monospace;
}

.result-divider {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 10px 0;
}

.result-total {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    padding: 12px 0;
}

/* === More Page Grid === */
.more-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.more-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.15s;
}

.more-item:active {
    background: var(--bg-card-hover);
}

.more-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.more-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* === Section Header === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-heading);
}

.section-count {
    font-size: 12px;
    color: var(--text-muted);
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state-text {
    font-size: 14px;
}

/* === Logistic Items === */
.logistic-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 10px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logistic-item-info {
    flex: 1;
}

.logistic-item-remove {
    color: var(--red);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* === Detail View === */
.detail-header {
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid var(--border-light);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.detail-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-heading);
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

/* === Animations === */
.fade-in {
    animation: fadeIn 0.2s ease-out;
}

/* === Search === */
.search-bar {
    position: relative;
    margin-bottom: 12px;
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* === FAB (Floating Action Button) === */
.fab {
    position: fixed;
    right: 16px;
    bottom: calc(var(--tab-height) + 16px);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(74,158,255,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.9);
}

/* === Notes Category Chips === */
.category-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    padding-bottom: 16px;
}

.pagination-btn {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

/* === Inline Spinner === */
.spinner-inline {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

/* === Calculator Action Buttons === */
.calc-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.calc-actions .btn-row {
    display: flex;
    gap: 8px;
}

.calc-actions .btn-row .btn {
    flex: 1;
}

/* Result sub-sections */
.result-sub-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 12px 0 6px;
}

.result-row.highlight {
    background: var(--accent-light);
    margin: 0 -16px;
    padding: 5px 16px;
    border-radius: var(--radius-xs);
}

.result-row.warn {
    background: var(--orange-light);
    margin: 0 -16px;
    padding: 5px 16px;
    border-radius: var(--radius-xs);
}

.result-row .value.green { color: var(--green); }
.result-row .value.orange { color: var(--orange); }
.result-row .value.accent { color: var(--accent); }

/* Client message preview */
.client-message-preview {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 14px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-primary);
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 12px;
}

/* CRM flow step indicator */
.crm-step-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.crm-step {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 11px;
}

.crm-step.active {
    background: var(--accent);
    color: #fff;
}

.crm-step.done {
    background: var(--green);
    color: #fff;
}

.crm-step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
}

.crm-step-line.done {
    background: var(--green);
}

/* CRM client select list */
.crm-client-list {
    max-height: 40vh;
    overflow-y: auto;
    margin: 12px 0;
}

.crm-client-item {
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.crm-client-item:active {
    background: var(--bg-card-hover);
}

.crm-client-item .name {
    font-weight: 500;
    color: var(--text-heading);
    font-size: 14px;
}

.crm-client-item .sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Discount input */
.discount-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0;
}

.discount-input-row input {
    flex: 1;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
}

.discount-input-row .suffix {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* === Dashboard compact feed === */
.mini-card { padding: 12px; }
.mini-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "main side"
        "sub side";
    gap: 2px 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border-light);
}
.mini-row:last-child { border-bottom: none; }
.mini-main { grid-area: main; font-size: 12px; font-weight: 600; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { grid-area: sub; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-side { grid-area: side; font-size: 10px; color: var(--text-secondary); background: var(--bg-light); border: 1px solid var(--border-light); border-radius: 999px; padding: 2px 6px; align-self: center; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-empty { font-size: 12px; color: var(--text-muted); padding: 6px 0; }
.mini-grid2 { display:grid; grid-template-columns:1fr 1fr; gap:6px 10px; margin-top:6px; }
.mini-kv { font-size: 11px; color: var(--text-secondary); display:flex; justify-content:space-between; gap:8px; border-bottom:1px dashed var(--border-light); padding-bottom:3px; }
.mini-kv b { color: var(--text-heading); font-size: 12px; font-weight: 600; }


.mini-status-row {
    display:flex;
    justify-content:space-between;
    align-items:center;
    font-size:12px;
    padding:5px 0;
    border-bottom:1px dashed var(--border-light);
}
.mini-status-row:last-child { border-bottom:none; }
.mini-status-name { color: var(--text-secondary); }
.mini-status-count {
    color: var(--text-heading);
    font-weight: 600;
    min-width: 24px;
    text-align: right;
}

/* Pull-to-refresh */
.ptr-indicator {
    position: fixed;
    top: var(--header-offset, 52px);
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 98;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    padding-top: 10px;
}
.ptr-indicator.ptr-has-subnav {
    top: calc(var(--header-offset, 52px) + var(--sub-nav-height, 44px));
}
.ptr-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid var(--border-light, rgba(255,255,255,0.15));
    border-top-color: var(--accent, #4a9eff);
    border-radius: 50%;
}
.ptr-ready .ptr-spinner {
    border-top-color: var(--success, #34d399);
}
.ptr-loading .ptr-spinner {
    animation: ptr-spin 0.6s linear infinite;
}
@keyframes ptr-spin {
    to { transform: rotate(360deg); }
}
