:root {
  --navy: #17324d;
  --blue: #2563eb;
  --blue-soft: #eaf2ff;
  --paper: #ffffff;
  --bg: #f4f7fa;
  --text: #1f2937;
  --muted: #64748b;
  --line: #dbe3ec;
  --danger: #b91c1c;
  --success: #15803d;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(23, 50, 77, .08);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { position: relative; z-index: 1000; isolation: isolate; min-height: 72px; padding: 10px clamp(16px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; gap: 24px; color: white; background: linear-gradient(120deg, #102a43, #204b70); box-shadow: var(--shadow); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: white; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; font-size: 24px; font-weight: 800; background: #fff; color: var(--navy); }
.brand strong, .brand small { display: block; }
.brand small { opacity: .75; margin-top: 2px; }
.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav a { color: white; padding: 9px 11px; border-radius: 8px; }
.nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.nav-user { display: grid; gap: 1px; padding: 4px 10px; border-left: 1px solid rgba(255,255,255,.25); font-size: 13px; line-height: 1.2; }
.nav-user small { max-width: 180px; overflow: hidden; opacity: .72; text-overflow: ellipsis; white-space: nowrap; }
.nav-toggle { display: none; }
.container { width: min(1240px, calc(100% - 32px)); margin: 28px auto; min-height: calc(100vh - 150px); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 5px; font-size: clamp(26px, 4vw, 38px); color: var(--navy); }
.page-head p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 700; background: var(--blue); color: white; }
.button:hover { text-decoration: none; filter: brightness(.96); }
.button-secondary { background: white; border-color: var(--line); color: var(--navy); }
.button-danger { background: var(--danger); }
.button-small { min-height: 34px; padding: 6px 10px; font-size: 14px; }
.grid { display: grid; gap: 18px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 24px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.stat strong { display: block; color: var(--navy); font-size: 30px; margin-top: 8px; }
.stat span { color: var(--muted); }
.two-cols { grid-template-columns: 1.5fr 1fr; }
.card h2, .card h3 { color: var(--navy); margin-top: 0; }
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--line); background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { color: var(--navy); background: #f8fafc; font-size: 13px; text-transform: uppercase; letter-spacing: .035em; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; padding: 4px 9px; border-radius: 999px; color: white; font-size: 12px; font-weight: 800; }
.muted { color: var(--muted); }
.form-card { max-width: 1000px; margin-inline: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.field { display: grid; gap: 6px; align-content: start; }
.field-full { grid-column: 1 / -1; }
label, legend { font-weight: 700; color: var(--navy); }
input, select, textarea { width: 100%; border: 1px solid #bdc9d6; border-radius: 9px; padding: 10px 11px; background: white; color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(37,99,235,.16); border-color: var(--blue); }
input[readonly] { background: #f3f6f9; color: #475569; cursor: default; }
textarea { min-height: 95px; resize: vertical; }
fieldset { margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.checks { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; margin-top: 10px; }
.check { display: flex; align-items: center; gap: 8px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; }
.check input { width: auto; }
.password-visibility { justify-self: start; padding: 6px 9px; font-size: 14px; font-weight: 400; }
.help, .error { font-size: 13px; }
.help { color: var(--muted); }
.error { color: var(--danger); font-weight: 700; }
.alert { border-radius: 10px; padding: 13px 15px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: #ecfdf3; color: var(--success); border-color: #a7f3d0; }
.alert-error { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.filter-bar { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 10px; margin-bottom: 16px; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.calendar-legend { display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap; margin: 0 0 14px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--muted); font-size: 13px; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.calendar-swatch { width: 18px; height: 14px; display: inline-block; flex: 0 0 auto; border: 1px solid rgba(23,50,77,.22); border-radius: 3px; }
.calendar-swatch-free { background: #e5f7e9; }
.calendar-swatch-am { background: linear-gradient(90deg, #64748b 50%, #e5f7e9 50%); }
.calendar-swatch-pm { background: linear-gradient(90deg, #e5f7e9 50%, #64748b 50%); }
.room-calendar-wrap { position: relative; max-height: min(72vh, 760px); max-height: min(72dvh, 760px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); scrollbar-gutter: stable; -webkit-overflow-scrolling: touch; }
.room-calendar-wrap:focus-visible { outline: 3px solid rgba(37,99,235,.22); outline-offset: 2px; }
.room-calendar { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.room-calendar th, .room-calendar td { padding: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.room-calendar thead th { position: sticky; top: 0; z-index: 30; height: 54px; background: #eef4fa; box-shadow: 0 1px 0 var(--line); text-align: center; }
.room-calendar-room { position: sticky; left: 0; z-index: 20; width: 158px; min-width: 158px; max-width: 158px; padding: 9px 11px !important; background: #f8fafc; box-shadow: 1px 0 0 var(--line); text-align: left !important; }
.room-calendar thead .room-calendar-room { z-index: 40; background: #e7eff8; }
.room-calendar-room strong, .room-calendar-room span { display: block; overflow: hidden; text-overflow: ellipsis; }
.room-calendar-room strong { color: var(--navy); font-size: 15px; }
.room-calendar-room span { margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.room-calendar-day-head, .room-calendar-day { width: 46px; min-width: 46px; max-width: 46px; }
.room-calendar-day-head span, .room-calendar-day-head strong { display: block; }
.room-calendar-day-head span { color: var(--muted); font-size: 10px; }
.room-calendar-day-head strong { margin-top: 2px; color: var(--navy); font-size: 16px; }
.room-calendar-day-head.is-weekend { background: #e6edf5; }
.room-calendar-cell { position: relative; width: 45px; height: 43px; overflow: hidden; background: #e5f7e9; }
.room-calendar-day.is-weekend .room-calendar-cell { background: #dcf1e2; }
.room-calendar-half { position: absolute; top: 0; bottom: 0; width: 50%; display: block; background: var(--room-event-color); }
.room-calendar-half:hover { z-index: 2; filter: brightness(.9); box-shadow: inset 0 0 0 2px rgba(255,255,255,.75); }
.room-calendar-am { left: 0; border-right: 1px solid rgba(255,255,255,.5); }
.room-calendar-pm { right: 0; }
.room-calendar-day.is-today .room-calendar-cell { box-shadow: inset 0 0 0 2px #f59e0b; }
.room-calendar-day-head.is-today { box-shadow: inset 0 -3px 0 #f59e0b; }
.reservation-filter { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: end; }
.empty { color: var(--muted); text-align: center; padding: 40px 20px; }
.login-wrap { max-width: 450px; margin: 8vh auto; }
.login-wrap .card { padding: 28px; }
.footer { padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }
.summary { display: flex; gap: 14px; flex-wrap: wrap; padding: 13px; border-radius: 10px; background: var(--blue-soft); color: var(--navy); }
.capacity-summary { border: 1px solid #cfe0ff; font-weight: 700; }
.capacity-summary.is-error { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.sticky-table-wrap { position: relative; max-height: min(70vh, 720px); max-height: min(70dvh, 720px); overflow: auto; scrollbar-gutter: stable; -webkit-overflow-scrolling: touch; }
.sticky-table { border-collapse: separate; border-spacing: 0; }
.sticky-table thead th { position: sticky; top: 0; z-index: 20; background: #f8fafc; box-shadow: 0 1px 0 var(--line), 0 5px 12px rgba(23, 50, 77, .08); }
.sticky-table-wrap:focus-visible { outline: 3px solid rgba(37,99,235,.22); outline-offset: 2px; }
.table-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 12px; }
.rooms-table-panel { height: min(76vh, 760px); height: min(76dvh, 760px); min-height: 280px; }
.rooms-summary { position: relative; z-index: 30; border: 1px solid #cfe0ff; box-shadow: 0 8px 20px rgba(23, 50, 77, .10); }
.rooms-table-panel > .rooms-table-wrap { min-height: 0; max-height: none; }
.price-form { display: grid; gap: 20px; }
.price-table-wrap { box-shadow: var(--shadow); }
.price-table input { min-width: 110px; }
.price-table .input-small { width: 78px; min-width: 78px; }
.price-table .price-col-money { min-width: 150px; }
.price-table .season-name { background: #f8fafc; color: var(--navy); vertical-align: middle; }
.input-unit { display: flex; align-items: center; gap: 8px; }
.input-unit input { min-width: 0; }
.input-unit span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.price-fees { display: grid; gap: 18px; }
.price-fees h2 { margin-bottom: 4px; }
.price-fees p { margin: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.price-list-overview { display: grid; gap: 16px; margin-bottom: 20px; }
.price-list-overview h2, .price-list-overview p { margin-bottom: 4px; }
.price-list-overview tr.is-selected td { background: var(--blue-soft); }
.audit-cell strong, .audit-cell small { display: block; }
.audit-cell small { margin-top: 3px; color: var(--muted); }
.price-list-create { margin-bottom: 22px; }
.price-list-create summary { cursor: pointer; color: var(--navy); font-size: 18px; }
.price-list-create[open] summary { margin-bottom: 12px; }
.price-list-create > p { margin-top: 0; }
.price-list-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 24px 0 14px; }
.price-list-heading h2 { margin: 0 0 4px; color: var(--navy); font-size: 26px; }
.price-list-heading p { margin: 0; color: var(--muted); }
.price-list-status { display: inline-flex; align-items: center; justify-content: center; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.price-list-status-draft { color: #854d0e; background: #fef9c3; }
.price-list-status-current { color: #166534; background: #dcfce7; }
.price-list-status-future { color: #1e40af; background: #dbeafe; }
.price-list-status-history { color: #475569; background: #e2e8f0; }
.price-list-meta { margin-bottom: 0; }
.price-publish { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; border-color: #bfdbfe; }
.price-publish h2 { margin-bottom: 4px; }
.price-publish p { margin: 0; max-width: 800px; }

@media (max-width: 850px) {
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .two-cols { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; padding: 8px 12px; color: white; border: 1px solid rgba(255,255,255,.4); border-radius: 8px; background: transparent; }
  .nav { display: none; position: absolute; z-index: 10; top: 70px; left: 16px; right: 16px; padding: 10px; border-radius: 12px; background: var(--navy); box-shadow: var(--shadow); }
  .nav.is-open { display: grid; }
  .nav-user { border-left: 0; border-top: 1px solid rgba(255,255,255,.2); padding-block: 10px; }
  .filter-bar, .reservation-filter { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .container { width: min(100% - 20px, 1240px); margin-top: 18px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .stats, .form-grid, .checks, .filter-bar, .reservation-filter { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .button { width: 100%; }
  .actions { width: 100%; }
  .form-actions { display: grid; }
  .price-list-heading, .price-publish { align-items: stretch; flex-direction: column; }
  .topbar { padding-inline: 14px; }
  .sticky-table-wrap { max-height: 62vh; max-height: 62dvh; }
  .rooms-table-panel { height: 72vh; height: 72dvh; min-height: 260px; }
  .rooms-table-panel > .rooms-table-wrap { max-height: none; }
  .calendar-head { gap: 8px; }
  .calendar-head h2 { text-align: center; font-size: 20px; }
  .calendar-head .button { width: auto; padding-inline: 10px; }
  .room-calendar-wrap { max-height: 68vh; max-height: 68dvh; }
  .room-calendar-room { width: 130px; min-width: 130px; max-width: 130px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .sticky-table-wrap { max-height: 72vh; max-height: 72dvh; }
  .rooms-table-panel { height: 78vh; height: 78dvh; min-height: 240px; }
  .rooms-summary { padding-block: 9px; font-size: 14px; }
}
.form-readonly {
    min-inline-size: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 14px;
}

.permission-group {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.permission-group legend {
    padding: 0 6px;
    font-weight: 700;
}

.permission-group .check + .check {
    margin-top: 8px;
}

.rooms-table-panel > .form-readonly {
    min-height: 0;
}

.rooms-table-panel > .form-readonly > .rooms-table-wrap {
    height: 100%;
    min-height: 0;
    max-height: none;
}
