/* Kaasukahva — UI text is Finnish, identifiers English. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e2e5ea;
  --text: #14171c;
  --text-dim: #646c7a;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --danger: #c8342b;
  --danger-soft: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 22, 33, .06), 0 8px 24px rgba(16, 22, 33, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1d222a;
    --border: #2a313b;
    --text: #e7eaef;
    --text-dim: #9aa4b2;
    --accent: #5a9bff;
    --accent-soft: #16233a;
    --danger: #ff6b60;
    --danger-soft: #33201e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

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

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.01em;
}

.brand-mark { font-size: 20px; }

/* The name alone does not say what the service is, so it carries a tagline. */
.brand-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0;
  padding-left: 9px;
  margin-left: 2px;
  border-left: 1px solid var(--border);
}

@media (max-width: 560px) {
  .brand-tag { display: none; }
}

.tabs { display: flex; gap: 4px; }

.tabs a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
}

.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a.active { background: var(--accent-soft); color: var(--accent); }

.view {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* ---------- page headers ---------- */

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

.page-head h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -.02em;
}

.back-link {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
}

.back-link:hover { color: var(--accent); }

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

/* ---------- buttons ---------- */

button, .btn {
  font: inherit;
  font-weight: 550;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .12s, border-color .12s;
}

button:hover, .btn:hover { background: var(--surface-2); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }

.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 4px 8px;
  font-size: 16px;
  line-height: 1;
}

.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- cards / grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: transform .12s, border-color .12s;
}

a.card:hover { transform: translateY(-2px); border-color: var(--accent); }

.card-photo {
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  background: var(--surface-2);
  display: block;
}

.card-photo.placeholder {
  display: grid;
  place-items: center;
  font-size: 44px;
  color: var(--text-dim);
}

.card-body { padding: 14px 16px 16px; }

.card-title {
  font-weight: 650;
  letter-spacing: -.01em;
  margin-bottom: 2px;
}

.card-meta { color: var(--text-dim); font-size: 13px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chip {
  font-size: 12px;
  font-weight: 550;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.chip-plate {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text);
}

.chip-class { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* The cost of a service, and the total across the ones that have one. */
.chip-cost {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.total-cost {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  margin-left: 9px;
  font-variant-numeric: tabular-nums;
}

/* Marks a service the owner did themselves, as opposed to a named workshop. */
.chip-self { background: transparent; border-style: dashed; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  font-weight: 550;
}

.checkbox input { width: 17px; height: 17px; accent-color: var(--accent); }

/* The workshop field is disabled while "itse tehty" is ticked. */
input:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ---------- panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

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

.panel-head h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }

.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px 20px;
}

.spec dt {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.spec dd {
  margin: 0;
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ---------- color picker ---------- */

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.swatch {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(128, 128, 128, .35);
  cursor: pointer;
  transition: transform .1s, outline-color .1s;
}

.swatch:hover { transform: scale(1.08); }

.swatch.selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Shown next to a color name, wherever one is displayed. */
.color-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(128, 128, 128, .45);
  display: inline-block;
  flex: none;
}

/* ---------- photos ---------- */

.photo-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.photo-item { position: relative; }

.photo-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
  cursor: zoom-in;
  transition: filter .12s;
}

.photo-item img:hover { filter: brightness(1.06); }

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 10, 14, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  cursor: zoom-out;
}

.lightbox[hidden] { display: none; }

#lightbox-img {
  max-width: min(1200px, 92vw);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  cursor: default;
  background: #000;
}

.lightbox-close,
.lightbox-nav {
  border: none;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  flex: none;
}

.lightbox-close:hover,
.lightbox-nav:hover { background: rgba(255, 255, 255, .26); }

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  font-size: 17px;
}

.lightbox-nav {
  width: 46px;
  height: 46px;
  font-size: 30px;
  line-height: 1;
}

.lightbox-nav[hidden] { display: none; }

.lightbox-count {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, .75);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  .lightbox { padding: 12px; gap: 4px; }
  .lightbox-nav { width: 38px; height: 38px; font-size: 24px; }
}

.photo-item button {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 7px;
  border-radius: 7px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  border: none;
  font-size: 13px;
}

.photo-item button:hover { background: var(--danger); }

/* ---------- service log ---------- */

.log { display: flex; flex-direction: column; gap: 12px; }

.log-item {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.log-date { font-weight: 650; font-variant-numeric: tabular-nums; }

.log-details { white-space: pre-wrap; margin-top: 6px; }

/* ---------- owners ---------- */

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex: none;
}

.avatar.placeholder {
  display: grid;
  place-items: center;
  font-weight: 650;
  color: var(--text-dim);
}

.owner-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.owner-row:last-child { border-bottom: none; }
.owner-row .grow { flex: 1; min-width: 0; }

.avatar-sm { width: 26px; height: 26px; font-size: 12px; }
.owner-inline { display: flex; align-items: center; gap: 6px; }

/* ---------- auth screens ---------- */

.auth-wrap {
  min-height: 78vh;
  display: grid;
  place-items: center;
  padding: 24px 0;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px 26px 24px;
}

.auth-title {
  margin: 0 0 20px;
  font-size: 20px;
  letter-spacing: -.02em;
}

.auth-card p { margin: 0 0 14px; }

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.auth-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.auth-link:hover { text-decoration: underline; }

/* A form that fills the card, rather than sitting right-aligned in a dialog. */
.form-actions-wide { justify-content: stretch; }
.form-actions-wide button { flex: 1; justify-content: center; }

.notice {
  padding: 10px 13px;
  border-radius: 9px;
  font-size: 14px;
  margin-bottom: 16px;
}

.notice-info { background: var(--accent-soft); color: var(--accent); }
.notice-error { background: var(--danger-soft); color: var(--danger); }

/* The signed-out screens have no top bar, so they need the space back. */
body.signed-out .view { padding-top: 8px; }

.whoami {
  margin-left: auto;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

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

/* Removes an owner from a moped, sitting inside their chip. */
.chip-x {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 0 0 0 4px;
  font-size: 12px;
  line-height: 1;
}

.chip-x:hover { background: transparent; color: var(--danger); }

/* ---------- forms ---------- */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 550;
  margin-bottom: 5px;
  color: var(--text-dim);
}

input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

textarea { resize: vertical; min-height: 96px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.owner-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 168px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px;
  background: var(--surface-2);
}

.owner-picker label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  margin: 0;
  font-size: 15px;
}

.owner-picker label:hover { background: var(--surface); }
.owner-picker input { accent-color: var(--accent); }

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 14, 20, .55);
  display: grid;
  place-items: start center;
  padding: 40px 16px;
  overflow-y: auto;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  width: min(560px, 100%);
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .3);
  border: 1px solid var(--border);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.modal-body { padding: 20px; }

/* ---------- misc ---------- */

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-mark { font-size: 40px; display: block; margin-bottom: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 550;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.toast[hidden] { display: none; }
.toast.err { background: var(--danger); color: #fff; }

@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
  .log-item { grid-template-columns: 1fr; }
  .view { padding: 16px 14px 48px; }
}
