:root {
  color-scheme: light;
  --fg: #1c2321;
  --muted: #6b7573;
  --border: #dfe3e1;
  --bg: #f7f8f7;
  --card: #ffffff;
  --accent: #2f6f4f;
  --accent-dark: #24593f;
  --accent-tint: rgba(47, 111, 79, 0.15);
  --error: #b3261e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }
.container.centered { max-width: 420px; padding-top: 96px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(28, 35, 33, 0.04);
}
.wordmark { font-weight: 800; letter-spacing: -0.03em; color: var(--accent); }
.topbar .brand { text-decoration: none; font-size: 1.3rem; }
.topbar nav { display: flex; gap: 18px; align-items: center; }
.topbar nav a { color: var(--fg); text-decoration: none; font-weight: 500; }
.topbar nav a:hover { color: var(--accent); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(28, 35, 33, 0.05), 0 1px 2px rgba(28, 35, 33, 0.03);
}

h1 { margin-top: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); font-size: 0.92rem; }

label { display: block; margin-bottom: 14px; font-size: 0.9rem; font-weight: 600; }
label.full { grid-column: 1 / -1; }
input, textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 12px;
  font-size: 1rem;
  font-weight: 400;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  background: var(--card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
textarea { min-height: 80px; resize: vertical; }

button, .link-button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
button:hover, .link-button:hover { background: var(--accent-dark); }
button:active { transform: translateY(1px); }
form.inline { display: inline; }
.link-button { background: none; color: var(--fg); padding: 0; text-decoration: underline; font-weight: 400; }
.link-button:hover { background: none; color: var(--accent); }
.link-button.danger { color: var(--error); }
.link-button.danger:hover { color: var(--error); opacity: 0.75; }

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

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }

table { width: 100%; border-collapse: collapse; margin: 12px 0; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.line-items input { padding: 6px 8px; }

.inline-form { display: flex; gap: 10px; align-items: flex-end; }
.inline-form input { width: 80px; margin-top: 0; padding: 6px 8px; }
.inline-form-label { display: block; margin-bottom: 0; font-weight: 400; }
.inline-form-label span { display: block; font-size: 0.75rem; margin-bottom: 2px; white-space: nowrap; }

.recent-table td, .recent-table th { font-size: 0.9rem; }
.status-ok { color: var(--accent); text-transform: capitalize; }
.status-error { color: var(--error); text-transform: capitalize; }

code { background: var(--border); padding: 2px 6px; border-radius: 4px; }

.error { color: var(--error); font-weight: 600; }
.htmx-indicator { display: none; margin-left: 10px; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

.login-card { margin-top: 0; }

.result-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 24px;
  align-items: start;
}
.result-image {
  position: sticky;
  top: 16px;
}
.result-image p.muted { margin: 6px 0 0; font-size: 0.8rem; }

.image-zoom-wrap {
  position: relative;
  height: 320px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #14181a;
  cursor: grab;
  touch-action: none;
  transition: height 0.15s ease;
}
.image-zoom-wrap.dragging { cursor: grabbing; }
.image-zoom-wrap.zoomed { cursor: move; }
.image-zoom-wrap.expanded { height: 78vh; }
.image-zoom-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transform-origin: center center;
  pointer-events: none;
  user-select: none;
}

.image-zoom-hint {
  position: absolute;
  top: 8px;
  left: 8px;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
}
.image-zoom-controls {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 2;
}
.image-zoom-controls button {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
}

@media (min-width: 801px) {
  .result-layout.wide-image { grid-template-columns: minmax(420px, 55vw) 1fr; }
}
@media (max-width: 800px) {
  .result-layout { grid-template-columns: 1fr; }
  .result-image { position: static; }
  .image-zoom-wrap { height: 220px; }
  .image-zoom-wrap.expanded { height: 60vh; }
}
