:root {
    --fg: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #2563eb;
    --danger: #dc2626;
    --ok: #16a34a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--fg);
    background: #f9fafb;
}

h1 { margin-top: 0; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.warn { color: var(--warn, #b7791f); }
.ok { color: var(--ok); margin-left: .5rem; }

/* toolbar */
.toolbar {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-bottom: 1rem;
}
.toolbar input { flex: 1; }

/* form controls */
input:not([type=file]), textarea, select {
    width: 100%;
    padding: .5rem .625rem;
    border: 1px solid var(--border);
    border-radius: .375rem;
    font: inherit;
    background: #fff;
}
.form { display: flex; flex-direction: column; gap: .75rem; max-width: 560px; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-weight: 500; }
.form label small { font-weight: 400; color: var(--muted); }

button, .btn {
    display: inline-block;
    padding: .5rem 1rem;
    border-radius: .375rem;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    align-self: flex-start;
}
button:disabled { opacity: .5; cursor: default; }
button.danger { background: var(--danger); border-color: var(--danger); }
button.link {
    background: none;
    border: none;
    color: var(--accent);
    padding: 0;
    text-decoration: underline;
}
button.link.danger { color: var(--danger); background: none; }

/* tables */
table.grid, table.kv {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: .5rem;
}
table.grid th, table.grid td, table.kv th, table.kv td {
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
table.grid th { background: #f3f4f6; font-weight: 600; }
table.kv th { width: 180px; color: var(--muted); font-weight: 500; }
table.grid td.actions { white-space: nowrap; }
table.grid td.actions a, table.grid td.actions button { margin-right: .5rem; }

.tag {
    display: inline-block;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 999px;
    padding: .1rem .5rem;
    font-size: .75rem;
    margin: 0 .25rem .25rem 0;
}

/* dashboard */
.stats { display: flex; gap: 1rem; margin-bottom: 1rem; }
.stat {
    flex: 1;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: .5rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.75rem; font-weight: 600; }
.recent { list-style: none; padding: 0; }
.recent li { padding: .4rem 0; border-bottom: 1px solid var(--border); }
.recent small { color: var(--muted); margin-left: .5rem; }

.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

pre.json {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: .5rem;
    padding: .75rem;
    font-size: .8rem;
    overflow-x: auto;
    max-width: 800px;
}

/* image content overlays */
.overlay-wrap { position: relative; display: inline-block; max-width: 640px; }
.overlay-wrap img { display: block; max-width: 100%; height: auto; }
.overlay-wrap .box { position: absolute; border: 2px solid; box-sizing: border-box; pointer-events: none; }
.box.face, .swatch.face { border-color: #dc2626; }
.box.logo, .swatch.logo { border-color: #2563eb; }
.box.subject, .swatch.subject { border-color: #16a34a; border-style: dashed; }
.box.keep, .swatch.keep { border-color: #f59e0b; border-style: dotted; }
.box.crop, .swatch.crop { border-color: #eab308; border-width: 3px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.swatch { display: inline-block; width: 14px; height: 14px; border: 2px solid; vertical-align: middle; margin: 0 .25rem 0 .75rem; }
.crops { display: flex; flex-wrap: wrap; gap: .75rem; }
.crop-card { margin: 0; width: 240px; cursor: pointer; border: 2px solid transparent; border-radius: .5rem; padding: .25rem; background: #fff; }
.crop-card.selected { border-color: #eab308; }
.crop-card img { display: block; width: 100%; height: auto; border-radius: .25rem; }
.crop-card figcaption { font-size: .8rem; padding: .25rem .1rem; }

/* web image + url builder */
.web-image-row { display: flex; gap: 1rem; align-items: flex-start; }
.web-image-row .grow { flex: 1; min-width: 0; }
.web-image .thumb { display: block; max-width: 320px; max-height: 240px; border: 1px solid var(--border); border-radius: .5rem; background: #fff; }
.url-line { display: flex; gap: .5rem; align-items: center; }
.url-line input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; color: #374151; }
.builder { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; margin: .5rem 0; }
.builder label { display: flex; flex-direction: column; gap: .25rem; font-weight: 500; }
.builder label input[type=number] { width: 110px; }
.builder label.check { flex-direction: row; align-items: center; gap: .4rem; }
.builder label.check input { width: auto; }
.builder .presets { display: flex; gap: .75rem; flex-wrap: wrap; align-self: center; }
.built-preview { margin: .5rem 0; }
.built-preview img { max-width: 100%; max-height: 360px; border: 1px solid var(--border); border-radius: .5rem; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.stat small { margin-top: .25rem; font-size: .75rem; }
.sidebar-footer .user { display: flex; align-items: center; gap: .4rem; color: #d1d5db; margin-bottom: .25rem; }
.sidebar-footer .avatar { width: 22px; height: 22px; border-radius: 50%; }
.sidebar-footer a { color: #93c5fd; }

/* home status badge */
.status { display: flex; flex-direction: column; align-items: flex-start; gap: .75rem; margin-top: 1.5rem; }
.status .badge { font-size: 2rem; font-weight: 700; padding: .5rem 1.25rem; border-radius: .75rem; color: #fff; }
.status .badge.healthy { background: var(--ok, #16a34a); }
.status .badge.warning { background: var(--warn, #b7791f); }
.status .badge.checking { background: var(--muted, #888); }

/* dashboard: image request stats */
.stats-table td.num, .stats-table th.num { text-align: right; white-space: nowrap; }
.stats-table tr.total td { font-weight: 700; border-bottom: 2px solid #d1d5db; }
.stats-table tr.domain td { font-weight: 600; background: #f9fafb; }
.stats-table tr.host td:first-child { padding-left: 1.5rem; }
.stats-table tr.size td:first-child { padding-left: 3rem; color: var(--muted); font-family: ui-monospace, monospace; }
h2 button.link { font-size: .8rem; font-weight: 400; margin-left: .5rem; }
