:root {
    --bg: #eef1f2;
    --panel: #ffffff;
    --ink: #193139;
    --line: #d7dfe2;
    --accent: #2f7f91;
    --error: #bc4343;
    --ok: #2b8b5b;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Trebuchet MS', Verdana, sans-serif; color: var(--ink); background: var(--bg); }

.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; transition: grid-template-columns .2s ease; }
.admin-shell.sidebar-collapsed { grid-template-columns: 82px 1fr; }
.sidebar { background: #13303a; color: #fff; padding: 1rem .75rem; display: flex; flex-direction: column; gap: .55rem; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .35rem; }
.sidebar h2 { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: .45rem; }
.sidebar-toggle {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.22);
    background: rgba(255,255,255,.12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.sidebar a { color: #dce8ed; text-decoration: none; padding: .52rem .58rem; border-radius: 8px; display: flex; align-items: center; gap: .6rem; }
.sidebar a:hover { background: rgba(255,255,255,.12); }
.sidebar i { width: 16px; text-align: center; }
.nav-text { white-space: nowrap; }
.admin-shell.sidebar-collapsed .nav-text { display: none; }
.admin-shell.sidebar-collapsed .sidebar { align-items: center; padding: 1rem .45rem; }
.admin-shell.sidebar-collapsed .sidebar-head { width: 100%; justify-content: center; }
.admin-shell.sidebar-collapsed .sidebar h2 { justify-content: center; }
.admin-shell.sidebar-collapsed .sidebar a { justify-content: center; width: 40px; height: 40px; padding: 0; }
.admin-shell.sidebar-collapsed .sidebar-toggle i { transform: rotate(180deg); }
.content { padding: 1.5rem; }

h1 { margin-top: 0; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.btn, button { border: 0; background: var(--accent); color: #fff; padding: .6rem .9rem; border-radius: 10px; text-decoration: none; cursor: pointer; }
.btn-secondary { background: #5c6f75; }
.form-grid { display: grid; gap: .45rem; max-width: 760px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1rem; }
input, select, textarea { padding: .65rem .7rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.file-input { display: none; }
.dropzone {
    border: 2px dashed #98b5bd;
    border-radius: 12px;
    padding: 1rem;
    background: #f8fbfc;
    cursor: pointer;
    display: grid;
    gap: .2rem;
}
.dropzone strong { font-size: .96rem; }
.dropzone span { color: #4f6369; font-size: .9rem; }
.dropzone-name { color: #2f7f91; font-style: normal; font-size: .88rem; }
.dropzone.dragging { border-color: var(--accent); background: #eef8fb; }
.dropzone-preview {
    max-width: 180px;
    max-height: 180px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    padding: 4px;
    object-fit: contain;
}
.dropzone-preview.is-hidden { display: none; }
.dropzone-preview-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .5rem;
}
.dropzone-preview-thumb {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}
.html-editor {
    display: grid;
    gap: .6rem;
}
.html-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}
.html-editor-toolbar .btn {
    padding: .48rem .72rem;
    border-radius: 9px;
}
.html-editor-preview {
    min-height: 160px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    padding: .9rem;
}
.html-editor-preview.is-hidden {
    display: none;
}
.html-editor-preview h1,
.html-editor-preview h2,
.html-editor-preview h3,
.html-editor-preview h4 {
    margin-top: 0;
}
.html-editor-preview img,
.html-editor-preview video,
.html-editor-preview iframe {
    max-width: 100%;
    height: auto;
}
.html-editor-preview table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}
.html-editor-preview pre {
    overflow-x: auto;
    background: #eef3f5;
    border-radius: 10px;
    padding: .75rem;
}
.existing-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: .7rem;
}
.existing-gallery-item {
    display: grid;
    gap: .4rem;
    align-items: start;
    background: #f7fafb;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: .45rem;
}
.existing-gallery-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
}
.existing-gallery-item span {
    font-size: .85rem;
    display: flex;
    align-items: center;
    gap: .3rem;
}
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 12px; overflow: hidden; }
th, td { padding: .7rem; border-bottom: 1px solid var(--line); text-align: left; }
tbody tr:nth-child(even) { background: #f7fafb; }
tbody tr:hover { background: #eaf3f6; transition: background-color .15s ease; }
.action-cell {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
.action-icon {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #204650;
    text-decoration: none;
    padding: 0;
    cursor: pointer;
    font-size: 13px;
}
.action-icon i {
    font-size: 13px;
    line-height: 1;
}
.action-icon:hover { background: #eef6f8; border-color: #b8cfd5; }
.action-delete { color: #b43c3c; }
.action-delete:hover { background: #faecec; border-color: #e7bbbb; }
.action-disabled {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
}
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(12, 28, 33, .48);
    display: grid;
    place-items: center;
    padding: 1rem;
    z-index: 2000;
}
.modal-backdrop.is-hidden { display: none; }
.modal-card {
    width: min(560px, 100%);
    background: #fff;
    border-radius: 14px;
    border: 1px solid var(--line);
    padding: 1rem;
    position: relative;
}
.modal-card h3 { margin-top: 0; margin-bottom: .9rem; }
.modal-close {
    position: absolute;
    top: .6rem;
    right: .6rem;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: #30484f;
    padding: 0;
}
.modal-form { border: 0; padding: 0; max-width: 100%; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .55rem;
    margin-top: .35rem;
}

.flash { margin-bottom: .8rem; padding: .7rem .8rem; border-radius: 10px; color: #fff; }
.flash.success { background: var(--ok); }
.flash.error { background: var(--error); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.stats-grid article { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 20%, rgba(47, 127, 145, .18), transparent 34%),
        radial-gradient(circle at 80% 0%, rgba(19, 48, 58, .26), transparent 28%),
        linear-gradient(140deg, #d9e4e7, #eef1f2 45%, #d3dde0);
}
.login-slideshow {
    position: absolute;
    inset: 0;
}
.login-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: scale(1.06);
    animation-name: login-fade-slide;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    will-change: opacity, transform;
}
.login-slide-blur,
.login-slide-image {
    position: absolute;
    inset: 0;
    background-position: center;
    background-repeat: no-repeat;
}
.login-slide-blur {
    background-size: cover;
    filter: blur(24px) saturate(110%);
    transform: scale(1.12);
    opacity: .9;
}
.login-slide-image {
    background-size: contain;
}
.login-overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(15, 31, 36, .44), rgba(15, 31, 36, .18)),
        radial-gradient(circle at center, rgba(255, 255, 255, .08), rgba(255, 255, 255, 0));
}
.login-card {
    position: relative;
    z-index: 1;
    width: min(440px, 92%);
    background: rgba(255, 255, 255, .62);
    border: 1px solid rgba(255,255,255,.38);
    border-radius: 20px;
    padding: 1.3rem;
    box-shadow: 0 24px 48px rgba(0,0,0,.14);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    cursor: grab;
    touch-action: none;
}
.login-card.dragging { cursor: grabbing; }
.login-card form { display: grid; gap: .55rem; }
.login-card > a { color: var(--accent); text-decoration: none; }
.login-card > a:hover { text-decoration: underline; }
.hint { color: #5a6d74; font-size: .9rem; }
.password-field {
    position: relative;
    display: flex;
    align-items: center;
}
.password-field input {
    width: 100%;
    padding-right: 3rem;
}
.password-toggle {
    position: absolute;
    right: .45rem;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: #45626b;
    padding: 0;
}
.password-toggle:hover {
    background: #eef6f8;
    color: #183640;
}
.inline-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-top: .5rem;
}

@keyframes login-fade-slide {
    0% { opacity: 0; transform: scale(1.08); }
    14% { opacity: 1; transform: scale(1.03); }
    52% { opacity: 1; transform: scale(1); }
    72% { opacity: 0; transform: scale(1.02); }
    100% { opacity: 0; transform: scale(1.08); }
}

@media (max-width: 900px) {
    .admin-shell, .admin-shell.sidebar-collapsed { grid-template-columns: 1fr; }
    .sidebar { flex-direction: row; flex-wrap: wrap; }
    .sidebar .nav-text { display: inline; }
    .sidebar a { width: auto; height: auto; padding: .5rem .6rem; }
    .sidebar-head { width: 100%; }
    .stats-grid { grid-template-columns: 1fr; }
    .login-card {
        width: min(420px, calc(100% - 1.4rem));
        padding: 1.1rem;
    }
}
