:root {
  --brown: #3a2c22;
  --red: #b23a30;
  --red-dark: #93302a;
  --blue: #4a90d9;
  --blue-dark: #3f7fc4;
  --panel: #e6e6e6;
  --panel-light: #f3f1ee;
  --text: #2b2b2b;
  --muted: #777;
  --border: #d5d5d5;
  --white: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: #fafafa;
}

/* ---------- Header ---------- */
.topbar {
  background: var(--brown);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand .brand-logo { height: 60px; width: auto; display: block; }
.topbar .site { font-size: 26px; font-weight: 700; letter-spacing: 1px; }

/* ---------- Nav / actions ---------- */
.actionbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 28px 0;
  align-items: center;
}
.actionbar .who { margin-right: auto; color: var(--muted); font-size: 14px; }
.actionbar .who strong { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 4px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
}
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); }
.btn-grey { background: #e4e4e4; color: #333; border: 1px solid #bbb; }
.btn-grey:hover { background: #d8d8d8; }
.btn-blue { background: var(--blue); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Dashboard layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  padding: 20px 28px 40px;
}
@media (max-width: 950px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border-radius: 12px;
  padding: 20px;
}
.card-light { background: var(--panel-light); border-radius: 12px; padding: 18px; }

.room-photo {
  width: 100%;
  height: 220px;
  border-radius: 8px;
  background: #ccc center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  font-size: 14px;
}
.thumbs { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.thumbs img {
  width: 90px; height: 60px; object-fit: cover; border-radius: 6px; cursor: pointer;
  border: 2px solid transparent;
}
.thumbs img.active { border-color: var(--red); }

.left-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
@media (max-width: 520px) { .left-cols { grid-template-columns: 1fr; } }

.section-title { text-align: center; font-weight: 700; margin: 0 0 12px; }

.room-btn {
  display: block;
  width: 100%;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.room-btn.active { outline: 3px solid var(--brown); }
.room-btn:hover { background: var(--red-dark); }

.desc { white-space: pre-line; font-size: 14px; line-height: 1.6; }

/* ---------- Booking panel ---------- */
.panel-title { font-size: 22px; font-weight: 700; margin: 4px 0 16px; }
.date-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.date-row label { font-weight: 600; font-size: 15px; }
.date-row input[type=date] {
  padding: 8px 12px; border-radius: 20px; border: 1px solid #999; font-size: 15px;
}

.slots-box { background: var(--panel-light); border-radius: 10px; padding: 18px; }
.slots-box h3 { margin: 0 0 14px; }
.slot-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 640px) { .slot-grid { grid-template-columns: repeat(2, 1fr); } }

.slot {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 9px 6px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.slot:hover { background: var(--blue-dark); }
.slot.selected { outline: 3px solid var(--brown); }
.slot.taken { background: #b9b9b9; cursor: help; }
.slot.taken.mine { background: #7a9e5f; cursor: pointer; }

.selection-head {
  display: flex; align-items: center; justify-content: space-between; margin: 24px 0 12px;
}
.selection-head h2 { margin: 0; font-size: 20px; }

.selection-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; min-height: 60px; }
@media (max-width: 640px) { .selection-grid { grid-template-columns: repeat(2, 1fr); } }
.sel-chip {
  background: #fff; border: 1px solid var(--border); border-radius: 4px;
  padding: 10px; font-size: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.12);
  display: flex; flex-direction: column; gap: 4px;
}
.sel-chip .x { align-self: flex-end; cursor: pointer; color: var(--red); font-weight: 700; }
.empty-hint { color: var(--muted); grid-column: 1 / -1; font-style: italic; }

.confirm-row { display: flex; justify-content: center; gap: 16px; margin-top: 24px; }
.release-hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: 12px 20px; border-radius: 6px;
  opacity: 0; transition: opacity .3s; z-index: 100; max-width: 90%;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--red-dark); }
.toast.ok { background: #3c7d3c; }

/* ---------- Login ---------- */
.login-wrap { min-height: calc(100vh - 72px); display: flex; align-items: center; justify-content: center; }
.login-card {
  background: #fff; border-radius: 12px; padding: 36px; width: 360px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 15px;
}
.error-box {
  background: #fdecea; color: #a33; border: 1px solid #f5c6c2;
  padding: 10px 12px; border-radius: 6px; font-size: 14px; margin-bottom: 16px;
}

/* ---------- Tables (admin) ---------- */
.admin-wrap { padding: 24px 28px 60px; max-width: 1100px; margin: 0 auto; }
.admin-wrap h1 { margin-top: 0; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: var(--brown); color: #fff; font-weight: 600; }
tr:hover td { background: #faf7f5; }
.badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.badge.super_admin { background: #7a2f2a; color: #fff; }
.badge.admin { background: #b6772a; color: #fff; }
.badge.user { background: #4a7fb0; color: #fff; }
.badge.off { background: #999; color: #fff; }

.form-inline { background: var(--panel-light); padding: 18px; border-radius: 10px; margin-bottom: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 4px; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px;
}
.links { display: flex; gap: 16px; }
.links a { color: var(--red); font-weight: 600; text-decoration: none; }

/* ---------- Admin image gallery ---------- */
.img-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.img-thumb { position: relative; display: inline-block; }
.img-thumb img { width: 54px; height: 40px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.img-x {
  position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff;
  width: 16px; height: 16px; line-height: 15px; text-align: center; border-radius: 50%;
  font-size: 12px; cursor: pointer;
}
.img-add { font-size: 11px; max-width: 150px; }

/* ---------- Week view ---------- */
.week-controls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.week-controls select { padding: 7px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; }
.week-label { font-weight: 700; min-width: 150px; text-align: center; }
.legend { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: #555; }
.legend .chip { width: 16px; height: 16px; border-radius: 3px; display: inline-block; }
.chip.free { background: #cfe8cf; border: 1px solid #9c9; }
.chip.taken { background: #b9b9b9; }
.chip.mine { background: #7a9e5f; }

.week-table { width: 100%; border-collapse: collapse; }
.week-table th, .week-table td { border: 1px solid var(--border); padding: 0; }
.week-table th { background: var(--brown); color: #fff; padding: 8px 6px; font-size: 13px; }
.week-table .time-col { background: #f3f1ee; font-size: 12px; font-weight: 600; padding: 4px 8px; white-space: nowrap; }
.wcell { height: 26px; cursor: default; }
.wcell.free { background: #cfe8cf; cursor: pointer; }
.wcell.free:hover { background: #aad6aa; }
.wcell.taken { background: #c7c7c7; }
body.is-admin .wcell.taken { cursor: pointer; }
body.is-admin .wcell.taken:hover { background: #b23a30; }
.wcell.mine { background: #7a9e5f; cursor: pointer; }
.wcell.mine:hover { background: #6a8e50; }
