:root {
    --admin-primary: #1e3a8a;
    --admin-primary-deep: #0f2460;
    --admin-accent: #f59e0b;
    --admin-bg: #f1f5f9;
    --admin-card: #ffffff;
    --admin-text: #334155;
    --admin-muted: #64748b;
    --admin-danger: #ef4444;
    --admin-success: #10b981;
    --admin-radius: 12px;
    --admin-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --admin-header-h: 56px;
    --admin-tabbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.admin-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--admin-bg);
    color: var(--admin-text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

/* Header */
.admin-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--admin-primary);
    color: white;
    box-shadow: var(--admin-shadow);
}

.admin-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.admin-header h1 {
    font-size: 1.1rem;
    font-weight: 700;
}

.admin-header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Main */
.admin-main {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 2rem;
}

.has-tabbar .admin-main {
    padding-bottom: calc(var(--admin-tabbar-h) + 1.5rem + env(safe-area-inset-bottom, 0px));
}

/* Cards */
.admin-card {
    background: var(--admin-card);
    border-radius: var(--admin-radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--admin-shadow);
}

.admin-card h2 {
    font-size: 1rem;
    color: var(--admin-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    background: var(--admin-primary);
    color: white;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-weight: 600;
}

/* Forms */
.admin-form .form-group {
    margin-bottom: 0.85rem;
}

.admin-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--admin-muted);
}

.admin-form input,
.admin-form select,
.admin-form textarea {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
    outline: none;
    border-color: var(--admin-primary);
}

.form-row {
    display: flex;
    gap: 0.75rem;
}

.flex-1 { flex: 1; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
    touch-action: manipulation;
}

.btn-primary {
    background: var(--admin-primary);
    color: white;
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 1.5px solid rgba(255,255,255,0.4);
}

.btn-accent {
    background: var(--admin-accent);
    color: #1e293b;
    border: none;
    font-weight: 600;
}

.btn-accent:active {
    filter: brightness(0.95);
}

.admin-header-actions .btn-label {
    margin-left: 0.2rem;
}

@media (max-width: 480px) {
    .admin-header-actions .btn-label {
        display: none;
    }
}

.btn-sm {
    padding: 0.45rem 0.7rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    color: var(--admin-muted);
    font-size: 0.9rem;
    touch-action: manipulation;
}

.btn-icon:active {
    background: #f1f5f9;
}

.btn-delete-project {
    color: var(--admin-danger);
}

/* Login / Setup */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.25rem;
    background:
        radial-gradient(ellipse 80% 50% at 10% 0%, rgba(245, 158, 11, 0.18), transparent 55%),
        radial-gradient(ellipse 70% 45% at 100% 100%, rgba(30, 58, 138, 0.22), transparent 50%),
        linear-gradient(165deg, #e8eef8 0%, #f1f5f9 45%, #e2e8f0 100%);
}

.login-shell {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--admin-card);
    border-radius: 16px;
    padding: 2rem 1.5rem 1.75rem;
    width: 100%;
    box-shadow: 0 8px 32px rgba(15, 36, 96, 0.12);
    text-align: center;
    border: 1px solid rgba(30, 58, 138, 0.08);
}

.login-brand {
    margin-bottom: 1.5rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(145deg, var(--admin-primary) 0%, var(--admin-primary-deep) 100%);
    color: white;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
    box-shadow: 0 4px 14px rgba(30, 58, 138, 0.35);
}

.login-company {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--admin-accent);
    margin-bottom: 0.35rem;
}

.login-card h1 {
    font-size: 1.45rem;
    color: var(--admin-primary);
    margin-bottom: 0.35rem;
    font-weight: 700;
}

.login-subtitle {
    color: var(--admin-muted);
    font-size: 0.92rem;
    margin-bottom: 0;
    line-height: 1.45;
}

.login-form {
    text-align: left;
    margin-top: 0.25rem;
}

.login-form .btn-block {
    margin-top: 0.35rem;
}

.login-form .form-group {
    margin-bottom: 1rem;
}

.login-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--admin-muted);
}

.login-form input {
    width: 100%;
    padding: 0.85rem 0.9rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    background: #f8fafc;
    transition: border-color 0.2s, background 0.2s;
    -webkit-appearance: none;
    color: var(--admin-text);
}

.login-form input:focus {
    outline: none;
    border-color: var(--admin-primary);
    background: white;
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--admin-muted);
    pointer-events: none;
}

.input-with-icon input {
    padding-left: 2.65rem;
}

.login-foot {
    text-align: center;
    margin-top: 1.25rem;
}

.login-foot a {
    color: var(--admin-primary);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

.login-foot a:hover {
    text-decoration: underline;
}

/* Dashboard home */
.dash-intro {
    margin-bottom: 1.25rem;
}

.dash-brand {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--admin-accent);
    margin-bottom: 0.35rem;
}

.dash-heading {
    font-size: 1.35rem;
    color: var(--admin-primary);
    margin-bottom: 0.4rem;
}

.dash-sub {
    color: var(--admin-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.dash-grid {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.dash-tile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.1rem;
    background: var(--admin-card);
    border-radius: var(--admin-radius);
    box-shadow: var(--admin-shadow);
    text-decoration: none;
    color: inherit;
    border: 1.5px solid transparent;
    transition: border-color 0.2s, transform 0.15s;
    touch-action: manipulation;
}

.dash-tile:active {
    transform: scale(0.98);
}

.dash-tile:hover {
    border-color: rgba(30, 58, 138, 0.25);
}

.dash-tile-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--admin-primary), var(--admin-primary-deep));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.dash-tile-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.dash-tile-body strong {
    font-size: 1.05rem;
    color: var(--admin-primary);
}

.dash-tile-body span {
    font-size: 0.85rem;
    color: var(--admin-muted);
}

.dash-tile-arrow {
    color: var(--admin-muted);
    font-size: 0.85rem;
}

/* Bottom tab bar — solo mobile */
.admin-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    display: none;
    align-items: stretch;
    justify-content: space-around;
    height: calc(var(--admin-tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--admin-card);
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
}

@media (max-width: 768px) {
    .admin-tabbar {
        display: flex;
    }
}

@media (min-width: 769px) {
    .has-tabbar .admin-main {
        padding-bottom: 1.5rem;
    }
}

.admin-tabbar .tab,
.admin-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.4rem 0.35rem;
    color: var(--admin-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    max-width: 120px;
}

.admin-tabbar .tab i,
.admin-tab i {
    font-size: 1.2rem;
}

.admin-tabbar .tab.active,
.admin-tab.active {
    color: var(--admin-primary);
}

.admin-tabbar .tab.active i,
.admin-tab.active i {
    transform: translateY(-1px);
}

.thumbs-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.thumb-wrap {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #f1f5f9;
}

.thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb-wrap .btn-icon {
    position: absolute;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb-wrap .btn-del-img { top: 4px; right: 4px; z-index: 3; }

.thumb-wrap.is-cover {
    outline: 2px solid #f59e0b;
    outline-offset: 1px;
}

.cover-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 2;
    max-width: calc(100% - 8px);
    background: #f59e0b;
    color: #111;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 0.18rem 0.4rem;
    border-radius: 999px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thumb-tools .btn-cover {
    color: #fbbf24;
}

.thumb-tools {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.25rem;
    background: linear-gradient(transparent, rgba(15, 23, 42, 0.75));
}

.thumb-tools .btn-icon {
    position: static;
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
}

.thumb-wrap.dragging {
    opacity: 0.45;
}

.cat-toolbar,
.toolbar-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.toolbar-actions {
    flex-shrink: 0;
    align-items: center;
}

.edit-cat-form,
.edit-proj-form {
    margin-bottom: 1rem;
    padding: 0.85rem;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.form-hint {
    font-size: 0.85rem;
    color: var(--admin-muted);
    margin: 0 0 0.75rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert[hidden] {
    display: none !important;
}

.alert-error {
    background: #fef2f2;
    color: var(--admin-danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #ecfdf5;
    color: var(--admin-success);
    border: 1px solid #a7f3d0;
}

/* Project cards */
.project-card {
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.85rem;
}

.project-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.project-info h3 {
    font-size: 0.95rem;
    color: var(--admin-primary);
}

.photo-count {
    font-size: 0.8rem;
    color: var(--admin-muted);
}

/* Upload zone */
.upload-zone {
    position: relative;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.upload-zone:active,
.upload-zone.dragover {
    border-color: var(--admin-primary);
    background: #eff6ff;
}

.upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.upload-placeholder {
    color: var(--admin-muted);
    pointer-events: none;
}

.upload-placeholder i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.35rem;
    color: var(--admin-primary);
}

.upload-placeholder span {
    font-size: 0.85rem;
}

.upload-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
}

.upload-actions .btn {
    min-width: 9rem;
}

.upload-zone {
    cursor: default;
}

.upload-zone .upload-input {
    pointer-events: none;
}

.upload-progress {
    pointer-events: none;
}

.progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--admin-primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--admin-muted);
}

/* Photo grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #f1f5f9;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-item.dragging {
    opacity: 0.5;
}

.cover-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--admin-accent);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    z-index: 2;
}

.photo-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    opacity: 0;
    transition: opacity 0.2s;
}

.photo-item:active .photo-actions,
.photo-item:hover .photo-actions {
    opacity: 1;
}

.photo-actions .btn-icon {
    color: white;
    background: rgba(0,0,0,0.3);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.empty-state {
    color: var(--admin-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
}

.admin-notice {
    border-left: 4px solid var(--admin-accent);
    background: #fffbeb;
}

.admin-notice p {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.notice-small {
    font-size: 0.8rem !important;
    color: var(--admin-muted);
    margin-bottom: 0 !important;
}

.admin-help {
    background: #f0f9ff;
    border-left: 4px solid var(--admin-primary);
}

.help-steps {
    padding-left: 1.25rem;
    font-size: 0.9rem;
    line-height: 1.7;
}

.help-steps li {
    margin-bottom: 0.35rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: calc(var(--admin-tabbar-h) + 1rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    font-size: 0.9rem;
    z-index: 1000;
    transition: transform 0.3s ease;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    background: var(--admin-danger);
}

.toast.success {
    background: var(--admin-success);
}

@media (min-width: 480px) {
    .photo-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 768px) {
    .admin-header h1 { font-size: 1.25rem; }
    .photo-grid { grid-template-columns: repeat(5, 1fr); }
}
