* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #16213e;
    --primary: #0f3460;
    --accent: #e94560;
    --accent-green: #00b894;
    --accent-yellow: #fdcb6e;
    --text: #eee;
    --text-dim: #888;
    --text-muted: #555;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

#app {
    min-height: 100%;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

/* Screens */
.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen.hidden { display: none; }

.screen-content {
    flex: 1;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
}

/* Logo */
.logo {
    font-size: 64px;
    text-align: center;
    margin-top: 40px;
    margin-bottom: 8px;
}

h1 {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 1px;
}

.subtitle {
    text-align: center;
    color: var(--text-dim);
    margin-bottom: 32px;
    font-size: 14px;
}

.info-text {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Forms */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--text-muted);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--accent);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    margin-top: 8px;
}

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

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

.btn-primary:hover {
    opacity: 0.9;
}

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

.btn-danger {
    background: #c0392b;
    color: white;
}

.btn-scan {
    background: var(--accent-green);
    color: white;
    font-size: 20px;
    padding: 24px;
    border-radius: 16px;
    margin: 16px 0;
    box-shadow: 0 4px 24px rgba(0, 184, 148, 0.3);
}

/* Top Bar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-user {
    font-weight: 600;
    font-size: 14px;
}

.topbar-clock {
    font-size: 13px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.topbar-back {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 0;
}

.topbar-action {
    background: none;
    border: 1px solid var(--text-muted);
    color: var(--text);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

/* Dashboard */
.dashboard-content {
    align-items: center;
}

.shift-badge {
    background: var(--accent-green);
    color: white;
    padding: 6px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 24px;
}

.scan-counter {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 16px;
}

.scan-counter #scan-number {
    font-size: 64px;
    font-weight: 700;
    line-height: 1;
}

.scan-counter .scan-label {
    font-size: 14px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* Scan Log Preview */
.log-preview {
    width: 100%;
    margin: 16px 0;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
}

.log-preview h3 {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 12px;
    text-align: left;
}

.log-preview ul {
    list-style: none;
}

.log-preview li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--text-muted);
    font-size: 14px;
}

.log-preview li:last-child {
    border-bottom: none;
}

.log-preview .cp-name {
    font-weight: 500;
}

.log-preview .cp-time {
    color: var(--text-dim);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.log-preview .cp-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.cp-status.pass {
    background: rgba(0, 184, 148, 0.2);
    color: var(--accent-green);
}

.cp-status.fail {
    background: rgba(233, 69, 96, 0.2);
    color: var(--accent);
}

.log-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
    font-size: 14px;
}

/* Scanner */
.scanner-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#qr-reader {
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius);
    overflow: hidden;
}

#qr-reader video {
    border-radius: var(--radius);
}

.scanner-status {
    margin-top: 16px;
    color: var(--text-dim);
    font-size: 14px;
    text-align: center;
}

/* Admin Panel */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

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

.tab-content { display: block; }
.tab-content.hidden { display: none; }

/* Item Lists (employees, checkpoints) */
.item-list {
    margin-bottom: 20px;
}

.item-card {
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-card .item-info {
    flex: 1;
}

.item-card .item-name {
    font-weight: 600;
    font-size: 15px;
}

.item-card .item-detail {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}

.item-card .item-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: none;
    border: 1px solid var(--text-muted);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon.danger {
    border-color: var(--accent);
    color: var(--accent);
}

/* Add Form */
.add-form {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 8px;
}

.add-form h4 {
    margin-bottom: 16px;
    font-size: 16px;
}

/* GPS Capture */
.gps-capture {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.gps-capture .btn {
    width: auto;
    padding: 10px 16px;
    font-size: 14px;
    white-space: nowrap;
}

#gps-status {
    font-size: 12px;
    color: var(--text-dim);
}

/* QR Output */
.qr-output {
    margin-top: 16px;
}

.qr-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    text-align: center;
}

.qr-card canvas {
    max-width: 200px;
}

.qr-card .qr-label {
    color: #333;
    font-weight: 600;
    margin-top: 8px;
    font-size: 14px;
}

.qr-card .qr-id {
    color: #666;
    font-size: 12px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.modal-content h3 {
    margin-bottom: 8px;
}

.modal-content p {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 16px;
}

#shift-summary {
    background: var(--bg-input);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.8;
}

.modal-actions {
    display: flex;
    gap: 8px;
}

.modal-actions .btn {
    flex: 1;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text);
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    z-index: 200;
    transition: opacity 0.3s;
    max-width: 90%;
    text-align: center;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}

.toast.success { border-left: 4px solid var(--accent-green); }
.toast.error { border-left: 4px solid var(--accent); }
.toast.warning { border-left: 4px solid var(--accent-yellow); }

/* Utility */
hr {
    border: none;
    border-top: 1px solid var(--text-muted);
    margin: 24px 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

/* PWA install prompt override */
@media (display-mode: standalone) {
    .topbar { padding-top: env(safe-area-inset-top, 16px); }
}
