/* Shopify apps admin. Hand-written, no build step. */

:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #d8dee6;
    --border-strong: #c3ccd6;
    --text: #0f172a;
    --muted: #5b6573;
    --primary: #0f766e;
    --primary-hover: #0b5f58;
    --warn: #9a3412;
    --danger-bg: #fdf2f2;
    --danger-border: #f0c8c8;
    --danger-text: #8a1c1c;
    --notice-bg: #fbf8ef;
    --notice-border: #e8dcb5;
    --row-hover: #f7f9fb;
    --radius: 6px;
    --font: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 var(--font);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

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

/* Top bar */

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

.brand { color: var(--text); font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; }

.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }

.nav a {
    padding: 6px 10px;
    border-radius: var(--radius);
    color: var(--muted);
    white-space: nowrap;
    transition: color 120ms ease, background-color 120ms ease;
}
.nav a:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--bg); font-weight: 500; }

.logout { display: flex; align-items: center; gap: 12px; margin: 0; white-space: nowrap; }

/* Page */

.page { max-width: 1400px; margin: 0 auto; padding: 24px; }

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

.summary, .result-count { margin: 0 0 16px; }
.footnote { margin: 16px 0 0; font-size: 13px; max-width: 900px; }

.notice {
    margin: 0 0 16px;
    padding: 10px 12px;
    background: var(--notice-bg);
    border: 1px solid var(--notice-border);
    border-radius: var(--radius);
    max-width: 900px;
}

.alert, .unavailable-block {
    margin: 0 0 16px;
    padding: 10px 12px;
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius);
    color: var(--danger-text);
}

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

/* Buttons and forms */

.button {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 120ms ease, border-color 120ms ease;
}
.button:hover { background: var(--bg); text-decoration: none; }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

label { display: block; font-weight: 500; margin-bottom: 4px; }

input[type="email"], input[type="password"], input[type="search"], select {
    width: 100%;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
input:focus, select:focus, .button:focus-visible, a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.filters .field { min-width: 160px; }
.filters .field.grow { flex: 1; min-width: 220px; }
.filters .actions { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* Login */

.login {
    max-width: 360px;
    margin: 64px auto 0;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.login h1 { font-size: 18px; margin-bottom: 20px; }
.login input[type="email"], .login input[type="password"] { margin-bottom: 16px; }
.login .check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 16px; }
.login .button { width: 100%; justify-content: center; }
.field-error { margin: 0 0 16px; color: var(--danger-text); }

/* Stats */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    margin: 0 0 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.stats div { padding: 10px 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 0 -1px -1px 0; }
.stats dt { color: var(--muted); font-size: 13px; }
.stats dd { margin: 2px 0 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Tables */

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.table { width: 100%; border-collapse: collapse; }

.table th, .table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.table thead th {
    font-weight: 500;
    color: var(--muted);
    background: var(--surface);
    white-space: nowrap;
}
.table tbody tr:hover { background: var(--row-hover); }
.table tbody tr:last-child th, .table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th, .table tfoot td { border-top: 1px solid var(--border-strong); border-bottom: 0; font-weight: 600; }
/* Short numeric columns: let the labels wrap instead of scrolling sideways. */
.table.stack thead th { white-space: normal; vertical-align: bottom; }
.table.stack thead th.num { min-width: 64px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .app-name { font-weight: 500; white-space: nowrap; }
.table .unavailable { color: var(--danger-text); }
.shops td { white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }

.pagination { display: flex; align-items: center; gap: 16px; margin-top: 16px; }

/* Phone */

@media (max-width: 760px) {
    .topbar { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
    .nav { order: 3; flex-basis: 100%; margin: 0 -10px; }
    .logout { margin-left: auto; }
    .logout .muted { display: none; }

    .page { padding: 16px; }
    .page-head { flex-wrap: wrap; }

    .filters .field, .filters .field.grow { flex: 1 1 100%; min-width: 0; }

    /* The overview table becomes one block per app, label left, number right. */
    .table.stack thead { display: none; }
    .table.stack, .table.stack tbody, .table.stack tfoot, .table.stack tr { display: block; }
    .table.stack tr { border-bottom: 1px solid var(--border-strong); padding: 4px 0; }
    .table.stack tr:last-child { border-bottom: 0; }
    .table.stack th, .table.stack td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 12px; border: 0; }
    .table.stack th { padding-top: 8px; }
    .table.stack td::before { content: attr(data-label); color: var(--muted); font-weight: 400; }
    .table.stack td.unavailable::before { content: none; }
    .table.stack td.na { display: none; }
    .table.stack tfoot th, .table.stack tfoot td { border-top: 0; }
}
