/* Apple iOS Human Interface Guidelines (HIG) Design System for Mini App */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* iOS System Colors - Light Mode */
    --ios-bg-grouped: #F2F2F7;
    --ios-surface: #FFFFFF;
    --ios-label: #000000;
    --ios-secondary-label: rgba(60, 60, 67, 0.60);
    --ios-tertiary-label: rgba(60, 60, 67, 0.30);
    --ios-separator: rgba(60, 60, 67, 0.18);
    --ios-accent: #007AFF;
    --ios-accent-active: #0062CC;
    --ios-destructive: #FF3B30;
    --ios-success: #34C759;
    --ios-tabbar-bg: rgba(249, 249, 249, 0.92);
    --ios-search-bg: rgba(118, 118, 128, 0.12);
    --ios-badge-bg: rgba(120, 120, 128, 0.14);
    --ios-card-highlight: rgba(0, 0, 0, 0.04);

    /* Dynamic Mapping with Telegram WebApp Fallbacks */
    --bg: var(--tg-theme-secondary-bg-color, var(--ios-bg-grouped));
    --surface: var(--tg-theme-bg-color, var(--ios-surface));
    --text: var(--tg-theme-text-color, var(--ios-label));
    --secondary-text: var(--tg-theme-hint-color, var(--ios-secondary-label));
    --separator: var(--ios-separator);
    --accent: var(--tg-theme-button-color, var(--ios-accent));
    --accent-text: var(--tg-theme-button-text-color, #FFFFFF);
    --destructive: var(--ios-destructive);
    --success: var(--ios-success);
    --tabbar-bg: var(--ios-tabbar-bg);
    --search-bg: var(--ios-search-bg);
    --card-highlight: var(--ios-card-highlight);

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, sans-serif;
}

/* Dark Theme Overrides */
[data-theme="dark"] {
    --bg: #000000;
    --surface: #1C1C1E;
    --text: #FFFFFF;
    --secondary-text: rgba(235, 235, 245, 0.60);
    --separator: rgba(84, 84, 88, 0.50);
    --accent: #0A84FF;
    --destructive: #FF453A;
    --success: #30D158;
    --tabbar-bg: rgba(29, 29, 31, 0.92);
    --search-bg: rgba(118, 118, 128, 0.24);
    --badge-bg: rgba(120, 120, 128, 0.30);
    --card-highlight: rgba(255, 255, 255, 0.06);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #000000;
        --surface: #1C1C1E;
        --text: #FFFFFF;
        --secondary-text: rgba(235, 235, 245, 0.60);
        --separator: rgba(84, 84, 88, 0.50);
        --accent: #0A84FF;
        --destructive: #FF453A;
        --success: #30D158;
        --tabbar-bg: rgba(29, 29, 31, 0.92);
        --search-bg: rgba(118, 118, 128, 0.24);
        --badge-bg: rgba(120, 120, 128, 0.30);
        --card-highlight: rgba(255, 255, 255, 0.06);
    }
}

[data-theme="light"] {
    --bg: #F2F2F7;
    --surface: #FFFFFF;
    --text: #000000;
    --secondary-text: rgba(60, 60, 67, 0.60);
    --separator: rgba(60, 60, 67, 0.18);
    --accent: #007AFF;
    --destructive: #FF3B30;
    --success: #34C759;
    --tabbar-bg: rgba(249, 249, 249, 0.92);
    --search-bg: rgba(118, 118, 128, 0.12);
    --badge-bg: rgba(120, 120, 128, 0.14);
    --card-highlight: rgba(0, 0, 0, 0.04);
}

html, body {
    width: 100%;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-padding-bottom: calc(52px + 16px + env(safe-area-inset-bottom, 0px));
}

body {
    min-height: 100vh;
    padding-bottom: 0;
    overflow-x: hidden;
}

/* Utilities */
.hidden {
    display: none !important;
}

.tabular {
    font-variant-numeric: tabular-nums;
}

.w-full {
    width: 100%;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--ios-badge-bg);
    color: var(--text);
    line-height: 1;
}

.badge-pro {
    background: rgba(0, 122, 255, 0.14);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

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

/* Screen Title Header (iOS Large Title) */
.screen-header {
    padding: 20px 16px 8px 16px;
}

.screen-large-title {
    font-size: 28px;
    line-height: 34px;
    font-weight: 600;
    letter-spacing: -0.4px;
    color: var(--text);
}

.screen-subtitle {
    font-size: 13px;
    line-height: 18px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--secondary-text);
    margin-top: 4px;
}

.screen-header.header-with-action {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.header-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--separator);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
    transition: background 0.15s ease, transform 0.1s ease;
}

.header-action-btn:active {
    transform: scale(0.92);
    background: var(--card-highlight);
}

.header-action-btn .icon {
    width: 20px;
    height: 20px;
}

/* Inset Groups */
.inset-group {
    margin: 8px 16px 16px 16px;
    background: var(--surface);
    border-radius: 14px;
    overflow: hidden;
}

.inset-group-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: -0.08px;
    color: var(--secondary-text);
    margin: 16px 16px 6px 16px;
}

.inset-group-footer {
    font-size: 13px;
    line-height: 18px;
    color: var(--secondary-text);
    margin: 4px 16px 16px 16px;
}

.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 16px;
}

.btn-text-action {
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
}

#calendarToggleIcon {
    transition: transform 0.25s ease;
}

.btn-text-action.expanded #calendarToggleIcon {
    transform: rotate(180deg);
}

.btn-inline-icon {
    width: 14px;
    height: 14px;
}

/* Inset Rows */
.inset-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 12px 16px;
    position: relative;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    transition: background-color 0.15s ease;
}

.inset-row:not(:last-child)::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 0;
    height: 0.5px;
    background: var(--separator);
}

.inset-row:active {
    background: var(--card-highlight);
}

.inset-row-static {
    cursor: default;
}
.inset-row-static:active {
    background: var(--surface);
}

.inset-row-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.inset-row-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
}

.row-title {
    font-size: 17px;
    font-weight: 600;
    line-height: 22px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-subtitle {
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    letter-spacing: 0.02em;
    color: var(--secondary-text);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#rowDailySummary .row-subtitle {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.row-value {
    font-size: 16px;
    color: var(--secondary-text);
}

/* Status Dots */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.status-connected {
    background: var(--success);
}

.status-disconnected {
    background: var(--secondary-text);
}

/* Prompt Box (Dismissible Banner) */
.prompt-box {
    margin: 8px 16px 12px 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--separator);
}

.prompt-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.prompt-text {
    font-size: 13px;
    line-height: 18px;
    color: var(--text);
    flex: 1;
}

.prompt-dismiss-btn {
    width: 28px;
    height: 28px;
    border-radius: 14px;
    border: none;
    background: transparent;
    color: var(--secondary-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-sm-accent {
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Next Client Card */
.next-client-card {
    margin: 8px 16px 16px 16px;
    padding: 16px;
    border-radius: 14px;
    background: var(--surface);
    border: 1.5px solid var(--accent);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.next-client-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.next-client-tag {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 0.5px;
}

.next-client-time {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.next-client-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
}

.next-client-service {
    font-size: 14px;
    color: var(--secondary-text);
}

.next-client-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

/* Today Visit Rows */
.visit-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 12px 16px;
    position: relative;
    cursor: pointer;
    background: var(--surface);
    transition: background-color 0.15s ease;
}

.visit-row:not(:last-child)::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 84px;
    right: 0;
    height: 0.5px;
    background: var(--separator);
}

.visit-row:active {
    background: var(--card-highlight);
}

.visit-time-col {
    width: 56px;
    min-width: 56px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.visit-time {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.visit-time-empty {
    font-size: 15px;
    font-weight: 500;
    color: var(--hint);
}

.visit-info-col {
    flex: 1;
    min-width: 0;
}

.visit-name {
    font-size: 17px;
    font-weight: 600;
    line-height: 22px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.visit-service {
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    letter-spacing: 0.02em;
    color: var(--secondary-text);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.visit-chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--secondary-text);
}

.empty-list-row {
    padding: 24px 16px;
    text-align: center;
    color: var(--secondary-text);
    font-size: 15px;
}

.empty-day-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    text-align: center;
    gap: 12px;
}

.empty-day-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--secondary-text);
}

/* 7-Day Week Strip */
.week-strip-wrap {
    padding: 0 16px 8px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.week-nav-btn {
    width: 30px;
    height: 56px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--separator);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-text);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.week-nav-btn:active {
    background: var(--card-highlight);
    transform: scale(0.95);
}

.week-nav-btn .icon {
    width: 14px;
    height: 14px;
}

.week-strip {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.week-day-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 2px;
    border-radius: 12px;
    border: none;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    min-height: 56px;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.week-day-btn:active {
    transform: scale(0.95);
}

.week-day-btn.selected {
    background: var(--accent);
    color: var(--accent-text);
}

.week-day-name {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.7;
}

.week-day-num {
    font-size: 16px;
    font-weight: 700;
    margin-top: 2px;
}

.week-day-dot {
    width: 4px;
    height: 4px;
    border-radius: 2px;
    background: var(--accent);
    margin-top: 4px;
}

.week-day-btn.selected .week-day-dot {
    background: #FFFFFF;
}

.week-day-btn:not(.has-visits) .week-day-dot {
    visibility: hidden;
}

/* Full Month Calendar View */
.month-calendar-wrap {
    margin: 8px 16px 16px 16px;
    padding: 14px;
    background: var(--surface);
    border-radius: 14px;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.month-calendar-wrap.collapsed {
    display: none;
}

.month-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    margin-bottom: 8px;
}

.month-title-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 48px;
}

.month-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 22px;
    color: var(--text);
    white-space: nowrap;
}

.month-visits-badge {
    font-size: 12px;
    font-weight: 500;
    color: var(--secondary-text);
    line-height: 16px;
    white-space: nowrap;
}

.month-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 16px;
    background: var(--search-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

#btnPrevMonth svg {
    transform: rotate(90deg);
}

#btnNextMonth svg {
    transform: rotate(-90deg);
}

.month-weekdays-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--secondary-text);
    margin-bottom: 8px;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 40px);
    gap: 4px;
}

.month-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
}

.month-cell.selected {
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 700;
}

.month-cell.today:not(.selected) {
    border: 1.5px solid var(--accent);
}

.month-cell.other-month {
    color: var(--secondary-text);
    opacity: 0.35;
}

.month-cell .cell-dot {
    display: none;
    width: 4px;
    height: 4px;
    border-radius: 2px;
    background: var(--accent);
    position: absolute;
    bottom: 3px;
}

.month-cell.has-visit .cell-dot {
    display: block;
}

.month-cell.selected.has-visit .cell-dot {
    background: #FFFFFF;
}

/* Floating Action Button */
.fab-btn {
    position: fixed;
    bottom: calc(64px + max(16px, env(safe-area-inset-bottom)));
    right: 16px;
    width: 52px;
    height: 52px;
    border-radius: 26px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.40);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.fab-btn:active {
    transform: scale(0.92);
}

.fab-btn .icon {
    width: 24px;
    height: 24px;
    stroke-width: 2.25;
}

/* Clients Screen & 2-Line Row */
.search-container {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-field-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--search-bg);
    border-radius: 10px;
    height: 36px;
    padding: 0 10px;
}

.search-icon {
    width: 16px;
    height: 16px;
    color: var(--secondary-text);
    flex-shrink: 0;
}

.input-search {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 16px;
    color: var(--text);
    padding: 0 8px;
}

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

.search-clear-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-text);
}

.search-cancel-btn {
    background: transparent;
    border: none;
    font-size: 16px;
    color: var(--accent);
    cursor: pointer;
    padding: 4px 8px;
}

.client-row {
    display: flex;
    align-items: center;
    min-height: 60px;
    padding: 10px 16px;
    position: relative;
    cursor: pointer;
    background: var(--surface);
    transition: background-color 0.15s ease;
}

.client-row:not(:last-child)::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 68px;
    right: 0;
    height: 0.5px;
    background: var(--separator);
}

.client-row:active {
    background: var(--card-highlight);
}

.client-info-col {
    flex: 1;
    min-width: 0;
    padding: 0 12px;
}

.client-name {
    font-size: 17px;
    font-weight: 600;
    line-height: 22px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-meta {
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    letter-spacing: 0.02em;
    color: var(--secondary-text);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-date-col {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--secondary-text);
    white-space: nowrap;
    flex: none;
    margin-left: 8px;
    margin-right: 4px;
}

.client-chevron {
    color: var(--secondary-text);
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

/* Deterministic Pastel Avatars (8 colors, CSS only) */
.avatar-initials {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}

.avatar-pastel-0 { background: #E8F1FF; color: #0051C6; }
.avatar-pastel-1 { background: #EAF7EE; color: #198038; }
.avatar-pastel-2 { background: #FFF3E8; color: #BA4E00; }
.avatar-pastel-3 { background: #F5EEFD; color: #6929C4; }
.avatar-pastel-4 { background: #FDEEF2; color: #9F1853; }
.avatar-pastel-5 { background: #E8F8F5; color: #007D79; }
.avatar-pastel-6 { background: #FFF9E6; color: #8A6D00; }
.avatar-pastel-7 { background: #F0F0F2; color: #4D5358; }

[data-theme="dark"] .avatar-pastel-0 { background: #1C335A; color: #78A9FF; }
[data-theme="dark"] .avatar-pastel-1 { background: #1B3B24; color: #6FDC8C; }
[data-theme="dark"] .avatar-pastel-2 { background: #432811; color: #FF9E58; }
[data-theme="dark"] .avatar-pastel-3 { background: #351F56; color: #BE95FF; }
[data-theme="dark"] .avatar-pastel-4 { background: #441628; color: #FF7EB6; }
[data-theme="dark"] .avatar-pastel-5 { background: #123735; color: #3DDBD9; }
[data-theme="dark"] .avatar-pastel-6 { background: #3D3512; color: #F1C21B; }
[data-theme="dark"] .avatar-pastel-7 { background: #2B2C2E; color: #C6C6C6; }

/* Segmented Control (Повідомлення) */
.segmented-control {
    margin: 8px 16px 14px 16px;
    display: flex;
    background: var(--search-bg);
    border-radius: 10px;
    padding: 2px;
}

.segment-btn {
    flex: 1;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.segment-btn.active {
    background: var(--surface);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.subview-pane {
    display: block;
}

.subview-pane.hidden {
    display: none;
}

/* Filter Pills */
.segmented-filters {
    display: flex;
    gap: 8px;
    padding: 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.segmented-filters::-webkit-scrollbar {
    display: none;
}

.filter-pill {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--separator);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-pill.active {
    background: #0060D6;
    color: #FFFFFF;
    border-color: #0060D6;
    font-weight: 600;
}

.filter-pill-count {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    background: var(--search-bg);
    color: var(--text);
}

.filter-pill.active .filter-pill-count {
    background: rgba(255, 255, 255, 0.25);
    color: #FFFFFF;
}

.filter-pill.pill-hidden {
    display: none !important;
}

/* Messages Screen Minimal Header */
.messages-screen-header {
    margin-bottom: 6px;
}

.messages-segmented-control {
    margin: 0 16px 10px 16px;
    height: 36px;
    background: transparent;
    border-bottom: 1px solid var(--separator);
    border-radius: 0;
    padding: 0;
    display: flex;
    gap: 20px;
}

.messages-segmented-control .segment-btn {
    height: 36px;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    padding: 0 4px;
    font-size: 15px;
    font-weight: 500;
    color: var(--secondary-text);
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.messages-segmented-control .segment-btn.active {
    background: transparent;
    color: var(--text);
    font-weight: 600;
    border-bottom: 2px solid var(--accent);
}

/* Light & Airy Reminder Cards */
.reminder-card {
    margin: 8px 16px 12px 16px;
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid var(--separator);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.reminder-card.sent {
    opacity: 0.52;
}

.reminder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.reminder-client-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.reminder-title-col {
    flex: 1;
    min-width: 0;
}

.reminder-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
    word-break: break-word;
}

.reminder-meta-inline {
    font-size: 13px;
    color: var(--secondary-text);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reminder-badges-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.reminder-chip {
    font-size: 12px;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 8px;
    white-space: nowrap;
    line-height: 1.2;
}

.chip-today {
    background: rgba(0, 122, 255, 0.12);
    color: var(--accent);
    font-weight: 600;
}

.chip-tomorrow {
    background: rgba(88, 86, 214, 0.12);
    color: #5856d6;
}

.chip-overdue {
    background: rgba(255, 59, 48, 0.12);
    color: var(--destructive);
    font-weight: 600;
}

.chip-future {
    background: var(--search-bg);
    color: var(--secondary-text);
}

.sent-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--success);
    background: rgba(52, 199, 89, 0.12);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Light Quote Snippet - Clean text, no heavy dark box */
.reminder-quote-preview {
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--secondary-text);
    border-left: 2.5px solid var(--accent);
    padding: 2px 0 2px 10px;
    margin: 2px 0;
    cursor: pointer;
    user-select: text;
    transition: color 0.15s ease;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.reminder-quote-preview.expanded {
    display: block;
    -webkit-line-clamp: unset;
}

.reminder-quote-preview:active {
    color: var(--text);
}

.reminder-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.btn-reminder-direct {
    flex: 1;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-reminder-direct:active {
    transform: scale(0.98);
}

.btn-secondary-direct {
    background: var(--search-bg);
    color: var(--text);
}

.btn-sent-toggle {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--search-bg);
    color: var(--secondary-text);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sent-toggle:active {
    transform: scale(0.92);
}

.btn-sent-toggle.active {
    background: rgba(52, 199, 89, 0.16);
    color: var(--success);
}

.btn-sent-toggle.active svg {
    stroke: var(--success);
    stroke-width: 2.5;
}


/* Request Cards (Pending) */
.request-card {
    margin: 8px 16px 12px 16px;
    padding: 16px;
    border-radius: 14px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.request-card.resolving {
    opacity: 0;
    transform: scale(0.96) translateY(-8px);
}

.request-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.request-client-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.request-time-badge {
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary-text);
}

.request-quote {
    font-size: 14px;
    line-height: 19px;
    color: var(--text);
    background: var(--search-bg);
    border-radius: 8px;
    padding: 10px 12px;
    font-style: italic;
}

.request-service {
    font-size: 14px;
    color: var(--secondary-text);
}

.request-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    padding: 0 16px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.15s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-sm {
    height: 36px;
    padding: 0 12px;
    font-size: 13px;
}

.btn-accent {
    background: var(--accent);
    color: var(--accent-text);
}

.btn-neutral {
    background: var(--search-bg);
    color: var(--text);
}

.btn-destructive {
    background: rgba(255, 59, 48, 0.12);
    color: var(--destructive);
}

.btn-text-destructive {
    background: transparent;
    border: none;
    color: var(--destructive);
    font-size: 15px;
    font-weight: 600;
    padding: 12px;
    cursor: pointer;
    text-align: center;
    width: 100%;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--search-bg);
    transition: 0.2s;
    border-radius: 31px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .switch-slider {
    background-color: var(--success);
}

input:checked + .switch-slider:before {
    transform: translateX(20px);
}

/* Skeleton Loaders */
.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    min-height: 56px;
}

.skeleton-box {
    background: var(--search-bg);
    border-radius: 6px;
    animation: skeletonPulse 1.5s infinite ease-in-out;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-text-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skeleton-line-title {
    width: 60%;
    height: 16px;
}

.skeleton-line-sub {
    width: 40%;
    height: 12px;
}

@keyframes skeletonPulse {
    0% { opacity: 0.5; }
    50% { opacity: 0.9; }
    100% { opacity: 0.5; }
}

/* Tab Panes */
.tab-pane {
    display: none;
    padding-bottom: calc(52px + 16px + env(safe-area-inset-bottom, 0px));
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.15s ease-out;
}

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

/* 4-Tab Bottom Navigation Bar */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: calc(52px + max(8px, env(safe-area-inset-bottom)));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    background: var(--tabbar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid var(--separator);
}

.tab-btn {
    flex: 1;
    height: 52px;
    background: transparent;
    border: none;
    outline: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--secondary-text);
    padding: 4px 0;
    min-height: 44px;
    position: relative;
}

.tab-icon-wrap {
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-icon {
    width: 22px;
    height: 22px;
}

.tab-icon.icon-filled {
    display: none;
}

.tab-btn.active .tab-icon.icon-filled {
    display: block;
}

.tab-btn.active .tab-icon.icon-outline {
    display: none;
}

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

.tab-label {
    font-size: 11px;
    font-weight: 500;
    margin-top: 2px;
    line-height: 12px;
}

.tab-badge {
    position: absolute;
    top: -2px;
    right: -8px;
    background: var(--destructive);
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Bottom Sheet Modals */
.sheet-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: opacity 0.25s ease;
}

.sheet-container {
    width: 100%;
    max-width: 500px;
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    padding: 12px 16px calc(16px + max(16px, env(safe-area-inset-bottom))) 16px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    animation: sheetSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.sheet-container-tall {
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.sheet-scrollable {
    overflow-y: auto;
    flex: 1;
}

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

.sheet-grabber {
    width: 36px;
    height: 5px;
    background: var(--separator);
    border-radius: 3px;
    margin: 0 auto 12px auto;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 0.5px solid var(--separator);
}

.sheet-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.sheet-close-btn {
    background: var(--search-bg);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-text);
}

.sheet-close-btn .icon {
    width: 14px;
    height: 14px;
}

.sheet-body {
    padding: 16px 0 8px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sheet-detail-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sheet-detail-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--secondary-text);
}

.sheet-detail-value {
    font-size: 16px;
    color: var(--text);
    word-break: break-word;
}

.sheet-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

/* Sheet Form Controls */
.sheet-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 0 6px 0;
    width: 100%;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.form-row-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--secondary-text);
    letter-spacing: 0.3px;
}

.form-input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 48px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--separator);
    background: var(--search-bg);
    color: var(--text);
    font-size: 16px;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    border-color: var(--accent);
    background: var(--surface);
}

.date-field {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 48px;
    box-sizing: border-box;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--separator);
    background: var(--search-bg);
    overflow: hidden;
}

.date-field-display {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    flex: 1;
    min-width: 0;
}

.date-field-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    z-index: 2;
}

.form-textarea {
    height: auto;
    min-height: 84px;
    max-height: 144px;
    padding: 10px 12px;
    resize: none;
    line-height: 20px;
    overflow-y: auto;
}

/* Post text container */
.post-text-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--search-bg);
    border-radius: 10px;
    padding: 12px;
    max-height: 320px;
    overflow-y: auto;
}

/* Confirmation Dialog */
.confirm-dialog-card {
    width: 100%;
    max-width: 320px;
    background: var(--surface);
    border-radius: 16px;
    padding: 24px 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    margin: auto 16px calc(24px + max(16px, env(safe-area-inset-bottom))) 16px;
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.confirm-dialog-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.confirm-dialog-desc {
    font-size: 14px;
    color: var(--secondary-text);
    line-height: 19px;
    margin-bottom: 20px;
}

.confirm-dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Empty State */
.empty-state {
    padding: 40px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.empty-state-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.empty-state-subtitle {
    font-size: 14px;
    color: var(--secondary-text);
    line-height: 19px;
    max-width: 280px;
}

/* Toast message */
.toast-msg {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 20px;
    z-index: 300;
    pointer-events: none;
    animation: toastFade 2s forwards;
}

@keyframes toastFade {
    0% { opacity: 0; transform: translate(-50%, -10px); }
    15% { opacity: 1; transform: translate(-50%, 0); }
    80% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -10px); }
}

/* Unauthorized View */
.view-unauthorized {
    padding: 60px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.unauthorized-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 32px 24px;
    max-width: 340px;
    margin: 0 auto;
}

.unauthorized-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--search-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px auto;
    color: var(--secondary-text);
}

.unauthorized-title {
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.unauthorized-desc {
    font-size: 14px;
    line-height: 20px;
    color: var(--secondary-text);
}

/* Icons */
.icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
}

/* Accessibility & Reduced Motion */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

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

.clients-loading-spinner {
    text-align: center;
    padding: 14px 0;
    font-size: 13px;
    color: var(--secondary-text);
}

.clients-scroll-sentinel {
    height: 24px;
    margin-top: -10px;
}
