:root {
  --bg: #f5f3ee;
  --card: #fffdf8;
  --ink: #1d1a14;
  --accent: #0e7c86;
  --accent-2: #f3a530;
  --danger: #9b2226;
  --line: #e3ddd1;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 0%, #faf5e7, var(--bg) 50%);
}

header {
  position: sticky;
  top: 0;
  background: linear-gradient(90deg, #fffdf8, #fef8ec);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

header nav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.nav-menu {
  position: relative;
}

.nav-menu > summary {
  list-style: none;
  cursor: pointer;
  font-weight: 700;
}

.nav-menu > summary::-webkit-details-marker {
  display: none;
}

.nav-menu-items {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
  display: grid;
  gap: 4px;
  z-index: 20;
}

.nav-menu-items a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
}

.nav-menu-items a:hover {
  background: #f3eee3;
}

main { max-width: 1060px; margin: 24px auto; padding: 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

.grid {
  display: grid;
  gap: 12px;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

input, select, textarea, button {
  width: 100%;
  padding: 10px;
  border: 1px solid #d0c8bc;
  border-radius: 8px;
  font: inherit;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
}

textarea { min-height: 110px; }

button, .btn {
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border: none;
  display: inline-block;
  width: auto;
  text-decoration: none;
  font-weight: 700;
  padding: 10px 16px;
}

.btn.secondary { background: #4a5b63; }
.btn.warn { background: var(--danger); }

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

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

.month-grid-header,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.month-grid-header {
  margin-bottom: 8px;
  color: #5c584f;
  font-weight: 700;
  text-align: center;
}

.month-cell {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 78px;
  padding: 8px;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
}

.month-cell .day {
  font-weight: 700;
  margin-bottom: 6px;
}

.month-cell .count {
  font-size: 12px;
  color: #5c584f;
}

.month-cell.outside {
  opacity: 0.45;
  background: #f6f2e9;
}

.month-cell.today {
  border-color: var(--accent);
}

.month-cell.selected {
  background: #e8f4f7;
  border-color: #77b7bf;
}

.slot-row.drop-over td {
  background: #eef7fb;
}

.appt-chip {
  border: 1px dashed #7ea8b2;
  border-radius: 8px;
  padding: 6px 8px;
  background: #f8fcfe;
  cursor: grab;
}

.appt-chip.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.picker-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffcf5;
}

.pick-btn {
  text-align: left;
  border: 1px solid #d6cec0;
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
}

.pick-btn.selected {
  border-color: #6faab3;
  background: #e7f5f8;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  background: #e6f4f6;
  color: #07444a;
  font-size: 12px;
}

.appt-type.planinis { background: #e7f2ff; color: #153b66; }
.appt-type.skubus { background: #ffe7e7; color: #7c1212; }
.appt-type.kontrolinis { background: #fff3d9; color: #744a03; }

.error { color: var(--danger); font-weight: 700; }
.muted { color: #635f56; }

@media (max-width: 640px) {
  main { margin: 14px auto; padding: 0 10px; }
  header { flex-direction: column; gap: 10px; align-items: flex-start; padding: 10px 12px; }
  header nav { width: 100%; gap: 8px; }
  .nav-menu-items {
    position: static;
    min-width: 0;
    box-shadow: none;
    margin-top: 6px;
  }
  header nav a,
  header nav .badge { font-size: 14px; }
  .card { padding: 12px; margin-bottom: 12px; }
  .actions > .btn,
  .actions > form,
  .actions > form > button {
    width: 100%;
  }
  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table th, .table td { white-space: nowrap; }
  .month-grid, .month-grid-header { gap: 4px; }
  .month-cell { min-height: 68px; padding: 6px; }
  .month-cell .count { font-size: 11px; }
}
