*,*::before,*::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f6f7f9;
    color: #1a1a1a;
    -webkit-font-smoothing: antialiased;
}
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: #1a1a1a; color: #fff;
    padding: 12px 16px;
    position: sticky; top: 0; z-index: 10;
}
.topbar .brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; }
.topbar .logout { color: #bbb; text-decoration: none; font-size: 14px; }
.topbar .logout:hover { color: #fff; }
.container { max-width: 760px; margin: 0 auto; padding: 16px; }

/* Flash banner */
.flash {
    background: #d4edda; color: #155724; border: 1px solid #c3e6cb;
    padding: 12px 16px; border-radius: 8px; margin-bottom: 16px;
}
.flash.error { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }

/* Login */
.login-card {
    max-width: 360px; margin: 60px auto; background: #fff;
    padding: 28px 24px; border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    text-align: center;
}
.login-card h1 { margin: 0 0 8px; font-size: 22px; }
.login-card p { color: #666; margin: 0 0 18px; font-size: 14px; }
.pin-input {
    font-size: 28px; letter-spacing: 12px; text-align: center;
    width: 200px; padding: 14px 0; border: 2px solid #ddd; border-radius: 8px;
    margin-bottom: 14px;
}
.pin-input:focus { outline: none; border-color: #2563eb; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 16px; font-weight: 600; padding: 12px 20px;
    border-radius: 8px; border: 0; cursor: pointer; text-decoration: none;
    background: #2563eb; color: #fff;
}
.btn:hover { background: #1d4fc8; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: #fff; color: #333; border: 1px solid #ddd; }
.btn-secondary:hover { background: #f0f0f0; }
.btn-danger { background: #dc3545; }
.btn-danger:hover { background: #c2293a; }

/* Upload */
.upload-card {
    background: #fff; padding: 22px; border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.04); margin-bottom: 18px;
    text-align: center;
}
.upload-card h2 { margin: 0 0 14px; font-size: 18px; }
.file-input { position: absolute; left: -9999px; }
.file-label {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 18px 20px; font-size: 18px; font-weight: 600;
    background: #2563eb; color: #fff; border-radius: 10px;
    cursor: pointer;
}
.file-label:hover { background: #1d4fc8; }
.file-chosen { margin: 10px 0 0; color: #666; font-size: 14px; }
.submit-row { margin-top: 14px; }

/* Recent grid */
.section-heading {
    font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
    color: #888; margin: 24px 0 10px;
}
.grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px;
}
.tile {
    position: relative; background: #fff; border-radius: 10px;
    overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    aspect-ratio: 1 / 1;
}
.tile a { display: block; width: 100%; height: 100%; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-pdf {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; background: #fdecec; color: #c2293a;
    font-weight: 700; font-size: 14px;
}
.tile-meta {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: #fff; font-size: 11px; padding: 14px 8px 6px; line-height: 1.2;
}
.tile-delete {
    position: absolute; top: 6px; right: 6px;
    background: rgba(0,0,0,0.6); color: #fff; border: 0;
    width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
    font-size: 14px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
}
.tile-delete:hover { background: rgba(220,53,69,0.95); }

/* Year action row */
.year-actions {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px;
}
.year-actions a {
    display: inline-flex; align-items: center; gap: 6px;
    background: #fff; border: 1px solid #ddd; padding: 8px 12px;
    border-radius: 8px; text-decoration: none; color: #333; font-size: 14px;
}
.year-actions a:hover { background: #f0f0f0; }
.empty {
    text-align: center; color: #888; padding: 30px 16px; font-size: 14px;
}
