:root {
    --bg: #0f1115;
    --bg-elevated: #171a20;
    --bg-elevated-soft: #191d26;
    --accent: #2ea6ff;
    --accent-soft: rgba(46, 166, 255, 0.1);
    --accent-strong: rgba(46, 166, 255, 0.2);
    --text: #f7f8fa;
    --text-soft: #9ca3af;
    --border-subtle: #232733;
    --danger: #f97373;
    --radius-lg: 18px;
    --radius-full: 999px;
    --shadow-soft: 0 12px 35px rgba(0, 0, 0, 0.55);
    --font-main: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden; /* Prevent horizontal scroll */
    -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape view */
    -webkit-user-select: none; /* Prevent text selection on iOS */
    user-select: none; /* Standard property for text selection prevention */
    -webkit-touch-callout: none; /* Disable callout menu on iOS */
}

body {
    -webkit-font-smoothing: antialiased;
}

.app {
    min-height: 100vh;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 12px 12px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #141823, #0c0e13);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: var(--shadow-soft);
}

.app-header__title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-header__name {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.02em;
}

.app-header__subtitle {
    font-size: 11px;
    color: var(--text-soft);
}

.app-header__user {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: radial-gradient(circle at 0 0, #4ade80, #22c55e, #16a34a);
    border: 1px solid rgba(15, 23, 42, 0.8);
    overflow: hidden;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.clickable-avatar {
    cursor: pointer;
    transition: all 0.2s ease;
}

.clickable-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 0 0 2px var(--accent);
}

.user-meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-username {
    font-size: 11px;
    color: var(--text-soft);
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card {
    padding: 14px 14px 12px;
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.card--accent {
    background: radial-gradient(circle at 0 0, rgba(46, 166, 255, 0.18), transparent 55%), var(--bg-elevated);
}

.card__title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
}

.card__subtitle {
    margin: 0 0 10px;
    font-size: 12px;
    color: var(--text-soft);
}

.services {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    border: 1px solid var(--border-subtle);
    background: rgba(15, 23, 42, 0.9);
    border-radius: var(--radius-full);
    padding: 8px 12px; /* Increased padding for better touch targets */
    font-size: 12px;
    color: var(--text-soft);
    cursor: pointer;
    transition: all 0.18s ease-out;
    min-height: 32px; /* Ensure minimum touch target size */
    display: flex;
    align-items: center;
    justify-content: center;
}

.chip:hover {
    border-color: var(--accent-soft);
    background: rgba(15, 23, 42, 1);
}

.chip--active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--text);
    box-shadow: 0 0 0 1px var(--accent-strong);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field__label {
    font-size: 11px;
    color: var(--text-soft);
}

.field__input {
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated-soft);
    padding: 10px 12px; /* Increased padding for better touch targets */
    font-size: 13px;
    color: var(--text);
    outline: none;
    transition: border-color 0.18s ease-out, box-shadow 0.18s ease-out, background 0.18s ease-out;
    min-height: 44px; /* Ensure minimum touch target size */
    -webkit-appearance: none; /* Remove default iOS styling */
    -moz-appearance: none;
    appearance: none;
}

.field__input::placeholder {
    color: #64748b;
}

.field__input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-soft);
    background: #11141c;
}

.field__input--textarea {
    resize: vertical;
    min-height: 70px;
}

.app-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 2px;
}

.btn-primary {
    width: 100%;
    border-radius: var(--radius-full);
    border: none;
    padding: 14px 16px; /* Increased padding for better touch targets */
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    background: linear-gradient(135deg, #2ea6ff, #6366f1);
    color: #0b1020;
    cursor: pointer;
    box-shadow: 0 14px 35px rgba(37, 99, 235, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px; /* Ensure minimum touch target size */
    transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, filter 0.12s ease-out;
}

.btn-primary:hover {
    filter: brightness(1.05);
    box-shadow: 0 16px 40px rgba(37, 99, 235, 0.65);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.45);
}

.btn-primary:disabled {
    opacity: 0.65;
    cursor: default;
    box-shadow: none;
}

.status {
    min-height: 16px;
    font-size: 11px;
    color: var(--text-soft);
}

.status--error {
    color: var(--danger);
}

.status--success {
    color: #4ade80;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.history-item {
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(30, 41, 59, 0.9);
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
}

.history-item__top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.history-item__service {
    font-weight: 500;
}

.history-item__datetime {
    color: var(--text-soft);
}

.history-item__bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
}

.history-item__status {
    font-size: 10px;
    color: var(--text-soft);
}

.history-item__actions {
    display: flex;
    gap: 4px;
}

.btn-pill {
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text-soft);
    padding: 3px 8px;
    font-size: 10px;
    cursor: pointer;
}

.btn-pill--primary {
    border-color: var(--accent);
    color: var(--accent);
}

.field__value {
    font-size: 13px;
    color: var(--text);
}

.tabs {
    display: flex;
    gap: 4px;
    padding: 2px;
    margin-bottom: 4px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(30, 41, 59, 0.9);
}

.tab {
    flex: 1;
    border-radius: 999px;
    border: none;
    padding: 10px 0; /* Increased padding for better touch targets */
    font-size: 11px;
    color: var(--text-soft);
    background: transparent;
    cursor: pointer;
    transition: background 0.15s ease-out, color 0.15s ease-out;
    min-height: 40px; /* Ensure minimum touch target size */
}

.tab--active {
    background: var(--accent-soft);
    color: var(--text);
}

.page {
    display: none;
    flex-direction: column;
    gap: 8px;
}

.page--active {
    display: flex;
}

select.field__input {
    padding-right: 24px;
    background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
    background-position: calc(100% - 14px) 11px, calc(100% - 9px) 11px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Prevent selection and scaling on interactive elements */
input, textarea, select, button {
    -webkit-user-modify: read-write-plaintext-only; /* iOS Safari */
    -webkit-user-select: auto; /* Enable text selection where needed */
    user-select: auto; /* Standard property for text selection */
    -webkit-touch-callout: default; /* Re-enable callout where needed */
}

/* Extra small devices (phones, 320px and down) */
@media (max-width: 320px) {
    .app {
        padding: 8px 8px 12px;
    }

    .app-header {
        padding: 8px 10px;
        gap: 8px;
    }

    .app-header__name {
        font-size: 14px;
    }

    .card {
        padding: 12px 12px 10px;
    }

    .card__title {
        font-size: 14px;
    }

    .field__input {
        padding: 6px 8px;
        font-size: 12px;
    }

    .btn-primary {
        padding: 10px 14px;
        font-size: 13px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* Small devices (landscape phones, 321px to 480px) */
@media (min-width: 321px) and (max-width: 480px) {
    .app {
        padding: 10px 10px 16px;
    }

    .app-header {
        padding: 9px 12px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Medium devices (tablets, 481px to 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .app {
        margin: 12px auto;
        padding: 14px 14px 20px;
    }

    body {
        background: radial-gradient(circle at top, #1e293b, #020617 55%);
    }
}

/* Large devices (desktops, 769px and up) */
@media (min-width: 769px) {
    .app {
        margin: 20px auto;
        padding: 16px 16px 24px;
    }

    body {
        display: flex;
        align-items: center;
        justify-content: center;
        background: radial-gradient(circle at top, #1e293b, #020617 55%);
    }
}

@media (min-width: 481px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        background: radial-gradient(circle at top, #1e293b, #020617 55%);
    }

    .app {
        margin: 16px auto;
    }
}

.loading-screen {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top, #020617, #020617 55%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.25s ease-out, visibility 0.25s ease-out;
}

.loading-screen--hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-card {
    width: 260px;
    padding: 20px 18px 18px;
    border-radius: 22px;
    background: radial-gradient(circle at 0 0, rgba(37, 99, 235, 0.4), transparent 55%), #020617;
    border: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow: 0 32px 80px rgba(15, 23, 42, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.loading-logo {
    width: 44px;
    height: 44px;
    border-radius: 18px;
    background: radial-gradient(circle at 0 0, #2ea6ff, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #0b1020;
}

.loading-text-main {
    font-size: 15px;
    font-weight: 600;
}

.loading-text-sub {
    font-size: 11px;
    color: var(--text-soft);
}

.loading-spinner {
    margin-top: 4px;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-top-color: #2ea6ff;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

