/* Loft theme: warm concrete, cream paper, charcoal steel, terracotta brick. */
:root {
  --bg: #cfc7bb;              /* warm concrete */
  --surface: #ece5da;         /* cream paper */
  --surface-2: #e2dacd;       /* table heads, inputs */
  --text: #2b2622;
  --muted: #6f655a;
  --border: #bdb2a3;
  --border-strong: #a69a89;

  --steel: #2c2825;           /* header */
  --steel-2: #3a3430;         /* sub-header */
  --steel-ink: #e9e1d4;

  --primary: #b5543a;         /* terracotta */
  --primary-hover: #96432d;
  --primary-ink: #fbf6ee;
  --ok: #5d7a4e;              /* olive */
  --ok-hover: #4e6841;
  --danger: #9a4433;          /* brick */

  --available: #f3ede3;
  --available-hover: #e6d7c3;
  --pending: #d4a24c;         /* ochre */
  --pending-ink: #3b2a0c;
  --reserved: #7e3a2c;        /* deep brick */
  --reserved-ink: #f6ece2;
  --past: #c9c0b3;
  --past-2: #c1b7a9;
  --selected: #4b5d68;        /* blue steel */

  --radius: 4px;
  --shadow: 0 1px 2px rgba(40, 30, 20, .08), 0 4px 14px rgba(40, 30, 20, .06);
  --font-head: Rockwell, "Roboto Slab", "Courier New", Georgia, serif;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  line-height: 1.5;
  background-color: var(--bg);
  /* faint concrete grain */
  background-image:
    radial-gradient(rgba(255, 255, 255, .10) 1px, transparent 1px),
    radial-gradient(rgba(60, 45, 30, .05) 1px, transparent 1px);
  background-size: 5px 5px, 7px 7px;
  background-position: 0 0, 2px 3px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: .01em; color: #2a2420; }
h1 { font-size: 1.7rem; margin: 0.4rem 0 0.8rem; }
h2 { font-size: 1.25rem; margin: 1.6rem 0 0.6rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 0.5rem; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 18px; }
main.container { padding-top: 24px; padding-bottom: 56px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.inline { display: inline; }
.empty { color: var(--muted); font-style: italic; }
.hint { color: var(--muted); margin: 0 0 8px; }

/* Header: dark steel beam with a copper edge */
.topbar { background: var(--steel); border-bottom: 3px solid var(--primary); color: var(--steel-ink); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; color: var(--steel-ink); letter-spacing: .04em; }
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark { color: var(--primary); }
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav a { color: var(--steel-ink); opacity: .85; }
.topnav a:hover, .topnav a.active { opacity: 1; color: #fff; }
.topnav .muted { color: #a99d8e; }
.link-btn { background: none; border: 0; color: var(--steel-ink); opacity: .85; cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { opacity: 1; text-decoration: underline; text-underline-offset: 3px; }
.lang-switch { display: inline-flex; border: 1px solid #5a514a; border-radius: 3px; overflow: hidden; }
.lang-switch a { padding: 2px 9px; font-size: 0.78rem; letter-spacing: .06em; color: #b9ad9e; opacity: 1; }
.lang-switch a.active { background: var(--primary); color: var(--primary-ink); }
.lang-switch a:hover { text-decoration: none; color: #fff; }
.subnav { background: var(--steel-2); border-bottom: 1px solid #241f1c; }
.subnav .container { display: flex; gap: 2px; align-items: center; height: 44px; }
.subnav a { padding: 6px 13px; border-radius: 3px; color: #c4b8a8; font-size: 0.93rem; }
.subnav a.active { background: rgba(233, 225, 212, .12); color: #f3ebdf; box-shadow: inset 0 -2px 0 var(--primary); }
.subnav a:hover { text-decoration: none; color: #f3ebdf; }
.role-tag { margin-left: auto; font-size: 0.82rem; color: #a99d8e; letter-spacing: .03em; }

/* Generic */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.narrow { max-width: 420px; margin: 48px auto; }
.center { text-align: center; }
.error-code { font-size: 3.2rem; color: var(--muted); margin: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head h1, .page-head h2 { margin-top: 0.2rem; }
.page-head p { margin: 0.2rem 0; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; border-left-width: 4px; }
.flash-success { background: #e3e6d6; border-color: #a9b394; border-left-color: var(--ok); color: #34452b; }
.flash-error { background: #eedcd3; border-color: #d2ab9d; border-left-color: var(--danger); color: #6e2a1e; }
.hero { margin: 16px 0 24px; }
.hero h1 { font-size: 2.1rem; margin-bottom: 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.property-card { color: var(--text); display: flex; flex-direction: column; border-top: 3px solid var(--primary); transition: box-shadow .15s, transform .15s; }
.property-card:hover { color: var(--text); text-decoration: none; box-shadow: 0 8px 22px rgba(40, 30, 20, .14); transform: translateY(-1px); }
.property-card h2 { margin: 0 0 4px; }
.property-card p { margin: 4px 0; }
.property-card .meta { margin-top: auto; padding-top: 12px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.link-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.link-list li { padding: 8px 14px; border-bottom: 1px solid var(--border); }
.link-list li:last-child { border-bottom: 0; }
.card .link-list { box-shadow: none; }
.danger-zone { border-color: #c9a091; }
.danger-zone form { display: flex; gap: 12px; align-items: center; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 7px 15px; border: 1px solid var(--border-strong); border-radius: 3px; background: var(--surface); color: var(--text); font: inherit; font-size: 0.92rem; cursor: pointer; white-space: nowrap; }
.btn:hover { color: var(--text); text-decoration: none; background: #e4dccf; border-color: #95887a; }
.btn-sm { padding: 3px 10px; font-size: 0.82rem; }
.btn-primary { background: var(--primary); border-color: var(--primary-hover); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); color: var(--primary-ink); border-color: #7d3726; }
.btn-ok { background: var(--ok); border-color: var(--ok-hover); color: #f4f0e6; }
.btn-ok:hover { background: var(--ok-hover); color: #f4f0e6; }
.btn-danger { background: transparent; border-color: #c08f80; color: var(--danger); }
.btn-danger:hover { background: #ead6cc; color: #7e3326; border-color: var(--danger); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Forms */
.form { display: grid; gap: 14px; }
.form.grid-2 { grid-template-columns: 1fr 1fr; }
.form.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.form label, .dialog label, .filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.86rem; font-weight: 600; color: #4a423b; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; align-self: end; padding-bottom: 8px; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 3px; background: #f6f1e9; color: var(--text); font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(181, 84, 58, .25); border-color: var(--primary); }
input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }
.form-actions { display: flex; gap: 8px; }
.filters { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 16px; flex-wrap: wrap; }
@media (max-width: 720px) {
  .form.grid-2, .form.grid-3 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
}

/* Data tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.card table.data { border: 1px solid var(--border); }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: .07em; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
table.data td { padding: 10px 12px; border-bottom: 1px solid #d3c9bb; vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: rgba(181, 84, 58, .04); }
.note { font-size: 0.85rem; color: var(--muted); margin-top: 4px; font-style: italic; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 3px; font-size: 0.74rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; background: var(--past); color: #554b41; }
.badge.b-pending { background: var(--pending); color: var(--pending-ink); }
.badge.b-reserved { background: var(--reserved); color: var(--reserved-ink); }
.badge.b-rejected { background: #dcc3b8; color: #6e2a1e; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: 14px 18px; color: var(--text); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat:hover { color: var(--text); text-decoration: none; border-color: var(--border-strong); border-left-color: var(--primary-hover); }
.stat-value { font-family: var(--font-head); font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: 0.85rem; }

/* Week navigation */
.week-nav { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.week-range { margin-left: 8px; font-family: var(--font-head); font-size: 1.05rem; }

/* Booking grid */
.grid-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); }
table.week-grid { width: 100%; min-width: 720px; border-collapse: separate; border-spacing: 0; table-layout: fixed; user-select: none; -webkit-user-select: none; }
.week-grid th, .week-grid td { border-right: 1px solid #cfc5b7; border-bottom: 1px solid #cfc5b7; }
.week-grid tr > :last-child { border-right: 0; }
.week-grid tbody tr:last-child > * { border-bottom: 0; }
.week-grid thead th { position: sticky; top: 0; background: var(--steel-2); color: var(--steel-ink); padding: 8px 4px; font-weight: 600; z-index: 1; border-color: #2a2522; }
.week-grid .corner { width: 64px; }
.week-grid th.day .wd { display: block; text-transform: uppercase; font-size: 0.7rem; letter-spacing: .1em; color: #b2a696; }
.week-grid th.day .dl { display: block; font-family: var(--font-head); font-size: 0.98rem; }
.week-grid th.day.today { background: var(--primary); color: var(--primary-ink); }
.week-grid th.day.today .wd { color: #f6d6c8; }
.week-grid th.hour { font-weight: 500; font-size: 0.78rem; color: var(--muted); text-align: right; padding: 2px 8px 0; vertical-align: top; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.week-grid td.slot { height: 34px; padding: 0 6px; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: background-color .1s; }

.s-available { background: var(--available); }
.s-pending { background: var(--pending); color: var(--pending-ink); }
.s-reserved { background: var(--reserved); color: var(--reserved-ink); }
.s-past { background: var(--past); }

/* Past bookings dimmed, past empty cells hatched */
.week-grid td.slot.s-past { background: repeating-linear-gradient(-45deg, var(--past), var(--past) 6px, var(--past-2) 6px, var(--past-2) 12px); }
.week-grid td.slot.is-past.s-pending, .week-grid td.slot.is-past.s-reserved { opacity: .55; }
.week-grid td.slot.s-pending { border-bottom-color: #c19140; }
.week-grid td.slot.s-reserved { border-bottom-color: #6a3024; }

[data-mode="public"] td.slot.s-available { cursor: pointer; touch-action: none; }
[data-mode="public"] td.slot.s-available:hover { background: var(--available-hover); }
[data-mode="public"] td.slot.selected { background: var(--selected); border-bottom-color: #3e4e58; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
[data-mode="admin"] td.slot[data-booking] { cursor: pointer; }
[data-mode="admin"] td.slot.hl { filter: brightness(0.9); }
.week-grid td.slot:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.week-grid .guest { font-weight: 600; }

.legend { display: flex; gap: 18px; list-style: none; padding: 0; margin: 12px 0 0; color: var(--muted); font-size: 0.85rem; flex-wrap: wrap; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 16px; height: 16px; border-radius: 2px; border: 1px solid var(--border-strong); display: inline-block; }

/* Dialog */
.dialog { border: 1px solid var(--border-strong); border-top: 4px solid var(--primary); border-radius: var(--radius); padding: 22px 24px; width: min(440px, 92vw); background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(25, 18, 12, .4); }
.dialog::backdrop { background: rgba(32, 26, 22, .6); }
.dialog h2 { margin: 0 0 6px; }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog .summary { margin: 0 0 4px; font-weight: 600; color: var(--primary); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.dialog-actions form { display: inline; }
.dialog-actions form[hidden] { display: none; }
.details { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0; }
.details dt { color: var(--muted); font-size: 0.86rem; }
.details dd { margin: 0; word-break: break-word; }

/* Hours after midnight (still part of the previous day's column) */
.week-grid th.hour.next-day { background: #d8cfc1; }
.week-grid th.hour small { display: block; font-size: 0.62rem; color: var(--primary); letter-spacing: .04em; }
.week-grid tr.midnight > * { border-top: 2px solid var(--steel-2); }

/* Selection bar under the visitor grid: stays visible at the bottom while scrolling */
.selection-bar {
  position: sticky; bottom: 12px; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 14px;
  background: var(--steel-2); color: var(--steel-ink);
  border-radius: var(--radius); border-left: 4px solid #6f655a;
  box-shadow: 0 6px 18px rgba(25, 18, 12, .25);
}
.selection-bar.has-selection { border-left-color: var(--primary); }
.selection-bar .selection-text { font-weight: 600; }
.selection-bar:not(.has-selection) .selection-text { font-weight: 400; color: #b2a696; }
.selection-actions { display: flex; gap: 8px; }
.selection-bar .btn:not(.btn-primary) { background: transparent; color: var(--steel-ink); border-color: #6a5f56; }
.selection-bar .btn:not(.btn-primary):hover { background: rgba(255, 255, 255, .08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Accounts */
.badge.b-cancelled { background: #d9d0c4; color: #6f655a; text-decoration: line-through; }
.form-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 16px 0 0; font-size: 0.9rem; }
.resend { margin: -4px 0 14px; }
.big-icon { font-size: 2.6rem; color: var(--primary); line-height: 1; }
.small { font-size: 0.85rem; margin: 0; }
input[readonly] { background: var(--surface-2); color: var(--muted); }
