:root {
    --bg: #0f1115;
    --panel: #181b22;
    --panel-2: #1f232c;
    --text: #e6e8eb;
    --muted: #8a93a3;
    --accent: #4f8cff;
    --accent-2: #2563eb;
    --good: #2ecc71;
    --warn: #f39c12;
    --bad: #e74c3c;
    --border: #262b35;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

header {
    max-width: 880px;
    margin: 0 auto;
    padding: 16px 16px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
header h1 { font-size: 20px; margin: 0; }

.user-strip { display: flex; align-items: center; gap: 12px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); margin: 8px 0 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.btn-link {
    display: inline-block;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    line-height: 1;
}
.btn-link:hover { background: #2a2f3a; text-decoration: none; }

.card {
    max-width: 880px;
    margin: 12px auto;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.warn-banner {
    border-color: var(--warn);
    background: #2a2014;
}
.warn-banner strong { color: var(--warn); display: block; margin-bottom: 4px; }

/* login/register */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
body.login .card { width: 100%; max-width: 420px; margin: 16px; }
body.login h1 { margin: 0 0 4px; }
body.login p { margin: 0 0 12px; }
body.login label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin: 12px 0 4px;
}
body.login input,
body.login button {
    width: 100%;
    padding: 14px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    font-size: 16px; /* >= 16px stops iOS Safari auto-zoom on focus */
    min-height: 48px;
}
body.login button {
    margin-top: 16px;
    background: var(--accent-2);
    border-color: var(--accent-2);
    cursor: pointer;
    font-weight: 600;
}
body.login button:hover:not([disabled]) { background: var(--accent); }
body.login button[disabled], body.login input[disabled] { opacity: 0.5; cursor: not-allowed; }
.register-link {
    margin-top: 18px;
    text-align: center;
    font-size: 14px;
}

/* pending-payment box */
.pay-box {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 12px 0;
}
.pay-list {
    margin: 6px 0 12px;
    padding-left: 20px;
}
.pay-box code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

/* quota bar */
.quota-label {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 8px; gap: 12px; flex-wrap: wrap;
}
.quota-track {
    height: 16px; background: var(--panel-2);
    border-radius: 8px; overflow: hidden; border: 1px solid var(--border);
}
.quota-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--good), var(--accent));
    transition: width 250ms ease, background 250ms ease;
}
.quota-fill.warn { background: linear-gradient(90deg, var(--warn), var(--bad)); }
.quota-fill.danger { background: var(--bad); }
.quota .small { margin: 8px 0 0; }

/* dropzone */
.dropzone {
    text-align: center;
    border: 2px dashed var(--border);
    background: var(--panel);
    padding: 24px 16px;
    transition: background 150ms, border-color 150ms;
}
.dropzone.drag { background: var(--panel-2); border-color: var(--accent); }
.dropzone p { margin: 4px 0; }
.dz-prompt { font-size: 16px; }
.dropzone input[type=file] {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); border: 0;
}
.big-btn {
    display: inline-block;
    margin: 14px 0 6px;
    padding: 14px 22px;
    min-height: 48px;
    background: var(--accent-2);
    color: var(--text);
    border-radius: 10px;
    font-weight: 600; font-size: 16px;
    cursor: pointer; border: 1px solid var(--accent-2);
    user-select: none;
}
.big-btn:hover, .big-btn:active { background: var(--accent); }

/* queue */
#queue h2, .card h2 { margin: 0 0 12px; font-size: 17px; }
#queue ul, .files { list-style: none; margin: 0; padding: 0; }
#queue li { padding: 12px 0; border-top: 1px solid var(--border); }
#queue li:first-child { border-top: 0; }
.q-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.q-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-status { font-size: 13px; color: var(--muted); white-space: nowrap; }
.q-status.done { color: var(--good); }
.q-status.err { color: var(--bad); }
.q-bar { height: 8px; margin-top: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.q-bar > div {
    height: 100%; width: 0%; background: var(--accent);
    transition: width 120ms linear;
}

/* file list */
.files li {
    padding: 12px 0; border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; flex-wrap: wrap;
}
.files li:first-child { border-top: 0; }
.files .f-meta { color: var(--muted); font-size: 13px; }
.files .f-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .actions { display: flex; gap: 8px; }
.files button, .files a.btn {
    background: var(--panel-2); border: 1px solid var(--border);
    color: var(--text); padding: 10px 14px;
    min-height: 40px; border-radius: 8px;
    font-size: 14px; cursor: pointer;
    text-decoration: none; display: inline-flex; align-items: center;
}
.files button:hover, .files a.btn:hover { background: #2a2f3a; }
.files button.danger { color: var(--bad); border-color: #4a2a2a; }
.files button.danger:hover { background: #2a1a1a; }

/* admin table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.admin-table th, .admin-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.admin-table th {
    color: var(--muted);
    font-weight: 500;
    background: var(--panel-2);
}
.admin-table tbody tr:hover { background: var(--panel-2); }
.row-actions {
    display: flex; gap: 6px; flex-wrap: wrap;
}
.row-actions button {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.row-actions button:hover { background: #2a2f3a; }
.row-actions button.ok { color: var(--good); border-color: #1f4731; }
.row-actions button.ok:hover { background: #14271c; }
.row-actions button.warn { color: var(--warn); border-color: #4a3a1a; }
.row-actions button.warn:hover { background: #2a221a; }
.row-actions button.danger { color: var(--bad); border-color: #4a2a2a; }
.row-actions button.danger:hover { background: #2a1a1a; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
}
.badge.ok { color: var(--good); border-color: #1f4731; }
.badge.warn { color: var(--warn); border-color: #4a3a1a; }

/* settings form */
.settings label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin: 12px 0 4px;
}
.settings input, .settings textarea {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
}
.settings textarea { resize: vertical; min-height: 80px; }
.settings .big-btn { margin-top: 16px; }
#settings-status { margin-left: 12px; }

/* narrow phones */
@media (max-width: 600px) {
    header h1 { font-size: 18px; }
    .card { margin: 10px; padding: 14px; border-radius: 12px; }
    .files li { flex-direction: column; align-items: stretch; }
    .files .actions { justify-content: space-between; }
    .files button, .files a.btn { flex: 1; justify-content: center; min-height: 44px; }

    /* Admin table: switch to "card per row" layout */
    .admin-table thead { display: none; }
    .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
    .admin-table tr {
        background: var(--panel-2);
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 10px 12px;
        margin-bottom: 10px;
    }
    .admin-table td {
        border: 0;
        padding: 4px 0;
    }
    .admin-table td::before {
        content: attr(data-label);
        display: inline-block;
        color: var(--muted);
        min-width: 80px;
    }
    .row-actions { margin-top: 8px; }
    .row-actions button {
        flex: 1 0 calc(50% - 6px);
        min-height: 40px;
    }
}
