/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg:           #eef3f0;
  --color-surface:      #ffffff;
  --color-border:       #cfddd6;
  --color-primary:      #1a6b45;
  --color-primary-hover:#145537;
  --color-primary-faint:#e6f2ec;
  --color-danger:       #c0392b;
  --color-danger-faint: #fdf0ef;
  --color-success:      #1a7a3c;
  --color-muted:        #6a7f74;
  --color-text:         #0f2318;
  --radius:             11px;
  --shadow:             0 2px 8px rgba(0,0,0,.07);
  --shadow-lg:          0 6px 20px rgba(0,0,0,.11);
  --max-w:              800px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--color-bg);
  color: var(--color-text);
  padding: 1.25rem 1rem;
}

/* ── Layout ──────────────────────────────────────────────────────────────────*/
.app { max-width: var(--max-w); margin: 0 auto; }

/* ── Header ──────────────────────────────────────────────────────────────────*/
header {
  background: linear-gradient(135deg, #1a6b45 0%, #228b5a 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
}
.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .5rem;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: .875rem;
  cursor: pointer;
}
.header-brand:hover  { opacity: .85; }
.header-brand:active { opacity: .7; }
.header-icon {
  font-size: 2.25rem;
  line-height: 1;
  flex-shrink: 0;
}
header h1 { font-size: 1.35rem; font-weight: 700; color: #fff; }
header p  { color: rgba(255,255,255,.72); font-size: .875rem; margin-top: .1rem; }

.header-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  align-self: stretch;
  gap: .25rem;
}
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 2px;
}
.lang-btn {
  background: transparent;
  border: none;
  border-radius: 18px;
  color: rgba(255,255,255,.65);
  cursor: pointer;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  padding: .2rem .55rem;
  transition: background .15s, color .15s;
}
.lang-btn:hover { color: #fff; }
.lang-btn--active {
  background: rgba(255,255,255,.22);
  color: #fff;
}
.header-user-name {
  font-size: .8125rem;
  color: rgba(255,255,255,.85);
  font-weight: 500;
  text-align: right;
}

/* ── Login screen ────────────────────────────────────────────────────────────*/
.login-body {
  padding: 3rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
}
.login-lead {
  font-size: 1rem;
  color: var(--color-muted);
}
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  padding: .65rem 1.4rem;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  font-size: .9375rem;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, background .15s;
}
.btn-google:hover {
  background: var(--color-bg);
  box-shadow: var(--shadow-lg);
}
.google-icon { flex-shrink: 0; }

/* ── Sections ─────────────────────────────────────────────────────────────── */
section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
section h2 {
  font-size: .8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-primary);
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-primary-faint);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Form ─────────────────────────────────────────────────────────────────── */
.form-body { padding: 1.25rem; display: grid; gap: .9rem; }

.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-size: .8125rem; font-weight: 600; color: var(--color-text); }
.field input, .field select {
  border: 1px solid var(--color-border);
  border-radius: 7px;
  padding: .5rem .75rem;
  font-size: .9375rem;
  width: 100%;
  background: white;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,107,69,.13);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }

.required { color: var(--color-danger); font-weight: 600; }
.optional  { font-weight: 400; color: var(--color-muted); font-size: .75rem; }
.hint      { font-size: .8rem; color: var(--color-muted); }

/* ── Validation error states ─────────────────────────────────────────────── */
.field--error > input,
.field--error > select {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(192,57,43,.1);
}
.field-error {
  font-size: .8rem;
  color: var(--color-danger);
  font-weight: 500;
}

/* ── Day checkboxes ──────────────────────────────────────────────────────── */
.checkbox-group {
  display: flex; flex-wrap: wrap; gap: .4rem;
  padding: .2rem 0;
}
.checkbox-group label {
  display: inline-block;
  font-size: .875rem; font-weight: 400; color: var(--color-text);
  cursor: pointer;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: .25rem .75rem;
  transition: background .12s, border-color .12s, color .12s;
  user-select: none;
}
/* Visually hide the native checkbox — the pill highlight is the checked indicator.
   Still in the accessibility tree and fully interactive. */
.checkbox-group input[type=checkbox],
.checkbox-group input[type=radio] {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}
.checkbox-group label:has(input:checked) {
  background: var(--color-primary-faint);
  border-color: var(--color-primary);
  color: var(--color-primary);
  font-weight: 600;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .875rem; font-weight: 600;
  padding: .5rem 1.1rem;
  border-radius: 7px;
  border: none; cursor: pointer;
  transition: background .15s, box-shadow .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--color-primary); color: white;
  box-shadow: 0 1px 4px rgba(26,107,69,.35);
}
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: 0 3px 8px rgba(26,107,69,.4); }
.btn-secondary { background: white; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-danger    { background: white; color: var(--color-danger); border: 1px solid #f5c6c2; }
.btn-danger:hover { background: var(--color-danger-faint); }
.btn-sm { padding: .28rem .65rem; font-size: .8rem; font-weight: 500; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.run-check-btn { flex-shrink: 0; }

.form-actions {
  display: flex; gap: .5rem; justify-content: flex-end;
  padding: .9rem 1.25rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-primary-faint);
}

/* ── Monitor list ─────────────────────────────────────────────────────────── */
.monitor-list { list-style: none; }
.monitor-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  transition: background .12s;
}
.monitor-item:hover { background: var(--color-primary-faint); }
.monitor-item:last-child { border-bottom: none; }
.monitor-main { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.monitor-name-row { display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; }
.monitor-name { font-weight: 600; word-break: break-word; }
.monitor-meta { font-size: .8125rem; color: var(--color-muted); }
.monitor-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* Active/inactive badge */
.badge {
  display: inline-block;
  font-size: .68rem; font-weight: 700;
  padding: .1rem .45rem; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .04em;
}
.badge-active   { background: #d1f5e0; color: #155e32; }
.badge-inactive { background: #f0f0f0; color: var(--color-muted); }

/* ── Notifications table ──────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
  text-align: left; padding: .55rem 1.25rem;
  font-size: .75rem; font-weight: 700; color: var(--color-primary);
  text-transform: uppercase; letter-spacing: .05em;
  background: var(--color-primary-faint); border-bottom: 1px solid var(--color-border);
}
td { padding: .65rem 1.25rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f5fbf7; }
.status-sent   { color: var(--color-success); font-weight: 500; }
.status-failed { color: var(--color-danger);  font-weight: 500; }

/* ── Availability results ─────────────────────────────────────────────────── */
.avail-timestamp {
  font-size: .75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--color-muted);
  margin-left: .5rem;
}
.avail-error {
  padding: .75rem 1rem;
  border-radius: 6px;
  background: #fff0f0;
  color: #c0392b;
  font-size: .875rem;
  word-break: break-word;
}
.avail-empty {
  padding: 1.75rem 1.25rem;
  text-align: center;
  color: var(--color-muted);
  font-size: .9375rem;
}

.avail-venue {
  border-bottom: 1px solid var(--color-border);
}
.avail-venue:last-of-type { border-bottom: none; }
.avail-venue--auth-required { background: color-mix(in srgb, var(--color-warning, #f59e0b) 8%, transparent); }
.avail-auth-notice {
  font-size: .85rem;
  color: var(--color-warning, #b45309);
  margin: .25rem 0 .75rem;
}

.avail-venue-name {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-primary);
  padding: .6rem 1.25rem .4rem;
}

.avail-slot-list { list-style: none; }
.avail-slot {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem 1.25rem;
  border-top: 1px solid var(--color-border);
  font-size: .9375rem;
}
.avail-slot:hover { background: var(--color-primary-faint); }

.avail-slot-date  { color: var(--color-muted); font-size: .8125rem; min-width: 6.5rem; }
.avail-slot-time  { font-weight: 600; }
.avail-slot-court {
  font-size: .8125rem;
  color: var(--color-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: .1rem .6rem;
}
.avail-slot-court a {
  color: inherit;
  text-decoration: none;
}
.avail-slot-court a:hover { text-decoration: underline; }

.avail-slot-list--linked { border-top: 2px dashed var(--color-border); margin-top: .25rem; }
.avail-slot--linked { background: #fffbea; }
.avail-slot--linked:hover { background: #fff3c4; }
.avail-slot-badge {
  font-size: .75rem;
  font-weight: 600;
  color: #7a5700;
  background: #fff0b3;
  border: 1px solid #e6c800;
  border-radius: 20px;
  padding: .1rem .55rem;
  white-space: nowrap;
}

.avail-book-link {
  display: inline-block;
  padding: .45rem 1.25rem .65rem;
  font-size: .8125rem;
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}
.avail-book-link:hover { text-decoration: underline; }

.avail-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--color-primary-faint);
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.avail-cta-hint {
  font-size: .875rem;
  color: var(--color-muted);
  flex: 1;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: 2rem 1rem;
  color: var(--color-muted); font-size: .9375rem;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 1.25rem; right: 1.25rem;
  background: #0f2318; color: white;
  padding: .65rem 1.1rem; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px);
  transition: opacity .2s, transform .2s;
  pointer-events: none; z-index: 100;
  max-width: 340px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: var(--color-danger); }

/* ── Loading spinner ──────────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 1em; height: 1em;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Site lock icon ──────────────────────────────────────────────────────── */
.site-lock-icon {
  font-size: .7rem;
  opacity: .45;
  margin-left: .15rem;
  vertical-align: middle;
  pointer-events: none;
}

/* ── twojtenis.pl inline auth panel ─────────────────────────────────────── */
.auth-panel {
  margin-top: .65rem;
  padding: .85rem 1rem;
  background: var(--color-primary-faint);
  border: 1px solid var(--color-primary);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.auth-panel-title {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--color-primary);
}
.auth-panel-hint {
  font-size: .8rem;
  color: var(--color-muted);
  margin-top: -.3rem;
}
.auth-panel .field-row { gap: .6rem; }
.auth-panel .field label { font-size: .75rem; }
.auth-panel .field input {
  font-size: .875rem;
  padding: .4rem .65rem;
}
.auth-panel-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Password field with show/hide toggle */
.input-pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-pw-wrap input {
  padding-right: 2.5rem !important;
  width: 100%;
}
.btn-pw-toggle {
  position: absolute;
  right: .4rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  padding: .15rem;
  color: var(--color-muted);
  line-height: 1;
}
.btn-pw-toggle:hover { color: var(--color-text); }

/* ── Version label ────────────────────────────────────────────────────────── */
.app-version {
  text-align: center;
  font-size: .7rem;
  color: var(--color-muted);
  padding: .5rem 0 .25rem;
  opacity: .6;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .field-row { grid-template-columns: 1fr; }
  th:nth-child(4), td:nth-child(4) { display: none; } /* hide court on small screens */
}
