/* =========================================================================
 * GBFS3 CMS — app.css
 * ========================================================================= */

/* Theme tokens ------------------------------------------------------------ */
:root,
[data-theme='light'] {
  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --bg-muted: #eef0f3;
  --border: #dcdfe4;
  --border-strong: #b9bec7;
  --text: #1f2430;
  --text-muted: #5c6472;
  --text-subtle: #8a93a0;
  --primary: #ff4081;
  --primary-hover: #e0356f;
  --primary-contrast: #ffffff;
  --danger: #c6332e;
  --danger-hover: #a6241f;
  --success: #1f7a45;
  --warning: #b5770a;
  --info: #1f5a7a;
  --focus: rgba(255, 64, 129, 0.35);
  --shadow-sm: 0 1px 2px rgba(15, 20, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 20, 40, 0.08);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-sans:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

[data-theme='dark'] {
  --bg: #0f1320;
  --bg-elevated: #171c2d;
  --bg-muted: #1f2539;
  --border: #2a3149;
  --border-strong: #394163;
  --text: #e6e9f2;
  --text-muted: #a6adc0;
  --text-subtle: #727a91;
  --primary: #ff5c96;
  --primary-hover: #ff7aac;
  --primary-contrast: #0f1320;
  --danger: #ff6b65;
  --danger-hover: #ff8a85;
  --success: #6cdc9e;
  --warning: #f0c056;
  --info: #6cc5dc;
  --focus: rgba(255, 92, 150, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Base -------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

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

h1,
h2,
h3,
h4 {
  margin: 0 0 0.5em 0;
  line-height: 1.25;
}
h1 {
  font-size: 1.6rem;
}
h2 {
  font-size: 1.3rem;
}
h3 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 1em 0;
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: var(--bg-muted);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

pre {
  background: var(--bg-muted);
  padding: 0.8em 1em;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: auto;
  max-height: 60vh;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.25em 0;
}

/* Layout ------------------------------------------------------------------ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

.stack > * + * {
  margin-top: 1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-grid .stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.stat-grid .stat .stat-label,
.stat-grid .stat .label {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex: 1 1 auto;
}
.stat-grid .stat .stat-value,
.stat-grid .stat .value {
  font-size: 1.8rem;
  font-weight: 600;
  text-align: right;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* Topbar ------------------------------------------------------------------ */
.topbar {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
}
.topbar .brand {
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.topbar .brand:hover {
  text-decoration: none;
}
.topbar .brand-logo {
  height: 28px;
  width: auto;
  display: block;
}
.topbar .brand-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  flex: 1;
}
.nav-links a {
  display: inline-block;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.nav-links a:hover {
  background: var(--bg-muted);
  text-decoration: none;
  color: var(--text);
}
.nav-links a.active {
  background: var(--bg-muted);
  color: var(--text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-user {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.lang-switcher select {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
}

form.inline {
  display: inline;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    transform 0.05s;
}
.btn:hover {
  text-decoration: none;
  background: var(--bg-muted);
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}
.btn[disabled],
.btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);

  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* Cards ------------------------------------------------------------------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}
.card.danger {
  border-color: var(--danger);
}
.card h2:first-child,
.card h3:first-child {
  margin-top: 0;
}

/* Tables ------------------------------------------------------------------ */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.table th,
.table td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  background: var(--bg-muted);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tbody tr:hover {
  background: var(--bg-muted);
}

/* Forms ------------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.field label {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.field .help {
  color: var(--text-muted);
  font-size: 0.8rem;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='url'],
input[type='search'],
input[type='date'],
input[type='datetime-local'],
input[type='time'],
input:not([type]),
select,
textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  font-size: 0.95rem;
  font-family: inherit;
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}
textarea {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}

input[type='file'] {
  font-size: 0.9rem;
}

input:disabled,
input[disabled],
input.disabled {
  background: var(--bg-elevated);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.4rem 0.75rem;
}
label.checkbox {
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
  cursor: pointer;
}
label.checkbox input {
  accent-color: var(--primary);
}
label.checkbox-inline {
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
  cursor: pointer;
  font-size: 0.9rem;
}
label.checkbox-inline input {
  accent-color: var(--primary);
}

.required {
  color: var(--danger);
  font-weight: 600;
}
.optional {
  color: var(--text-subtle);
  font-size: 0.8em;
  font-weight: normal;
}

.spec-link, .spec-link-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2em;
  height: 1.2em;
  border-radius: 50%;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 0.75em;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--border);
}
.spec-link:hover, .spec-link-header:hover  {
  background: var(--primary);
  color: var(--primary-contrast);
  border-color: var(--primary);
  text-decoration: none;
}

.spec-link-header {
    right: 0;
    position: absolute;
    margin-right: 20px;

}


/* Flash ------------------------------------------------------------------- */
.flash-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}
.flash {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
  background: var(--bg-elevated);
}
.flash-ok,
.flash-success {
  background: color-mix(in srgb, var(--success) 12%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
  color: var(--success);
}
.flash-err,
.flash-error {
  background: color-mix(in srgb, var(--danger) 12%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  color: var(--danger);
}
.flash-info {
  background: color-mix(in srgb, var(--info) 12%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--info) 40%, var(--border));
  color: var(--info);
}
.flash-warn,
.flash-warning {
  background: color-mix(in srgb, var(--warning) 15%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--warning) 45%, var(--border));
  color: var(--warning);
}

/* Errors block ------------------------------------------------------------ */
.errors {
  background: color-mix(in srgb, var(--danger) 10%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  color: var(--danger);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.errors ul {
  margin: 0.3rem 0 0 1.2rem;
  padding: 0;
}

/* Tabs -------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  overflow-x: auto;
}
.tabs a {
  display: inline-block;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-muted);
  white-space: nowrap;
  border: 1px solid transparent;
  border-bottom: none;
}
.tabs a:hover {
  text-decoration: none;
  color: var(--text);
  background: var(--bg-muted);
}
.tabs a.active {
  color: var(--text);
  background: var(--bg-elevated);
  border-color: var(--border);
  border-bottom-color: var(--bg-elevated);
  margin-bottom: -1px;
}

/* Badges ------------------------------------------------------------------ */
.badge {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-muted);
  color: var(--text-muted);
  border: 1px solid var(--border);
  vertical-align: middle;
}
.badge-ok,
.badge-success {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
}
.badge-warn {
  background: color-mix(in srgb, var(--warning) 15%, transparent);
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 40%, var(--border));
}
.badge-err {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}

/* Brand assets & thumbnails ----------------------------------------------- */
.brand-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-muted);
}
.brand-preview img {
  max-width: 160px;
  max-height: 80px;
  background: #fff;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.brand-preview.dark img {
  background: #111;
}

.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
}

/* Footer ------------------------------------------------------------------ */
.site-footer {
  /* padding: 2rem 1rem 1rem; */
  color: var(--text-subtle);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  margin-top: auto;

  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
}
.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: center;
  justify-content: space-between;
}
.site-footer-meta {
  color: var(--text-subtle);
}
.site-footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}
.site-footer-links li {
  display: inline-flex;
}
.site-footer-links a {
  color: var(--text-muted);
}
.site-footer-links a:hover {
  color: var(--text);
}

/* Login page background --------------------------------------------------- */

body.is-login {
  background-color: var(--bg-elevated);
  background-image: var(--login-bg-url, none);
  background-repeat: no-repeat;
  background-position: center calc(100% - 3.5rem);
  background-size: contain;
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
[data-theme='dark'] body.is-login {
  background-blend-mode: multiply;
}

body.is-login main {
  flex: 1;
}

.auth-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 5rem;
  margin-top: 1rem;
}
.auth-brand .auth-logo {
  height: 2.5rem;
  width: auto;
}

.auth-lang {
  display: flex;
  justify-content: flex-end;
  margin: -0.5rem 0 1rem;
}
.auth-lang select {
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
}

/* Utility ----------------------------------------------------------------- */
.muted {
  color: var(--text-muted);
}
.subtle {
  color: var(--text-subtle);
}
.text-right {
  text-align: right;
}
.text-center {
  text-align: center;
}
.mono {
  font-family: var(--font-mono);
}
.nowrap {
  white-space: nowrap;
}

.feed-links {
  list-style: none;
  padding: 0;
  margin: 0;
}
.feed-links li {
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.feed-links li:last-child {
  border-bottom: 0;
}
.feed-links .feed-name {
  color: var(--text-muted);
}
.feed-links a {
  word-break: break-all;
}

/* Error pages ------------------------------------------------------------- */
.error-page {
  text-align: center;
  padding: 3rem 1.5rem;
}
.error-page h1 {
  font-size: 4rem;
  color: var(--primary);
  margin: 0;
}
.error-detail {
  text-align: left;
  margin-top: 1rem;
}

/* Auth page --------------------------------------------------------------- */
.auth-wrap {
  max-width: 380px;
  margin: 4rem auto;
}
.auth-wrap h1 {
  text-align: center;
  margin-bottom: 1rem;
}

/* Maps -------------------------------------------------------------------- */
.map-container {
  height: 380px;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-muted);
}
.map-container-large {
  height: 70vh;
  min-height: 460px;
}

.map-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.map-toolbar input[type='text'] {
  flex: 1 1 240px;
  min-width: 180px;
}

.geocode-results {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  display: none;
  box-shadow: var(--shadow-sm);
}
.geocode-results.open {
  display: block;
}
.geocode-results li {
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.geocode-results li:last-child {
  border-bottom: 0;
}
.geocode-results li:hover {
  background: var(--bg-muted);
}
.geocode-results li.empty {
  cursor: default;
  color: var(--text-muted);
  font-style: italic;
}
.geocode-results li.empty:hover {
  background: transparent;
}

.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  pointer-events: none;
}

/* Dark-mode — OSM tiles are bright, so invert them. */
[data-theme='dark'] .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.95);
}
[data-theme='dark'] .leaflet-container {
  background: var(--bg-muted);
}
[data-theme='dark'] .leaflet-control-attribution {
  background: rgba(23, 28, 45, 0.85) !important;
  color: var(--text-muted) !important;
}
[data-theme='dark'] .leaflet-control-attribution a {
  color: var(--primary);
}
[data-theme='dark'] .leaflet-popup-content-wrapper,
[data-theme='dark'] .leaflet-popup-tip {
  background: var(--bg-elevated);
  color: var(--text);
}

/* Fieldset legend spacing inside station form */
fieldset.card-inner {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem 1rem;
  margin: 0.5rem 0;
  background: var(--bg-elevated);
}
fieldset.card-inner legend {
  padding: 0 0.4rem;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Responsive tweaks ------------------------------------------------------- */
@media (max-width: 720px) {
  .topbar-inner {
    flex-wrap: wrap;
  }
  .nav-links {
    order: 3;
    flex-basis: 100%;
    overflow-x: auto;
  }
  h1 {
    font-size: 1.35rem;
  }
  .table th,
  .table td {
    padding: 0.5rem 0.55rem;
  }
}
