:root {
    --bg: #020b07;
    --surface: #07130d;
    --surface-2: #0b1811;
    --line: #124c2f;
    --line-soft: rgba(48, 174, 102, .24);
    --text: #f6fff8;
    --muted: #83a391;
    --green: #72f5a1;
    --lime: #d8ef77;
    --gold: #f6d56b;
    --danger: #ff7a7a;
    --shadow: 0 20px 70px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 0 0, rgba(0, 92, 48, .23), transparent 29rem),
        radial-gradient(circle at 100% 0, rgba(161, 157, 54, .12), transparent 30rem),
        var(--bg);
    font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
form { margin: 0; }

.topbar {
    width: min(1400px, calc(100% - 40px));
    margin: 28px auto 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.brand-logo {
    display: block;
    width: auto;
    height: 56px;
    max-width: min(280px, 48vw);
    object-fit: contain;
    object-position: left center;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .22));
}
.brand-logo-login {
    height: auto;
    max-height: 78px;
    max-width: min(320px, 100%);
}
.brand-mark {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    color: #06210f;
    font-size: 18px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--gold), var(--green));
    box-shadow: inset 0 1px rgba(255,255,255,.5);
}
.brand strong { display: block; font-size: 18px; }
.brand small { color: var(--muted); display: block; }
.top-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status-dot, .user-pill {
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    padding: 8px 13px;
    color: var(--green);
    background: rgba(0,0,0,.15);
}
.user-pill { color: var(--text); }

.page-shell { width: min(1400px, calc(100% - 40px)); margin: 0 auto 40px; }
.panel {
    border: 1px solid var(--line);
    background: linear-gradient(145deg, rgba(9, 23, 15, .96), rgba(3, 13, 8, .98));
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.toolbar {
    min-height: 64px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}
.breadcrumbs, .toolbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.breadcrumbs span { color: var(--muted); }
.toolbar-actions small { color: var(--muted); }

.btn, .mini-btn {
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 12px;
    padding: 10px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    font-weight: 800;
    transition: .2s ease;
}
.btn:hover, .mini-btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn-primary { color: #082412; background: linear-gradient(90deg, var(--gold), var(--green)); }
.btn-dark { color: var(--text); background: rgba(255,255,255,.055); }
.btn-wide { width: 100%; }
button:disabled { opacity: .42; cursor: not-allowed; transform: none !important; }

.alert { margin-top: 16px; padding: 14px 18px; border-radius: 14px; border: 1px solid; }
.alert-success { background: rgba(50,190,106,.13); border-color: rgba(77,230,132,.35); color: #a8ffc6; }
.alert-error { background: rgba(255,90,90,.11); border-color: rgba(255,110,110,.38); color: #ffb3b3; }
.alert-warning { background: rgba(255,198,76,.12); border-color: rgba(255,198,76,.38); color: #ffe19e; }

.dashboard-grid {
    margin-top: 18px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.folders-panel, .upload-panel, .contents-panel, .api-panel { padding: 20px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin-bottom: 18px; }
h1, h2, p { margin-top: 0; }
h2 { margin-bottom: 3px; font-size: 20px; }
.section-heading p, .modal-card p, .muted { color: var(--muted); margin-bottom: 0; }
.count-pill { color: var(--green); border: 1px solid var(--line-soft); border-radius: 999px; padding: 7px 12px; }

.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.folder-card {
    border: 1px solid rgba(255,255,255,.09);
    background: rgba(255,255,255,.025);
    border-radius: 18px;
    padding: 15px;
    min-height: 155px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.folder-card.is-active { border-color: var(--green); box-shadow: inset 0 0 0 1px rgba(114,245,161,.15); }
.folder-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 15px; background: #183044; font-size: 24px; margin-bottom: 12px; }
.folder-card small { color: var(--muted); margin: 6px 0 12px; }
.folder-actions { margin-top: auto; display: flex; gap: 7px; flex-wrap: wrap; }
.mini-btn { padding: 7px 10px; border-radius: 8px; color: var(--text); background: rgba(255,255,255,.04); font-size: 12px; }
.mini-btn.danger { color: #ffb1b1; }

.selected-folder {
    min-height: 58px;
    border: 1px solid var(--line);
    background: rgba(33, 106, 62, .14);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
}
.selected-folder span { display: grid; }
.selected-folder small { color: var(--green); }
.selected-folder b { font-size: 12px; }

.drop-zone {
    min-height: 385px;
    border: 1px dashed var(--line);
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 30px;
    cursor: pointer;
    background: rgba(1, 11, 6, .36);
    transition: .2s ease;
}
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--green); background: rgba(28,117,63,.14); }
.drop-zone.disabled { opacity: .5; cursor: not-allowed; }
.drop-zone input { display: none; }
.upload-icon { width: 76px; height: 76px; display: grid; place-items: center; border-radius: 24px; background: rgba(88,130,78,.2); color: var(--green); font-size: 38px; }
.drop-zone > strong { font-size: 22px; }
.drop-zone > small { color: var(--muted); }
.fake-btn { margin-top: 5px; }
.file-summary { color: var(--gold); min-height: 20px; font-weight: 700; }
.upload-submit { margin-top: 12px; }

.contents-panel { margin-top: 18px; }
.empty { min-height: 100px; border: 1px dashed var(--line); border-radius: 16px; display: grid; place-items: center; color: #80c29d; text-align: center; padding: 20px; }
.empty.compact { min-height: 150px; grid-column: 1 / -1; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.image-card { border: 1px solid rgba(255,255,255,.09); border-radius: 17px; overflow: hidden; background: rgba(255,255,255,.025); }
.preview-link { height: 170px; display: block; background: #020804; }
.preview-link img { width: 100%; height: 100%; object-fit: contain; display: block; }
.image-meta { padding: 12px 13px 7px; display: grid; }
.image-meta strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.image-meta small { color: var(--muted); }
.image-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 7px 13px 13px; }

.api-panel { margin-top: 18px; display: grid; grid-template-columns: 1fr minmax(250px, 2fr) auto; align-items: center; gap: 15px; }
.api-panel p { color: var(--muted); margin: 0; }
.api-panel code { background: #010904; border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: #b7ffcb; overflow: auto; }

.modal { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 20px; background: rgba(0,0,0,.72); backdrop-filter: blur(10px); }
.modal.is-open { display: grid; }
.modal-card { width: min(440px, 100%); position: relative; border: 1px solid var(--line); border-radius: 22px; padding: 24px; background: #07130d; box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 12px; right: 14px; border: 0; background: transparent; color: var(--text); font-size: 28px; cursor: pointer; }
label { display: grid; gap: 7px; font-weight: 700; margin: 17px 0; }
input[type="text"], input[type="password"] { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #020a06; color: var(--text); padding: 13px 14px; outline: none; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(114,245,161,.1); }

.login-page { display: grid; place-items: center; }
.login-shell { width: min(440px, calc(100% - 32px)); }
.login-card { border: 1px solid var(--line); border-radius: 26px; background: rgba(7,19,13,.96); padding: 30px; box-shadow: var(--shadow); }
.brand-login { margin-bottom: 25px; }
.login-card h1 { margin-bottom: 5px; }
.login-form { margin-top: 24px; }

@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .api-panel { grid-template-columns: 1fr; }
    .topbar, .toolbar { align-items: flex-start; }
    .topbar, .toolbar { flex-direction: column; }
    .toolbar-actions { width: 100%; }
}

@media (max-width: 600px) {
    .topbar, .page-shell { width: min(100% - 22px, 1400px); }
    .top-actions { width: 100%; }
    .folders-panel, .upload-panel, .contents-panel, .api-panel { padding: 15px; }
    .drop-zone { min-height: 300px; }
    .folder-grid, .image-grid { grid-template-columns: 1fr; }
}

.status-ready { color: var(--green); }
.status-warning { color: var(--gold); border-color: rgba(246, 213, 107, .35); }

.diagnostics-panel, .setup-panel { padding: 22px; }
.setup-panel { margin-top: 18px; }
.diagnostic-summary {
    display: grid;
    gap: 4px;
    border: 1px solid;
    border-radius: 16px;
    padding: 15px 17px;
    margin-bottom: 18px;
}
.diagnostic-summary.is-ok {
    color: #b6ffcd;
    border-color: rgba(114,245,161,.35);
    background: rgba(50,190,106,.12);
}
.diagnostic-summary.is-warning {
    color: #ffe19e;
    border-color: rgba(255,198,76,.38);
    background: rgba(255,198,76,.1);
}
.diagnostic-summary span { color: var(--muted); }
.check-table { display: grid; gap: 10px; }
.check-row {
    display: grid;
    grid-template-columns: 38px minmax(190px, 1fr) minmax(190px, 1fr);
    gap: 12px;
    align-items: center;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    padding: 12px;
    background: rgba(255,255,255,.025);
}
.check-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 900;
}
.check-icon.ok { color: #07190d; background: var(--green); }
.check-icon.bad { color: #271506; background: var(--gold); }
.check-main { display: grid; }
.check-main small { color: var(--muted); }
.check-row code, .setup-panel code { color: #b7ffcb; }
.check-row > code {
    overflow-wrap: anywhere;
    background: #010904;
    border: 1px solid var(--line-soft);
    border-radius: 9px;
    padding: 8px 10px;
}
.setup-panel pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #c6ffd5;
    background: #010904;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 15px;
    overflow: auto;
}

@media (max-width: 760px) {
    .check-row { grid-template-columns: 38px 1fr; }
    .check-row > code { grid-column: 1 / -1; }
}

/* User management */
.users-panel { margin-top: 18px; padding: 22px; }
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.user-card {
    min-height: 142px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    align-items: start;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 18px;
    padding: 16px;
    background: rgba(255,255,255,.025);
}
.user-card.is-current {
    border-color: var(--green);
    box-shadow: inset 0 0 0 1px rgba(114,245,161,.14);
}
.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    color: #082412;
    font-size: 20px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--gold), var(--green));
}
.user-card-main { min-width: 0; display: grid; gap: 5px; }
.user-card-main small { color: var(--muted); }
.user-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.user-title-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.role-pill {
    flex: 0 0 auto;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .05em;
    border: 1px solid var(--line-soft);
}
.role-admin { color: #172008; background: linear-gradient(90deg, var(--gold), var(--lime)); }
.role-user { color: var(--green); background: rgba(31,124,67,.14); }
.user-card-actions { grid-column: 1 / -1; margin-top: auto; display: flex; justify-content: flex-end; }
.disabled-control { opacity: .55; cursor: default; pointer-events: none; }
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #020a06;
    color: var(--text);
    padding: 13px 14px;
    outline: none;
}
select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(114,245,161,.1); }

@media (max-width: 600px) {
    .users-panel { padding: 15px; }
    .user-grid { grid-template-columns: 1fr; }
}


@media (max-width: 680px) {
    .brand-logo {
        height: 46px;
        max-width: 210px;
    }
    .brand-logo-login {
        height: auto;
        max-height: 70px;
        max-width: 100%;
    }
}
