/* Dark by default: this panel is operated alongside c4ds, which is dark, and a white page at night
   in the field is its own kind of hostile. */

:root {
    --bg: #14171a;
    --surface: #1c2126;
    --border: #2b333b;
    --text: #e6edf3;
    --muted: #8b969f;
    --accent: #22c55e;
    --accent-text: #04140a;
    --error: #f87171;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 16px; font-weight: 600; }

.centred {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.spacer { flex: 1; }

/* The icon is a white plate with the mark on it, so it is not rounded here to taste — it is rounded
   to the same proportion the SVG uses, or the plate's own corners show through the crop. */
.topbar-logo {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    flex-shrink: 0;
    display: block;
}

.nav {
    display: flex;
    gap: 4px;
    margin-left: 20px;
}

.nav-item {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    /* The active tab is marked by weight and contrast rather than an underline, so the row does not
       shift by a pixel when it changes. */
    border: 1px solid transparent;
}

.nav-item:hover {
    color: var(--text);
    background: var(--bg);
}

.nav-item-active {
    color: var(--text);
    background: var(--bg);
    border-color: var(--border);
}

@media (max-width: 640px) {
    .topbar { flex-wrap: wrap; }
    .nav { margin-left: 0; order: 3; flex-basis: 100%; }
}

.content {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.card-narrow { width: 100%; max-width: 420px; }

/* The sign-in card. Everything on one axis: heading, subtitle and the button all centred, rather
   than left-aligned text above a centred button, which reads as a mistake. */
.card-centred {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 32px 24px;
}

.card-centred h1 { margin-bottom: 8px; }

.card-centred .muted { margin: 0; }

/* Google's iframe is a fixed 320px wide, so the slot is sized to it rather than stretched — a
   full-width flex row would leave the button looking off-centre inside its own container. */
.card-centred .google-slot {
    width: 320px;
    max-width: 100%;
    margin: 24px 0 0;
}

/* The error and the "loading sign-in" line both sit above the button; keeping them the same width
   as it stops the card jumping sideways when one appears. */
.card-centred .error,
.card-centred .hint,
.card-centred > p.muted:last-child {
    width: 100%;
}

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.row-between h2 { margin: 0; }

.muted { color: var(--muted); font-size: 13px; }

.hint {
    color: var(--muted);
    font-size: 12px;
    margin: 4px 0 0;
}

.field { margin-bottom: 16px; }

.field-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.field-inline label { margin: 0; }
.field-inline .hint { flex-basis: 100%; margin: 0; }

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
}

input, select {
    width: 100%;
    padding: 9px 11px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: 14px;
}

input[type="checkbox"] { width: auto; }

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="file"] {
    padding: 8px;
    color: var(--muted);
}

button {
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

/* not-allowed rather than default: some of these are disabled permanently, not just mid-request,
   and the cursor is the only thing that says so before the tooltip arrives. */
button:disabled { opacity: 0.55; cursor: not-allowed; }

.primary {
    background: var(--accent);
    color: var(--accent-text);
    width: 100%;
}

.secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.error, .status {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 14px;
    background: #232a31;
    border: 1px solid var(--border);
    /* Digests and storage paths are long and must stay readable rather than overflow the card. */
    word-break: break-word;
}

.error, .status-error {
    color: var(--error);
    border-color: #4a2226;
    background: #2a1c1e;
}

.status-ok {
    color: var(--accent);
    border-color: #1c3d29;
    background: #16251c;
}

.status-warn {
    color: #fbbf24;
    border-color: #4a3a16;
    background: #2a2213;
}

.badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
    /* Helps at a glance in a long table; the tooltip carries the detail. */
    cursor: help;
}

/* The file picker. A dashed box reads as "put something here" in a way a bare file input never
   does, and it doubles as the drop target. */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 28px 20px;
    margin-bottom: 20px;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover {
    border-color: var(--accent);
    background: #171d21;
}

/* Dragging over: the same treatment as hover but solid, so the drop target is unambiguous while a
   file is in flight over it. */
.dropzone-over {
    border-style: solid;
    border-color: var(--accent);
    background: #16251c;
}

.dropzone-filled {
    border-style: solid;
    border-color: #2f4738;
    background: #161d19;
}

.dropzone-glyph {
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    margin-bottom: 4px;
}

.dropzone-filled .dropzone-glyph { color: var(--accent); }

.dropzone-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    /* A long APK filename must not stretch the card. */
    word-break: break-all;
}

.dropzone-hint {
    font-size: 12px;
    color: var(--muted);
}

/* Advanced: present but out of the way. If you had to open it, you did not need it. */
.advanced {
    margin-bottom: 20px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.advanced > summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    list-style: none;
    user-select: none;
}

.advanced > summary::-webkit-details-marker { display: none; }

.advanced > summary::before {
    content: "▸ ";
    display: inline-block;
    transition: transform 0.15s;
}

.advanced[open] > summary::before { content: "▾ "; }

.advanced > summary:hover { color: var(--text); }

.advanced-body { padding-top: 16px; }

/* Google renders its button inside an iframe it controls, so this only positions it — the button's
   own appearance is not ours to style. */
.google-slot {
    display: flex;
    justify-content: center;
    min-height: 44px;
    margin: 20px 0 4px;
}

/* The download surface. One card per app, the action on the right so the column of buttons is
   scannable rather than hidden at the end of a row of metadata. */
.app-card {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 12px;
}

.app-main { flex: 1; min-width: 0; }

.app-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.app-meta {
    font-size: 13px;
    color: var(--muted);
    /* Package names are long and must wrap rather than widen the card. */
    word-break: break-word;
}

.app-action { flex-shrink: 0; }
.app-action button { width: auto; }
.app-card .status { margin: 8px 0 0; }

/* Compact enough to sit in a table cell without stretching the row. */
.role-select {
    width: auto;
    padding: 4px 8px;
    font-size: 12px;
}

.badge-admin {
    color: var(--accent);
    background: #16251c;
    border: 1px solid #1c3d29;
}

/* Destructive, so it reads as such only on approach — a row of permanently red buttons trains
   people to ignore red. Not when disabled: a button that lights up under the cursor and then does
   nothing reads as broken rather than as refused. */
.danger:hover:not(:disabled) {
    color: var(--error);
    border-color: #4a2226;
}

/* The add-account form sits above its own table, so it needs to be compact rather than a page of
   stacked fields. */
.inline-form {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.inline-form .field {
    flex: 1 1 220px;
    margin-bottom: 0;
}

.inline-form button {
    /* Aligns with the inputs rather than the labels above them. */
    margin-top: 25px;
    width: auto;
}

.badge-warn {
    color: #fbbf24;
    background: #2a2213;
    border: 1px solid #4a3a16;
}

/* Confirmation dialogs. Native <dialog>, so the backdrop, the top layer and Escape are the
   browser's job and only the surface is styled here. */
.modal {
    width: calc(100vw - 48px);
    max-width: 420px;
    padding: 22px 24px 18px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.modal::backdrop { background: rgba(0, 0, 0, 0.6); }

.modal-title { font-size: 17px; margin: 0 0 8px; }

.modal-message {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
    /* Email addresses and APK filenames are long and must wrap rather than widen the dialog. */
    word-break: break-word;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

/* .primary is full-width for the forms it was written for; in a button row it is not. */
.modal-actions button { width: auto; }

/* Only ever the confirm button of a destructive dialog — the one place a permanently red button is
   earned, because by then the question has already been asked. */
.destructive {
    background: var(--error);
    color: #2a0d0f;
}

.hidden { display: none; }

.progress {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 14px;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 0.15s linear;
}

.catalog {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.catalog th, .catalog td {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
}

.catalog th {
    color: var(--muted);
    font-weight: 500;
}

.catalog tr:last-child td { border-bottom: none; }

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

.catalog-body { overflow-x: auto; }
