:root {
    --bg: #ffffff;
    --bg-soft: #f7f7f8;
    --card-bg: #ffffff;
    --text: #212121;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --accent: #ffdb4d;
    --accent-hover: #facc15;
    --accent-text: #212121;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --radius: 20px;
    --radius-sm: 14px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.1);
    --input-bg: #f7f7f8;
}

[data-theme="dark"] {
    --bg: #0f0f0f;
    --bg-soft: #1a1a1a;
    --card-bg: #1a1a1a;
    --text: #f5f5f5;
    --text-light: #9ca3af;
    --border: #2a2a2a;
    --accent: #ffdb4d;
    --accent-hover: #facc15;
    --accent-text: #212121;
    --input-bg: #0f0f0f;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
}

header {
    width: 100%;
    max-width: 720px;
    padding: 32px 20px 20px;
    position: relative;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-top: 4px;
    font-weight: 500;
}

.theme-toggle {
    position: absolute;
    top: 28px;
    right: 20px;
    background: var(--bg-soft);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle:hover { transform: scale(1.05); background: var(--border); }

main {
    flex: 1;
    width: 100%;
    max-width: 720px;
    padding: 0 20px 60px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    width: 100%;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
}

.card h2 {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 24px;
    color: var(--text);
    letter-spacing: -0.3px;
}

.form { display: flex; flex-direction: column; gap: 18px; }

.form label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.form input,
.form select,
.form textarea {
    padding: 16px 18px;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    background: var(--input-bg);
    color: var(--text);
    font-family: inherit;
    font-weight: 500;
}

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

.btn {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 24px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    text-decoration: none;
    gap: 8px;
    min-height: 56px;
    letter-spacing: -0.2px;
}
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255, 219, 77, 0.4); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
    background: var(--bg-soft);
    color: var(--text);
    border: 2px solid var(--border);
}
.btn-secondary:hover { background: var(--border); box-shadow: none; }

.btn-small {
    padding: 10px 16px;
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-small:hover { background: var(--accent-hover); }

.message {
    text-align: center;
    font-size: 0.95rem;
    padding: 14px;
    border-radius: var(--radius-sm);
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.3s;
    font-weight: 600;
}
.message.success { background: #d1fae5; color: #065f46; opacity: 1; }
.message.error { background: #fee2e2; color: #991b1b; opacity: 1; }
[data-theme="dark"] .message.success { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .message.error { background: #7f1d1d; color: #fca5a5; }

.link-back {
    display: block;
    text-align: center;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.95rem;
    margin-top: 20px;
    font-weight: 500;
}
.link-back:hover { color: var(--text); }

/* Карточки заказов и платежей */
.order-item {
    background: var(--bg-soft);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.order-item.active {
    border-color: var(--accent);
    background: rgba(255, 219, 77, 0.08);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 700;
}

.order-header .status {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

.order-route {
    font-size: 0.92rem;
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 14px;
    font-weight: 500;
}

.order-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-detail {
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    padding: 22px;
    margin-bottom: 16px;
}

.order-detail p {
    margin-bottom: 10px;
    line-height: 1.7;
    font-weight: 500;
}

.driver-info {
    background: var(--card-bg);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-top: 14px;
    border-left: 4px solid var(--accent);
    font-weight: 500;
}

.price-preview {
    padding: 20px;
    background: linear-gradient(135deg, #fff9e6, #fff3cc);
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--accent-text);
    font-size: 0.95rem;
    line-height: 1.8;
    font-weight: 500;
}
[data-theme="dark"] .price-preview {
    background: rgba(255, 219, 77, 0.1);
    color: var(--accent);
}
.price-preview small { color: var(--text-light); }

/* Табы */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 12px 20px;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: var(--bg-soft);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    transition: all 0.15s;
}

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

/* Тост */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    font-size: 1rem;
    font-weight: 700;
    display: none;
    max-width: 90%;
}
.toast.show { display: block; animation: slideDown 0.3s ease; }
@keyframes slideDown { from { top: -100px; opacity: 0; } to { top: 24px; opacity: 1; } }

/* Чат */
.chat-box {
    max-height: 500px;
    overflow-y: auto;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 14px;
}

.msg {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    margin-bottom: 10px;
    font-size: 0.95rem;
    word-wrap: break-word;
    font-weight: 500;
    line-height: 1.5;
}

.msg.mine {
    background: var(--accent);
    color: var(--accent-text);
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.msg.theirs {
    background: var(--card-bg);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg-time {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 4px;
    font-weight: 500;
}

.chat-input { display: flex; gap: 8px; }
.chat-input input {
    flex: 1;
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    font-size: 1rem;
    outline: none;
    background: var(--input-bg);
    color: var(--text);
    font-family: inherit;
    font-weight: 500;
}
.chat-input input:focus { border-color: var(--accent); background: var(--card-bg); }
.chat-input button { padding: 16px 20px; min-width: 60px; min-height: auto; }

/* Платежи */
.payment-item {
    background: var(--bg-soft);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px;
    margin-bottom: 12px;
}
.payment-item.confirmed { border-color: var(--success); background: rgba(16, 185, 129, 0.06); }
.payment-item.pending { border-color: var(--warning); background: rgba(245, 158, 11, 0.06); }

.payment-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
.payment-row:last-child { border-bottom: none; }
.payment-label { color: var(--text-light); font-weight: 500; }
.payment-value { font-weight: 700; }

footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 500;
}

@media (max-width: 500px) {
    header h1 { font-size: 1.5rem; }
    .card { padding: 22px; }
    .btn { padding: 14px 20px; min-height: 52px; }
    .theme-toggle { width: 40px; height: 40px; font-size: 1.1rem; top: 24px; right: 16px; }
    main { padding: 0 16px 40px; }
}