:root {
    --ink: #14221d;
    --muted: #68766f;
    --paper: #f4f6f2;
    --card: #fff;
    --line: #dce4df;
    --green: #176b4d;
    --green-2: #2e9a70;
    --mint: #dff2e8;
    --gold: #d2a84b;
    --danger: #7c1f2c;
    --danger-light: #f8e9eb;
    --warning: #8a5a0a;
    --warning-light: #fff3d7;
    --shadow: 0 16px 40px rgba(29, 56, 45, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--green); }
code {
    overflow-wrap: anywhere;
    color: #244b3c;
    border-radius: 6px;
    background: #edf3ef;
    font-family: "Cascadia Mono", Consolas, monospace;
}

.admin-layout { display: grid; grid-template-columns: 245px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 24px 16px;
    color: #fff;
    background: linear-gradient(180deg, #123b2d, #0f2f24);
}
.sidebar-brand, .login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}
.sidebar-brand { padding: 0 9px 24px; }
.sidebar-brand strong, .login-brand strong { display: block; letter-spacing: .08em; }
.sidebar-brand small, .login-brand small { display: block; margin-top: 2px; opacity: .68; }
.brand-mark {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    width: 40px;
    height: 40px;
    padding: 8px 7px 7px;
    border-radius: 11px;
    background: var(--green-2);
}
.brand-mark span {
    display: block;
    border: 2px solid #fff;
    border-top-left-radius: 5px;
    border-bottom-left-radius: 3px;
    border-right: 0;
}
.brand-mark span:last-child { transform: scaleX(-1); }
.sidebar nav { display: grid; gap: 5px; }
.nav-item {
    width: 100%;
    padding: 12px 13px;
    color: #cce2d8;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    text-align: left;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.13); font-weight: 750; }
.sidebar-footer { display: grid; gap: 9px; margin-top: auto; padding: 16px 9px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-footer a, .sidebar-footer button { color: #cce2d8; font-size: 13px; }
.sidebar-footer button { padding: 0; border: 0; background: none; cursor: pointer; }
.sidebar-footer small { margin-top: 8px; color: rgba(255,255,255,.45); }

.admin-main { width: min(1220px, 100%); min-width: 0; padding: 34px clamp(20px, 4vw, 56px) 60px; }
.mobile-header { display: none; }
.view { display: none; }
.view.active { display: block; animation: appear .16s ease-out; }
@keyframes appear { from { opacity: .45; transform: translateY(3px); } }
.page-heading, .panel-heading, .pagination, .dialog-heading, .dialog-actions, .secret-row, .button-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.page-heading { margin-bottom: 20px; }
.page-heading h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.035em; }
.eyebrow { margin: 0 0 6px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted, .hint { color: var(--muted); line-height: 1.55; }
.hint { font-size: 12px; }

.panel, .metric, .status-banner {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--card);
    box-shadow: var(--shadow);
}
.panel { padding: 22px; }
.panel-heading { margin-bottom: 18px; }
.panel-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.panel-heading .eyebrow { margin-bottom: 4px; }
.status-banner { display: flex; align-items: center; gap: 13px; margin-bottom: 15px; padding: 15px 18px; }
.status-banner strong, .status-banner small { display: block; }
.status-banner small { margin-top: 3px; color: var(--muted); }
.status-dot { flex: 0 0 11px; width: 11px; height: 11px; border-radius: 50%; background: var(--green-2); box-shadow: 0 0 0 6px rgba(46,154,112,.12); }
.status-banner.problem { color: var(--danger); border-color: #e4b8be; background: var(--danger-light); }
.status-banner.problem .status-dot { background: var(--danger); box-shadow: 0 0 0 6px rgba(124,31,44,.11); }
.status-banner.empty .status-dot { background: #9ba8a2; box-shadow: 0 0 0 6px rgba(104,118,111,.10); }
.status-banner.working .status-dot {
    animation: update-pulse 1.2s ease-in-out infinite;
}
@keyframes update-pulse {
    50% { opacity: .45; box-shadow: 0 0 0 10px rgba(46,154,112,.05); }
}
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.metric { padding: 19px; }
.metric > span, .metric small { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin: 8px 0 5px; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.035em; }
.metric.accent { border-color: #c5e7d6; background: var(--mint); }
.two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stack { display: grid; gap: 14px; align-content: start; }
.details-list { margin: 0; }
.details-list div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid #edf1ee; }
.details-list div:last-child { border-bottom: 0; }
.details-list dt { color: var(--muted); }
.details-list dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; text-align: right; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 15px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 750;
    line-height: 1.2;
    text-decoration: none;
}
.button:disabled { cursor: not-allowed; opacity: .5; }
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover { background: #125a40; }
.button.secondary { color: var(--green); border-color: #c6d9d1; background: #fff; }
.button.secondary:hover { border-color: var(--green-2); }
.button.danger { color: #fff; background: var(--danger); }
.button.danger-outline { color: var(--danger); border-color: #ddb4ba; background: #fff; }
.button.compact { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.button-row { justify-content: flex-start; flex-wrap: wrap; }

.filters { display: grid; grid-template-columns: minmax(250px, 1fr) 220px 130px; gap: 12px; margin-bottom: 14px; }
label { display: grid; gap: 6px; }
label > span { color: var(--muted); font-size: 12px; font-weight: 650; }
input, select {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--ink);
    border: 1px solid #cdd8d2;
    border-radius: 9px;
    outline: none;
    background: #fff;
}
input:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(46,154,112,.1); }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 800px; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid #edf1ee; font-size: 13px; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
td.numeric, th.numeric { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
.file-cell { max-width: 330px; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 28px; color: var(--muted); text-align: center; }
.pagination { padding-top: 16px; color: var(--muted); font-size: 13px; }
.pagination div { display: flex; align-items: center; gap: 10px; }

.form-panel { display: grid; gap: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-panel > .panel-heading { margin-bottom: 2px; }
.secret-row { padding: 10px 0 14px; }
.secret-row code { flex: 1; padding: 10px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 0; border-bottom: 1px solid #edf1ee; }
.switch-row span { display: grid; gap: 3px; color: var(--ink); }
.switch-row small, .checkbox-list small { color: var(--muted); font-weight: 400; }
input[type="checkbox"] { width: 19px; min-height: 19px; accent-color: var(--green); }
.switch-row input { width: 42px; }
.checkbox-list { display: grid; gap: 10px; }
.cleanup-options { margin: 14px 0; }
.checkbox-list label { display: flex; align-items: flex-start; gap: 10px; }
.checkbox-list label > span { display: grid; gap: 3px; color: var(--ink); }
.pill { padding: 6px 9px; color: var(--green); border-radius: 999px; background: var(--mint); font-size: 12px; font-weight: 750; }
.instruction-card ol { display: grid; gap: 15px; padding-left: 22px; line-height: 1.5; }
.instruction-card li code { display: block; margin-top: 7px; padding: 10px; font-size: 15px; }
kbd { padding: 3px 6px; border: 1px solid #ccd5d0; border-bottom-width: 2px; border-radius: 5px; background: #fff; }

.notice, .flash { padding: 12px 14px; border-radius: 10px; line-height: 1.45; }
.notice.warn { color: var(--warning); border: 1px solid #ecd69f; background: var(--warning-light); }
.notice.danger { color: var(--danger); border: 1px solid #e4b8be; background: var(--danger-light); }
.flash { position: sticky; z-index: 20; top: 12px; margin-bottom: 14px; color: #fff; background: var(--green); box-shadow: var(--shadow); }
.flash.error { background: var(--danger); }
.file-list { display: grid; gap: 0; }
.file-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid #edf1ee; }
.file-item:last-child { border-bottom: 0; }
.file-item strong, .file-item small { display: block; }
.file-item small { margin-top: 4px; color: var(--muted); }
.file-actions { display: flex; gap: 7px; }
.empty-block { padding: 14px 0; color: var(--muted); }
hr { width: 100%; margin: 19px 0; border: 0; border-top: 1px solid #e5ece8; }
.danger-zone { margin-top: 14px; border-color: #e0bdc2; }
.danger-zone .eyebrow, .danger-zone h2 { color: var(--danger); }
.danger-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.danger-actions > div { padding: 17px; border-radius: 12px; background: var(--danger-light); }
.danger-actions p { min-height: 58px; color: #6c4e52; font-size: 13px; line-height: 1.5; }
.inline-check { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 7px; margin: 10px 0; color: var(--muted); font-size: 12px; }
.update-version-list { padding: 2px 0 6px; }
.update-confirmation { align-items: flex-start; margin: 2px 0; line-height: 1.45; }
.update-confirmation > span { color: var(--muted); font-weight: 500; }
.update-steps strong { color: var(--ink); }
.update-status { min-height: 72px; }
.apk-details dt { align-self: start; }
.apk-details dd { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; }

.dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100vh - 30px); padding: 22px; border: 0; border-radius: 18px; box-shadow: 0 30px 90px rgba(13,35,27,.28); }
.dialog::backdrop { background: rgba(8,27,20,.46); backdrop-filter: blur(2px); }
.dialog-heading h2 { margin: 0; }
.icon-button { width: 36px; height: 36px; color: var(--muted); border: 0; border-radius: 50%; background: #edf2ef; cursor: pointer; font-size: 24px; }
.dialog-actions { flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid #e5ece8; }
.publication-list { display: grid; gap: 8px; margin-top: 14px; }
.publication-item { padding: 11px 13px; border-radius: 10px; background: #f3f6f4; font-size: 13px; line-height: 1.55; }

.login-body {
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(circle at 5% 0%, rgba(46,154,112,.14), transparent 34rem), var(--paper);
}
.login-card { width: min(460px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.login-brand { width: fit-content; margin-bottom: 34px; color: var(--ink); }
.login-brand .brand-mark { background: var(--green); }
.login-card h1 { margin: 0 0 12px; font-size: 31px; letter-spacing: -.035em; }
.login-form { display: grid; gap: 16px; margin-top: 24px; }
.login-card footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; color: var(--muted); font-size: 12px; }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .two-columns { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .admin-layout { display: block; }
    .sidebar { display: none; }
    .admin-main { padding: 16px 12px 40px; }
    .mobile-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
    .mobile-header select { width: auto; min-width: 180px; }
    .filters { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .danger-actions { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .metric-grid { grid-template-columns: 1fr; }
    .panel { padding: 17px; }
    .page-heading { align-items: flex-start; }
    .login-card { padding: 24px; }
    .login-card footer { flex-direction: column; }
}
