:root {
    --primary-color: #2E7D32;
    /* TerraTrack Green/Nature feel */
    --primary-dark: #1B5E20;
    --background-color: #F5F7FA;
    --card-bg: #FFFFFF;
    --text-main: #333333;
    --text-muted: #666666;
    --border-color: #E0E0E0;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --radius-md: 8px;
    --radius-lg: 12px;
    --font-heading: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    --header-height: 60px;
    --footer-height: 80px;
    /* Increased for bottom nav */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    background-color: #e0e0e0;
    /* Desktop background */
    height: 100%;
}

body {
    font-family: var(--font-heading);
    background-color: var(--background-color);
    /* App background */
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    /* Force height to match viewport */
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    /* Disable body scroll, use container scroll */
}

/* Header */
.app-header {
    height: var(--header-height);
    background-color: var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    box-shadow: var(--shadow-sm);
    position: fixed;
    top: 0;
    width: 100%;
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    color: white;
}

.logo-area {
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.settings-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* Main Content */
.main-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--header-height) + 20px) 20px var(--footer-height);
    width: 100%;
}

.login-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 400px;
    /* Limits width on PC for better aesthetics */
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.5rem 2rem;
    text-align: center;
    transition: transform 0.2s ease;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-main);
}

/* Form Elements */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.input-group {
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: #fff;
}

.input-group select {
    width: 100%;
    padding: 0.9rem;
    padding-right: 2.5rem;
    /* Space for custom arrow */
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: #fff;

    /* Custom Arrow */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%23666666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
    cursor: pointer;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-top: 1rem;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-save-outline {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-top: 1rem;
    width: 100%;
    transition: all 0.2s ease;
}

.btn-save-outline:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Footer */
.app-footer {
    height: var(--footer-height);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    background-color: transparent;
}

/* Dashboard Layout */
/* Dashboard Layout */
.dashboard-container {
    padding: calc(var(--header-height) + 10px) 15px 160px;
    /* Increased bottom padding for floating button */
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* Enable scrolling within container */
}

#record-form {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#record-form .btn-save-outline {
    position: fixed;
    bottom: calc(var(--footer-height) + 15px);
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 30px);
    /* Full width minus container padding */
    max-width: 570px;
    /* Max width minus padding */
    margin: 0;
    z-index: 90;
    background-color: var(--background-color);
    /* Mask scrolling content */
    /* Ensure text is readable against background */
}

/* Site Selection */
.site-select-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    text-align: center;
    margin-top: 2rem;
}

/* Tab Navigation */
/* Tab Navigation */
/* Tab Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    height: var(--footer-height);
    background: var(--primary-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    border-top: none;
}

.nav-item {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.5);
    /* Inactive text color: 50% opacity */
    font-size: 0.9rem;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.nav-item.active {
    color: #FFFFFF;
    font-weight: 700;
    /* Active tab background removed */
}

.nav-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 6px;
    height: 32px;
}

.nav-icon img {
    height: 32px;
    width: auto;
    opacity: 0.5;
    /* Inactive icon opacity: 50% */
    transition: opacity 0.2s ease;
}

.nav-item.active .nav-icon img {
    opacity: 1;
    /* Active icon opacity */
}

/* Camera Section */
.camera-section {
    position: relative;
    width: 100%;
    height: 0;
    /* padding hack for aspect ratio */
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
    display: block;
    /* Remove flex, use absolute children */
    box-shadow: var(--shadow-md);
}

#camera-stream {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    gap: 10px;
}

.scan-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    padding: 10px 24px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
}

.scan-btn:active {
    transform: scale(0.95);
}

.camera-fallback-msg {
    position: absolute;
    top: 20px;
    /* Moved to top to avoid overlapping with centered icon */
    left: 0;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 0.9rem;
    z-index: 10;
    line-height: 1.4;
    padding: 0 10px;
    /* Reduced padding */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    word-break: keep-all;
    /* Prevent awkward breaks */
}

/* Camera Icon */
.camera-icon-img {
    width: 80px;
    height: auto;
    opacity: 0.8;
}

/* Data Lists */
.data-card {
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
}

.data-card:hover {
    border-color: var(--primary-color);
}

.data-info div {
    margin-bottom: 4px;
}

.data-plate {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
}

.data-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.data-date {
    color: #999;
    font-size: 0.8rem;
    text-align: right;
}

/* Input Row for 2-column layout */
/* Input Row (Default: Stacked for PC) */
/* Input Row (Layout container) */
.input-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 0;
}

/* Global Form Spacing via Flex Gap */
#record-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 60px;
    /* Space for fixed save button */
}

/* Remove margins to rely on gap */
.input-group,
.input-group.half {
    margin-bottom: 0 !important;
    position: relative;
    width: 100%;
}

/* Responsive Tweaks - General Mobile */
@media (max-width: 480px) {
    .login-card {
        box-shadow: none;
        background: transparent;
        padding: 1rem 0.5rem;
        max-width: 100%;
    }

    .page-title {
        font-size: 1.6rem;
        margin-bottom: 1.5rem;
    }

    .camera-section {
        width: 100%;
    }

    /* Reduce Camera Icon on Mobile (80% of original) */
    .camera-icon-img {
        width: 64px !important;
        /* 80px * 0.8 = 64px */
    }
}

/* Specific Layout for iPhone SE (Short & Narrow) - Compact Spacing */
@media (max-width: 380px) and (max-height: 700px) {
    #record-form {
        gap: 0.5rem;
        /* Reduced from 1rem */
    }

    .input-row {
        gap: 0.5rem;
        /* Reduced from 1rem */
    }
}