:root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --text: #172033;
    --muted: #6d7688;
    --line: #e5e9f0;
    --accent: #2e63ff;
    --sidebar: #111827;
    --sidebar-muted: #9ca3af;
    --success: #16803c;
    --danger: #b42318;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 245px;
    background: var(--sidebar);
    color: white;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
}
.brand { display: flex; gap: 11px; align-items: center; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center;
    background: white; color: #111827; font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { color: var(--sidebar-muted); margin-top: 2px; font-size: 12px; }
.sidebar nav { margin-top: 32px; display: grid; gap: 7px; }
.sidebar nav a, .sidebar-bottom a {
    padding: 11px 13px; border-radius: 10px; color: #d7dce5;
}
.sidebar nav a:hover, .sidebar nav a.active { background: #202938; color: white; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid #2b3442; padding-top: 18px; display: grid; }
.sidebar-bottom span { font-weight: 700; padding: 0 13px; }
.sidebar-bottom small { color: var(--sidebar-muted); padding: 4px 13px 10px; }

.main { margin-left: 245px; min-width: 0; width: calc(100% - 245px); }
.topbar {
    height: 68px; background: rgba(255,255,255,.94);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 16px;
    padding: 0 28px; position: sticky; top: 0; z-index: 10;
    backdrop-filter: blur(12px);
}
.menu-button { display: none; border: 0; background: transparent; font-size: 23px; cursor: pointer; }
.status-pill {
    margin-left: auto; border: 1px solid var(--line); border-radius: 999px;
    padding: 7px 11px; color: var(--muted); font-size: 13px;
}
.status-pill span { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #22a45d; margin-right: 5px; }

.content { max-width: 1250px; margin: 0 auto; padding: 30px; }
.hero {
    display: flex; align-items: end; justify-content: space-between; gap: 24px;
    background: linear-gradient(120deg, #111827, #263757);
    color: white; border-radius: 22px; padding: 34px;
}
.hero h1 { margin: 4px 0 10px; font-size: clamp(28px, 4vw, 44px); }
.hero p:not(.eyebrow) { color: #d2d8e3; max-width: 660px; line-height: 1.6; }
.eyebrow { margin: 0; font-size: 12px; letter-spacing: .16em; font-weight: 800; color: #a9c2ff; }

.button {
    border: 0; border-radius: 11px; padding: 11px 16px; cursor: pointer;
    display: inline-flex; justify-content: center; align-items: center; font-weight: 700;
}
.button.primary { background: var(--accent); color: white; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 5px 20px rgba(22,32,51,.035); }
.stat { padding: 22px; }
.stat strong { display: block; font-size: 24px; }
.stat span { color: var(--muted); }

.section-title { display: flex; justify-content: space-between; align-items: end; margin: 30px 0 15px; gap: 16px; }
.section-title h1, .section-title h2 { margin: 0 0 5px; }
.section-title p { color: var(--muted); margin: 0; }

.app-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.app-card { padding: 20px; display: flex; gap: 15px; align-items: flex-start; }
.app-card h3 { margin: 2px 0 5px; }
.app-card p { margin: 0 0 9px; color: var(--muted); }
.app-icon {
    width: 45px; height: 45px; border-radius: 13px; flex: 0 0 auto;
    background: #edf2ff; color: var(--accent); display: grid; place-items: center; font-weight: 800;
}
.badge { background: #eaf7ef; color: var(--success); border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; }
.empty { padding: 28px; grid-column: 1 / -1; }
.empty h3 { margin-top: 0; }

.upload-card, .settings-card, .info-card { padding: 22px; margin-bottom: 18px; }
.upload-card h2, .settings-card h2, .info-card h2 { margin-top: 0; }
.upload-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 14px; }

.table-card { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { text-align: left; padding: 15px 18px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
.empty-cell { color: var(--muted); text-align: center; padding: 30px; }
code { background: #f0f2f6; border-radius: 7px; padding: 3px 6px; }

.form-stack { display: grid; gap: 14px; }
.form-stack label { display: grid; gap: 7px; font-weight: 600; }
.form-stack input {
    width: 100%; border: 1px solid #d7dce5; border-radius: 10px; padding: 11px 12px;
    outline: none; background: white;
}
.form-stack input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,99,255,.12); }
.narrow { max-width: 480px; }

.flash { padding: 12px 14px; border-radius: 11px; margin-bottom: 15px; border: 1px solid; }
.flash.success { color: var(--success); background: #edf9f1; border-color: #b9e3c7; }
.flash.error { color: var(--danger); background: #fff1f0; border-color: #f1c2bd; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #eef2f7; }
.login-card {
    width: min(430px, 100%); background: white; border: 1px solid var(--line);
    padding: 30px; border-radius: 20px; box-shadow: 0 18px 50px rgba(21,31,50,.10);
}
.login-brand { margin-bottom: 28px; color: var(--text); }
.login-brand .brand-mark { background: var(--sidebar); color: white; }
.login-brand small { color: var(--muted); }
.login-card h1 { margin: 0 0 8px; }
.login-card > p { color: var(--muted); margin: 0 0 22px; }

@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 16px 0 40px rgba(0,0,0,.18); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; width: 100%; }
    .menu-button { display: block; }
    .topbar { padding: 0 16px; }
    .content { padding: 20px 16px 30px; }
    .stats { grid-template-columns: 1fr; }
    .hero { align-items: flex-start; flex-direction: column; padding: 25px; }
    .hero .button { width: 100%; }
}

.secondary { background: #eef1f6; color: #263247; }
.app-manage { padding: 20px; }
.app-manage-head { display:flex; align-items:flex-start; gap:14px; }
.grow { flex:1; min-width:0; }
.app-manage h3 { margin:2px 0 5px; }
.app-manage p { margin:0; color:var(--muted); }
.app-meta { display:flex; gap:18px; flex-wrap:wrap; color:var(--muted); font-size:13px; margin:15px 0; }
.app-actions { display:flex; gap:9px; flex-wrap:wrap; align-items:center; }
.app-actions form { margin:0; }
.badge.bad { background:#fff1f0; color:var(--danger); }
@media(max-width:640px){
  .app-actions, .app-actions form, .app-actions .button { width:100%; }
}

.inline-form { display:flex; gap:8px; flex-wrap:wrap; margin:12px 0; }
.inline-form input, .user-create input, .user-create select {
    border:1px solid #d7dce5; border-radius:10px; padding:10px 11px; background:white;
}
.inline-form input { min-width:220px; }
.user-create { display:grid; grid-template-columns: 1.2fr 1.2fr 1fr auto; gap:10px; }
.users-list { display:grid; gap:16px; }
.user-card { padding:20px; }
.user-head { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; }
.user-head h3 { margin:0 0 8px; }
.permissions { display:grid; gap:9px; margin:18px 0; }
.check-row { display:flex; gap:10px; align-items:center; padding:10px 12px; border:1px solid var(--line); border-radius:10px; }
.check-row small { color:var(--muted); margin-left:6px; }
.password-form { padding-top:14px; border-top:1px solid var(--line); }
@media(max-width:760px){
  .user-create { grid-template-columns:1fr; }
  .inline-form, .inline-form input, .inline-form .button { width:100%; }
}

.versions { margin-top:16px; border-top:1px solid var(--line); padding-top:14px; }
.versions summary { cursor:pointer; font-weight:700; }
.version-list { display:grid; gap:8px; margin-top:12px; }
.version-row {
    display:flex; align-items:center; justify-content:space-between; gap:12px;
    padding:10px 12px; border:1px solid var(--line); border-radius:10px;
}
.version-row small { display:block; color:var(--muted); margin-top:2px; }
@media(max-width:640px){
  .version-row { align-items:flex-start; flex-direction:column; }
  .version-row form, .version-row .button { width:100%; }
}

.update-box { margin:14px 0 4px; }
.update-box > summary { list-style:none; width:max-content; }
.update-box > summary::-webkit-details-marker { display:none; }
.update-form { display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-top:12px; }
@media(max-width:640px){
  .update-box > summary, .update-form, .update-form .button, .update-form input { width:100%; }
}

.logout-form{margin:0}.link-button{background:none;border:0;padding:0;color:inherit;text-decoration:underline;cursor:pointer;font:inherit}
