:root {
    --bg: #0f0d0b;
    --surface: #1a1612;
    --surface2: #252019;
    --border: #3d3428;
    --gold: #c9a227;
    --gold-light: #e8c84a;
    --gold-dim: #8a7420;
    --text: #f5f0e6;
    --text-muted: #a89f8f;
    --danger: #c45c4a;
    --success: #5a9e6f;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --nav-h: 72px;
    --header-h: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
}

a { color: var(--gold-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 13, 11, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: var(--header-h);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px;
    height: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gold-light);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
}

.brand-icon { font-size: 1.2rem; }

/* Main */
.main-content {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
}

.page-title {
    margin: 0 0 4px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold-light);
}

.page-subtitle {
    margin: 0 0 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Bottom nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: calc(var(--nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(26, 22, 18, 0.96);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 4px 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    transition: color 0.15s;
}

.nav-item.active { color: var(--gold-light); }
.nav-icon { font-size: 1.35rem; line-height: 1; }

.nav-fab .nav-icon {
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    color: var(--bg);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    margin-top: -20px;
    box-shadow: var(--shadow);
}

.nav-fab.active .nav-icon {
    box-shadow: 0 0 0 3px var(--gold-dim);
}

/* Cards */
.card-grid {
    display: grid;
    gap: 12px;
}

.object-card {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.1s;
}

.object-card:active { transform: scale(0.98); }
.object-card:hover { border-color: var(--gold-dim); text-decoration: none; }

.object-card img,
.object-card .thumb-placeholder {
    width: 88px;
    height: 88px;
    border-radius: var(--radius);
    object-fit: cover;
    background: var(--surface2);
}

.thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--gold-dim);
}

.card-body h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.card-meta {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.card-meta strong { color: var(--gold); font-weight: 500; }

/* Forms */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gold);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    font-family: inherit;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
}

.form-group textarea { min-height: 80px; resize: vertical; }

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.2);
}

.form-hint {
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 400px) {
    .form-row { grid-template-columns: 1fr; }
}

/* Photo upload */
.photo-upload {
    text-align: center;
}

.photo-preview {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    border-radius: var(--radius);
    background: var(--surface2);
    margin-bottom: 12px;
    display: none;
}

.photo-preview.visible { display: block; }

.photo-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 140px;
    padding: 24px;
    background: var(--surface2);
    border: 2px dashed var(--gold-dim);
    border-radius: var(--radius-lg);
    color: var(--gold-light);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.photo-btn:active { background: var(--border); }
.photo-btn .icon { font-size: 2.5rem; }

input[type="file"].hidden-file {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    color: var(--bg);
    width: 100%;
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    width: 100%;
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    width: 100%;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 8px 12px;
}

.btn-sm { font-size: 0.85rem; padding: 8px 14px; }

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* Alerts */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error { background: rgba(196, 92, 74, 0.15); border: 1px solid var(--danger); color: #f0a89a; }
.alert-success { background: rgba(90, 158, 111, 0.15); border: 1px solid var(--success); color: #a8e0b8; }

/* Filters */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
    flex-shrink: 0;
    padding: 8px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
}

.filter-chip.active {
    background: var(--gold-dim);
    border-color: var(--gold);
    color: var(--gold-light);
}

/* Monthly */
.month-list { display: grid; gap: 10px; }

.month-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.month-card h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--gold-light);
}

.month-card p {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.month-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.month-actions .btn { width: auto; padding: 8px 12px; font-size: 0.8rem; }

/* Print view */
.print-sheet { background: #fff; color: #111; padding: 24px; border-radius: var(--radius); }
.print-sheet h1 { color: #8a7420; margin-top: 0; }
.print-grid { display: grid; gap: 16px; }
.print-item {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 12px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 12px;
}
.print-item img { width: 100px; height: 100px; object-fit: cover; border-radius: 8px; }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

.stats-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-box {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
}

.stat-box .value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold-light);
}

.stat-box .label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.site-footer {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Header utente */
.header-user {
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-badge {
    font-size: 0.8rem;
    color: var(--gold);
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Login PIN */
.login-wide { max-width: 400px; }

.user-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.user-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 8px;
    background: var(--surface2);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}

.user-chip input { position: absolute; opacity: 0; pointer-events: none; }

.user-chip span {
    font-weight: 600;
    color: var(--text);
}

.user-chip .user-role {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.user-chip:has(input:checked) {
    border-color: var(--gold);
    background: rgba(201, 162, 39, 0.12);
}

.pin-field {
    text-align: center;
    font-size: 1.5rem !important;
    letter-spacing: 0.4em;
    font-weight: 700;
}

.pin-display { font-family: monospace; }

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.pin-key {
    min-height: 52px;
    font-size: 1.25rem;
    font-weight: 600;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
}

.pin-key:active { background: var(--border); }
.pin-key-empty { visibility: hidden; pointer-events: none; }

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

/* Login */
.login-page {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at top, #2a2218 0%, var(--bg) 60%);
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0 0 8px;
    text-align: center;
    color: var(--gold-light);
    font-size: 1.4rem;
}

.login-card p {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 24px;
}

@media print {
    body { background: #fff; color: #000; padding: 0; }
    .site-header, .bottom-nav, .site-footer, .no-print { display: none !important; }
    .main-content { max-width: none; padding: 0; }
}
