* { box-sizing: border-box; }

:root {
  --bg: #f4f5f7;
  --surface: #fff;
  --border: #d8dce3;
  --border-strong: #b8bec8;
  --text: #1a1d23;
  --text-muted: #5c6573;
  --accent: #1a56db;
  --accent-soft: #e8effc;
  --header-bg: #fff;
  --panel-bg: #f8f9fb;
  --radius: 6px;
  --page-padding: 1.25rem;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

/* —— App shell —— */

.app-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.app-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 1.5rem;
  padding: 0.65rem var(--page-padding) 0;
}

.brand {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand a {
  color: var(--text);
  text-decoration: none;
}

.brand a:hover {
  color: var(--accent);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  display: block;
  padding: 0.5rem 0.75rem 0.6rem;
  margin-bottom: -1px;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.site-nav a:hover {
  color: var(--text);
  border-bottom-color: var(--border-strong);
}

.site-nav a.current {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.app-main {
  width: 100%;
  padding: 1.25rem var(--page-padding) 2rem;
  min-height: 60vh;
}

footer {
  padding: 1rem var(--page-padding) 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* —— Login page —— */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

body.login-page .login-shell {
  width: 100%;
  max-width: 22rem;
  margin: 0;
  padding: 0;
  min-height: 0;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
}

.login-brand {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  text-align: center;
}

.login-title {
  margin: 0 0 1.25rem;
  font-size: 1.35rem;
  font-weight: 650;
  text-align: center;
  line-height: 1.3;
}

.login-error {
  margin: 0 0 1rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: var(--radius);
}

.login-form label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.login-form input[type=password] {
  display: block;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin-bottom: 0.85rem;
}

.login-form button[type=submit] {
  display: block;
  width: 100%;
}

/* —— Browse flow pages —— */

.browse-flow {
  padding: 0;
}

.page-head {
  margin: 0 0 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.page-kind {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.page-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  line-height: 1.3;
}

.page-lead {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 42rem;
}

.page-actions {
  margin: 0.65rem 0 0;
  font-size: 0.9rem;
}

.page-actions a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.page-actions a:hover {
  text-decoration: underline;
}

.content-section {
  margin: 1.5rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.content-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.content-section h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 600;
}

/* —— Open image form —— */

.open-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.label-hint {
  font-weight: 400;
  color: var(--text-muted);
}

.open-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

input[type=text],
input[type=number],
input[type=password],
select.tag-select {
  font-family: ui-monospace, monospace;
  font-size: 0.95rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  flex: 1 1 20rem;
  min-width: 12rem;
  max-width: 100%;
}

.tag-select-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  max-width: 28rem;
}

select.tag-select {
  flex: 1 1 12rem;
  min-width: 10rem;
  width: auto;
  max-width: 100%;
  cursor: pointer;
}

.tag-select-go {
  flex: 0 0 auto;
}

.tag-select-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

input[type=text]:focus,
input[type=number]:focus,
input[type=password]:focus,
select.tag-select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

button {
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

button:hover {
  background: var(--panel-bg);
}

button[type=submit] {
  background: var(--accent);
  border-color: #1340a8;
  color: #fff;
}

button[type=submit]:hover {
  background: #1649c7;
}

/* —— Location trail & browse panel —— */

.browse-panel {
  margin: 0 0 1rem;
  padding: 0 0 0.85rem;
  border-bottom: 1px solid var(--border);
}

.browse-trail {
  margin: 0 0 0.65rem;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.875rem;
}

.crumbs li {
  display: flex;
  align-items: center;
}

.crumbs li:not(:last-child)::after {
  content: "›";
  margin: 0 0.35rem;
  color: var(--text-muted);
  font-weight: 400;
}

.crumbs a {
  color: var(--accent);
  text-decoration: none;
}

.crumbs a:hover {
  text-decoration: underline;
}

.crumbs .crumb-here {
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-weight: 500;
}

.browse-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* —— Buttons —— */

.actions { margin: 0.5rem 0 1rem; }

a.button {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

a.button:hover {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent);
}

/* —— Tables —— */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--panel-bg);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

table .actions {
  margin: 0;
  text-align: right;
  white-space: nowrap;
}

table .actions a.button {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
}

table a {
  text-decoration: none;
  color: var(--accent);
  font-weight: 500;
}

table a:hover {
  text-decoration: underline;
}

table.file-list {
  font-size: 0.8125rem;
}

.entry-kind {
  display: inline-block;
  min-width: 2rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  vertical-align: baseline;
}

.file-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  word-break: break-all;
}

/* —— Misc content —— */

.hint { color: var(--text-muted); font-size: 0.9rem; }
.error { color: #b42318; }
.mono, code, pre, .dockerfile { font-family: ui-monospace, monospace; }

.dockerfile { list-style: decimal; padding-left: 1.5rem; }
.dockerfile li { margin: 0.25rem 0; }
.dockerfile a { text-decoration: underline; color: var(--accent); }
.dockerfile li.scan-line { list-style: decimal; }
.scan-dot { color: #0a7a2f; margin-right: 0.35em; font-size: 0.85em; vertical-align: baseline; }
.nolayer { color: var(--text-muted); }

details.raw-blobs { margin: 1rem 0; }
details.raw-blobs summary { cursor: pointer; font-weight: 600; }
details.raw-blobs ul { margin: 0.5rem 0 0 1.25rem; }

dl.scan-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
}

dl.scan-meta dt { font-weight: 600; margin: 0; }

p.scan-status {
  font-size: 1.05rem;
  margin: 1rem 0;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.layers { list-style: none; padding: 0; margin: 0; }
.layers li {
  margin: 0.4rem 0;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.layers li:last-child { border-bottom: none; }
.layers a { font-weight: 500; }

img.preview-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

iframe.preview-pdf {
  display: block;
  width: 100%;
  min-height: 75vh;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

pre.file {
  font-size: 0.75rem;
  line-height: 1.35;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
}

pre.file-lines {
  padding: 0.75rem 0;
  white-space: normal;
  line-height: 1.35;
}

pre.file-lines .file-line {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  padding: 0 0.75rem;
  margin: 0;
}

pre.file-lines .line-num {
  flex: 0 0 3.5em;
  color: var(--text-muted);
  user-select: none;
  text-align: right;
  padding-right: 0.75em;
}

pre.file-lines .line-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

pre.file-lines .file-line.line-highlight {
  background: #fff3a0;
  box-shadow: inset 3px 0 0 #e6b800;
}

progress {
  width: 100%;
  max-width: 32rem;
  height: 1.25rem;
}

/* Non-browse pages */
.page-block {
  padding: 0;
}

.page-block > h2:first-child {
  margin-top: 0;
}

.app-main > h2:first-child {
  margin-top: 0;
}
