:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --ink: #15202b;
    --muted: #5b6b7c;
    --line: #d7dee7;
    --accent: #0b6e4f;
    --accent-ink: #ffffff;
    --danger: #b42318;
    --success: #067647;
    --shadow: 0 10px 30px rgba(21, 32, 43, 0.08);
    --radius: 14px;
    --font: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(11, 110, 79, 0.12), transparent 35%),
        linear-gradient(180deg, #eef3f7 0%, var(--bg) 45%, #e8eef3 100%);
    min-height: 100vh;
}

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

.shell {
    width: min(1100px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 3rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    color: var(--ink);
    text-decoration: none;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.card-narrow {
    width: min(420px, 100%);
    margin: 4rem auto 0;
}

h1, h2 {
    margin: 0 0 0.75rem;
    letter-spacing: -0.02em;
}

.muted { color: var(--muted); }

.flash {
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.flash-success {
    background: #ecfdf3;
    color: var(--success);
    border-color: #abefc6;
}

.flash-error {
    background: #fef3f2;
    color: var(--danger);
    border-color: #fecdca;
}

.form-grid {
    display: grid;
    gap: 0.9rem;
}

label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.92rem;
    font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    font: inherit;
    background: #fff;
}

input:focus {
    outline: 2px solid rgba(11, 110, 79, 0.25);
    border-color: var(--accent);
}

.btn,
button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 0;
    border-radius: 10px;
    padding: 0.65rem 1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    background: var(--accent);
    color: var(--accent-ink);
    text-decoration: none;
}

.btn:hover { filter: brightness(1.05); text-decoration: none; }

.btn-secondary {
    background: #e8eef3;
    color: var(--ink);
}

.btn-small {
    padding: 0.4rem 0.7rem;
    font-size: 0.88rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    min-width: min(100%, 280px);
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.breadcrumbs a { color: var(--muted); }
.breadcrumbs span { color: var(--ink); font-weight: 600; }

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.85rem 0.5rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.row-name {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 600;
    color: var(--ink);
}

.icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: inline-grid;
    place-items: center;
    background: #eef6f2;
    color: var(--accent);
    font-size: 0.85rem;
    flex: 0 0 auto;
}

.icon.file { background: #eef2f7; color: #345; }

.empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--muted);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.inline-form { display: inline; }

.login-hero {
    text-align: center;
    margin-bottom: 1.25rem;
}

.login-hero p {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0 0 1rem;
}

.stats-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.85rem 0.95rem;
    background: linear-gradient(180deg, #fbfcfd 0%, #f3f7f5 100%);
}

.stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
}

.stat-value {
    margin-top: 0.25rem;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-meta {
    margin-top: 0.2rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.controls-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
}

.chip:hover { text-decoration: none; color: var(--ink); }
.chip.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.sort-form label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.9rem;
}

.sort-form select {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.45rem 0.7rem;
    font: inherit;
    background: #fff;
    color: var(--ink);
}

.type-pill {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    background: #eef2f7;
    color: #445;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.path-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
}

.path-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.recent-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.65rem 0.8rem;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: #f8fafb;
}

.recent-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    flex: 0 0 auto;
}

.recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-width: 0;
}

.recent-item {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.3rem 0.55rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 0.85rem;
    text-decoration: none;
}

.recent-item:hover { border-color: var(--accent); text-decoration: none; }

.copy-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    border-radius: 6px;
    padding: 0.15rem 0.4rem;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
}

.copy-btn:hover { color: var(--ink); }

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.85rem;
}

.file-tile {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.7rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

.tile-thumb {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    background: #eef2f7;
    color: #345;
    font-weight: 700;
    text-decoration: none;
}

.tile-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.folder-thumb { background: #eef6f2; color: var(--accent); }
.file-thumb { background: #eef2f7; }

.tile-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile-meta {
    color: var(--muted);
    font-size: 0.8rem;
}

.tile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: auto;
}

.pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.pager-status {
    color: var(--muted);
    font-weight: 600;
}

.preview-card .toolbar { margin-bottom: 1rem; }

.preview-stage {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #0f141a;
    min-height: 60vh;
    display: grid;
    place-items: center;
    overflow: auto;
}

.preview-image {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
}

.preview-frame {
    width: 100%;
    height: 75vh;
    border: 0;
    background: #fff;
}

.preview-frame-text {
    background: #fff;
}

.version-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fafb;
}

.version-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-width: 0;
}

tr.is-current-version td {
    background: #f3faf6;
}

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    th:nth-child(3), td:nth-child(3),
    th:nth-child(2), td:nth-child(2) { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
    .controls-bar { align-items: stretch; flex-direction: column; }
    .path-row { align-items: flex-start; flex-direction: column; }
    .recent-bar { align-items: flex-start; flex-direction: column; }
}


/* Admin: users */
.btn-danger { background: #fef3f2; color: var(--danger); }

.admin-form { max-width: 720px; }

select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    font: inherit;
    background: #fff;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.folder-field {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1rem;
    margin: 0;
    display: grid;
    gap: 0.75rem;
}

.folder-field legend { font-weight: 700; padding: 0 0.35rem; }
.folder-field p { margin: 0; }

.folder-selected {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.folder-picker {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.75rem;
    background: #fafbfc;
    max-height: 360px;
    overflow-y: auto;
}

.folder-picker .breadcrumbs { margin-bottom: 0.5rem; }
.picker-status { margin-bottom: 0.5rem; }

.picker-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.picker-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.25rem;
    border-bottom: 1px solid var(--line);
}

.picker-list li:last-child { border-bottom: 0; }
