:root {
    --primary: #1e3a5f;
    --primary-light: #2d5a8e;
    --primary-dark: #152a45;
    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --bg: #f0f4f8;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lg: 0 4px 20px rgba(0,0,0,.1);
    --header-h: 56px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --content-max: 960px;
    --touch-min: 44px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

body.admin-body { --content-max: 1100px; }

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--safe-top) 16px 0;
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    min-width: 0;
}

.logo-icon { font-size: 20px; flex-shrink: 0; }
.logo-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.user-badge {
    font-size: 12px;
    opacity: .85;
    display: none;
}

@media (min-width: 480px) {
    .user-badge { display: inline; }
}

/* Main */
.main-content {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 20px 16px calc(24px + var(--safe-bottom));
    width: 100%;
}

/* Login */
.login-page {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 20px;
}

.login-container { width: 100%; max-width: 400px; }

.login-card {
    background: var(--card);
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: var(--shadow-lg);
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-header h1 { font-size: 22px; color: var(--primary); margin-bottom: 4px; }
.login-header p { color: var(--text-muted); font-size: 14px; }

.login-form .form-group { margin-bottom: 16px; }

/* Typography */
.page-header {
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.page-header h1 { font-size: 22px; font-weight: 700; color: var(--primary); }
.page-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.section { margin-top: 32px; }
.section-title { font-size: 17px; font-weight: 600; margin-bottom: 16px; color: var(--primary); }
.section-subtitle { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: inherit;
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(30,58,95,.12);
}

.form-hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-group input { width: auto; }

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    min-height: var(--touch-min);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, transform .1s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.btn:active { transform: scale(.98); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-outline {
    background: transparent;
    color: #fff;
    border: 1.5px solid rgba(255,255,255,.4);
}
.btn-outline:hover { background: rgba(255,255,255,.1); }

.main-content .btn-outline {
    color: var(--primary);
    border-color: var(--border);
    background: #fff;
}
.main-content .btn-outline:hover { background: var(--bg); }

.btn-ghost {
    background: transparent;
    color: rgba(255,255,255,.85);
    padding: 8px 12px;
}
.main-content .btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { background: rgba(0,0,0,.05); }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.alert-success { background: var(--success-light); color: #065f46; }
.alert-error { background: var(--danger-light); color: #991b1b; }
.alert-warning { background: var(--warning-light); color: #92400e; }

.current-vehicle-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: #dbeafe;
    color: #1e40af;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}

.vehicle-selected {
    border-color: var(--primary-light) !important;
    background: #f8fbff;
}

.vehicle-selected-badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    margin-bottom: 8px;
}

/* Vehicle Grid */
.vehicle-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 480px) {
    .vehicle-grid { grid-template-columns: repeat(2, 1fr); }
}

.vehicle-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    transition: border-color .2s, transform .15s;
}

.vehicle-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

/* User action menu */
.user-action-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 480px) {
    .user-action-grid { grid-template-columns: 1fr 1fr; }
}

.user-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 28px 20px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    border: 2px solid transparent;
    transition: transform .15s, border-color .2s, box-shadow .2s;
    position: relative;
}

.user-action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.user-action-card.fuel-action:hover { border-color: var(--success); }
.user-action-card.end-action:hover { border-color: var(--danger); }

.action-icon { font-size: 40px; }
.action-title { font-size: 17px; font-weight: 700; color: var(--primary); }
.action-desc { font-size: 13px; color: var(--text-muted); line-height: 1.4; }

.action-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--success-light);
    color: #065f46;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
}

.summary-bar {
    background: var(--card);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    font-size: 14px;
    text-align: center;
}

.vehicle-info-card.compact {
    padding: 18px;
    margin-bottom: 16px;
}

.page-header .btn-ghost {
    margin-bottom: 8px;
    padding-left: 0;
}

.vehicle-plate {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.vehicle-plate.large { font-size: 28px; text-align: center; }

.vehicle-model {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.vehicle-km { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }

.vehicle-status {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.vehicle-status.busy {
    background: var(--warning-light);
    color: #92400e;
}

/* Active Vehicle */
.vehicle-info-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
}

/* Plaka rozeti — mavi kart üzerinde beyaz zemin */
.plate-badge {
    display: table;
    margin: 0 auto 14px;
    padding: 12px 28px;
    background-color: #ffffff;
    color: #0f2744;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 3px;
    line-height: 1.2;
    text-align: center;
    text-transform: uppercase;
    border-radius: 10px;
    border: 3px solid #0f2744;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    max-width: 100%;
    word-break: break-word;
}

.vehicle-info-card .vehicle-model {
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    margin-bottom: 20px;
}

.km-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.km-item {
    background: rgba(255,255,255,.15);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}

.km-label { display: block; font-size: 12px; opacity: .8; margin-bottom: 4px; }
.km-value { font-size: 18px; font-weight: 700; }
.km-value.fuel { color: #a7f3d0; }

.action-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.action-card h2 { font-size: 16px; margin-bottom: 16px; }

.end-card { border: 2px solid var(--danger-light); }
.end-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }

/* File Upload */
.file-upload { position: relative; }

.file-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color .2s, background .2s;
    text-align: center;
}

.file-label:hover, .file-input:focus + .file-label {
    border-color: var(--primary-light);
    background: rgba(30,58,95,.03);
}

.file-icon { font-size: 32px; }
.file-text { font-size: 14px; color: var(--text-muted); }

.file-input-simple {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 8px;
}

.image-preview {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    margin-top: 12px;
    background: var(--bg);
}

.image-preview.small { max-height: 120px; width: auto; }

/* Fuel List */
.fuel-list { display: flex; flex-direction: column; gap: 10px; }

.fuel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.fuel-amount { font-weight: 700; color: var(--success); font-size: 16px; }
.fuel-date { font-size: 13px; color: var(--text-muted); flex: 1; }

.fuel-receipt img, .thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    font-size: 14px;
}

.data-table-compact { font-size: 13px; }
.data-table-compact th,
.data-table-compact td { padding: 10px 12px; }

@media (min-width: 768px) {
    .data-table { min-width: 560px; }
}

.data-table th {
    background: var(--primary);
    color: #fff;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(30,58,95,.02); }
.row-inactive td { opacity: .5; }

.data-table .actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-warning { background: var(--warning-light); color: #92400e; }

.text-success { color: var(--success); font-weight: 500; }
.text-muted { color: var(--text-muted); }

/* Admin */
.admin-nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

@media (min-width: 600px) {
    .admin-nav { grid-template-columns: repeat(4, 1fr); }
}

.admin-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    background: var(--card);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s;
    font-size: 13px;
    font-weight: 500;
}

.admin-nav-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    color: var(--primary);
}

.nav-icon { font-size: 28px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

@media (min-width: 600px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card.highlight {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    word-break: break-word;
}

.stat-label {
    font-size: 12px;
    margin-top: 6px;
    opacity: .75;
}

.stat-card:not(.highlight) .stat-label { color: var(--text-muted); }

.admin-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    min-width: 0;
}

@media (min-width: 900px) {
    .admin-layout {
        display: grid;
        grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
        align-items: start;
        gap: 24px;
    }
}

.admin-form-card,
.admin-list-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    min-width: 0;
    width: 100%;
}

@media (min-width: 600px) {
    .admin-form-card,
    .admin-list-card { padding: 24px; }
}

.admin-form-card h2,
.admin-list-card h2 {
    font-size: 16px;
    margin-bottom: 20px;
    color: var(--primary);
}

/* Tabs */
.tab-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-item {
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-muted);
    background: var(--card);
    border: 1.5px solid var(--border);
    white-space: nowrap;
    transition: all .2s;
}

.tab-item.active,
.tab-item:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    padding: 16px;
}

@media (min-width: 480px) {
    .modal-overlay { align-items: center; }
}

.modal-card {
    background: var(--card);
    border-radius: 16px 16px 0 0;
    padding: 24px;
    width: 100%;
    max-width: 440px;
    max-height: 90dvh;
    overflow-y: auto;
}

@media (min-width: 480px) {
    .modal-card { border-radius: 16px; }
}

.modal-card h2 {
    font-size: 17px;
    margin-bottom: 20px;
    color: var(--primary);
}

/* Reports */
.period-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.period-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    background: var(--card);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 140px;
}

.filter-bar .form-group input {
    padding: 10px 12px;
    font-size: 14px;
}

.insight-card {
    background: var(--success-light);
    color: #065f46;
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 14px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state.small { padding: 24px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* Mobile / Desktop visibility */
.show-mobile { display: flex; flex-direction: column; gap: 12px; }
.hide-mobile { display: none; }

@media (min-width: 768px) {
    .show-mobile { display: none !important; }
    .hide-mobile { display: block; }
    .table-responsive.hide-mobile { display: block; }
}

/* Data cards (mobile-first lists) */
.mobile-card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.data-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    width: 100%;
}

.data-card-inactive { opacity: .55; }
.data-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform .15s, box-shadow .15s;
}
.data-card-link:active { transform: scale(.99); }

.data-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.data-card-body { display: flex; flex-direction: column; gap: 8px; }

.data-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.data-card-row span:first-child { color: var(--text-muted); flex-shrink: 0; }
.data-card-row span:last-child { text-align: right; font-weight: 500; }

.data-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.data-card-actions .btn { flex: 1; }

.plate-text {
    font-size: 17px;
    letter-spacing: .5px;
    color: var(--primary);
}

.text-sm { font-size: 13px; }
.count-badge {
    display: inline-block;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
}

.page-back {
    display: inline-block;
    margin-bottom: 8px;
    padding-left: 0 !important;
}

.input-uppercase { text-transform: uppercase; }

.filter-bar-stack {
    flex-direction: column;
    align-items: stretch !important;
}

.filter-bar-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

@media (min-width: 600px) {
    .filter-bar-stack {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end !important;
    }
    .filter-bar-stack .form-group:first-child { min-width: 200px; flex: 2; }
}

.table-responsive {
    max-width: 100%;
    width: 100%;
}

/* Header mobile: compact buttons */
@media (max-width: 400px) {
    .header-actions .btn-sm {
        padding: 8px 10px;
        font-size: 12px;
    }
    .logo-text { max-width: 100px; }
}

/* Vehicle card as form */
.vehicle-card {
    display: block;
    width: 100%;
}

/* Tab scroll snap */
.tab-nav {
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
}
.tab-nav::-webkit-scrollbar { display: none; }

/* Modal safe area */
.modal-overlay {
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
}

/* Form actions full width mobile */
@media (max-width: 599px) {
    .form-actions .btn { flex: 1; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header .btn { align-self: flex-start; }
}

/* Insight & stats mobile */
@media (max-width: 380px) {
    .stat-value { font-size: 18px; }
    .stats-grid { gap: 8px; }
    .stat-card { padding: 14px 10px; }
}
