:root {
  --bg: #0b0d10;
  --panel: #12161c;
  --panel-2: #181e26;
  --line: #262e3a;
  --text: #e6ebf2;
  --muted: #8c97a8;
  --accent: #2f6db0;
  --navy: #0d3a6b;
  --navy-2: #0a2f58;
  --head: #2f6eae;
  --cell: #e7eef7;
  --cell-role: #c8dcf1;
  --cell-alt: #dbe7f4;
  --cell-text: #1a2533;
  --green: #1f7f3a;
  --amber: #d6a000;
  --grey: #9aa3ad;
  --situ: #3e5f8a;
  --red: #a12828;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: #7fb3ec; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .85em; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  background: linear-gradient(90deg, var(--navy-2), #0b1a2c);
  border-bottom: 1px solid #1d3b5f;
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; text-decoration: none; color: #fff; }
.brand-mark { font-weight: 800; letter-spacing: .12em; font-size: 1.05rem; }
.brand-sub { font-size: .75rem; color: #a9c3e2; letter-spacing: .05em; }
.topnav { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.topnav a { color: #d7e5f6; text-decoration: none; font-weight: 600; font-size: .95rem; }
.topnav a:hover { color: #fff; text-decoration: underline; }
.account { display: flex; align-items: center; gap: 10px; }
.account form { margin: 0; }
.account-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.avatar { border-radius: 50%; vertical-align: middle; background: #333; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; flex: 1; }
.container-wide { max-width: 1840px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px 16px; border-top: 1px solid var(--line); }

/* ---------- buttons, badges ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid #355a85;
  background: #1c3a5e; color: #fff; font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
.btn-primary { background: var(--accent); border-color: #4a88cc; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-danger { background: #5c1b1b; border-color: #8a2b2b; }
.btn-ok { background: var(--green); border-color: #2fa152; }
.btn-discord { background: #5865f2; border-color: #6f7bf7; }
.link-btn { background: none; border: 0; color: #2f6db0; cursor: pointer; padding: 0; display: block; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  background: #2a3240; color: #cfd8e4; white-space: nowrap;
}
.badge-open { background: #17462a; color: #8ff0ae; }
.badge-soon { background: #4a3a06; color: #ffd75e; }
.badge-closed { background: #3a2222; color: #f2a0a0; }
.badge-host { background: #3b2a5c; color: #d9c7ff; }
.badge-draft { background: #39404c; color: #e1e6ee; }
.badge-published { background: #17462a; color: #8ff0ae; }
.badge-archived { background: #2a2a2a; color: #aaa; }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; font-weight: 600; }
.flash-ok { background: #123b22; border: 1px solid #1f6b3a; }
.flash-error { background: #3d1515; border: 1px solid #7a2a2a; }
.flash-warn { background: #3b3008; border: 1px solid #77610f; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card-summary { cursor: pointer; font-weight: 700; font-size: 1.1rem; margin-bottom: 4px; }
details.card[open] .card-summary { margin-bottom: 14px; }
.section-heading { margin-top: 28px; }
.empty { text-align: center; padding: 60px 0; }
.empty h1 { font-size: 4rem; }

/* ---------- home ---------- */
.rp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.rp-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: var(--radius);
  background: linear-gradient(160deg, #13243a, var(--panel)); border: 1px solid #23395a;
  color: var(--text); text-decoration: none; transition: transform .1s, border-color .1s;
}
.rp-card:hover { transform: translateY(-2px); border-color: #3c6aa3; }
.rp-card h2 { font-size: 1.25rem; margin: 4px 0 0; }
.rp-card p { margin: 0; }
.rp-card-date { display: flex; flex-direction: column; font-size: .9rem; color: #a9c3e2; }
.rp-card-day { text-transform: capitalize; font-size: .8rem; }
.rp-card-foot { margin-top: auto; padding-top: 10px; display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.past { margin-top: 32px; }
.past summary { cursor: pointer; color: var(--muted); margin-bottom: 14px; font-weight: 600; }

/* ---------- RP header (podle tabulky) ---------- */
.rp-header {
  display: grid; grid-template-columns: 200px 1fr; border-radius: var(--radius); overflow: hidden;
  border: 1px solid #1d3b5f; margin-bottom: 16px;
}
.rp-header-brand {
  background: var(--navy-2); display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 16px; font-weight: 800; letter-spacing: .12em; text-align: center;
}
.rp-header-brand small { font-weight: 500; letter-spacing: .04em; color: #a9c3e2; margin-top: 4px; }
.rp-header-main { background: var(--navy); padding: 16px 20px; }
.rp-header-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.rp-header h1 { margin: 0; font-size: 1.8rem; }
.rp-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.rp-meta > div { background: var(--head); border-radius: 8px; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rp-meta span { font-size: .75rem; color: #d4e4f6; text-transform: uppercase; letter-spacing: .06em; }
.rp-meta strong { overflow-wrap: anywhere; }
.rp-meta .badge { align-self: flex-start; white-space: normal; border-radius: 6px; }

.briefing { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--head); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; }
.briefing h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: #a9c3e2; }
.briefing p { margin: 0; white-space: pre-line; }

.my-res {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius);
  background: #2c2507; border: 1px solid #6d5a10;
}
.my-res-ok { background: #12301d; border-color: #22663a; }
.my-res form { margin: 0; }

.legend { margin-bottom: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; }
.legend summary { cursor: pointer; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: .9rem; }
.legend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 12px; }
.legend h3 { font-size: .95rem; }
.legend p { margin: 0 0 .4em; font-size: .9rem; color: #c6d0dd; }
.legend-statuses { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- tabulka ---------- */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 880px), 1fr)); gap: 18px; align-items: start; }
.sheet { min-width: 0; }
.sheet-title {
  margin: 0; padding: 12px 16px; text-align: center; color: #fff; font-size: 1.15rem; font-weight: 800;
  letter-spacing: .03em; text-transform: uppercase; background: var(--navy); border-radius: var(--radius) var(--radius) 0 0;
}
.sheet-icon { font-size: 1rem; margin-right: 4px; }
.sheet-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sheet-table { width: 100%; border-collapse: collapse; color: var(--cell-text); font-size: .9rem; }
.sheet-table th {
  background: var(--head); color: #fff; padding: 10px 8px; font-weight: 700; white-space: nowrap; text-align: center;
}
.sheet-table td { background: var(--cell); padding: 8px; text-align: center; border-bottom: 1px solid #cfdcea; }
.sheet-table tbody tr:nth-child(even) td { background: var(--cell-alt); }
.sheet-table td.cell-role, .sheet-table tbody tr:nth-child(even) td.cell-role { background: var(--cell-role); font-weight: 700; white-space: nowrap; }
.sheet-table td.cell-num { font-weight: 700; position: relative; }
.sheet-table td.cell-level { font-weight: 700; white-space: nowrap; }
.sheet-table th.col-detail, .sheet-table td.col-detail { background: var(--bg) !important; border: 0; padding: 4px 0 4px 8px; width: 1%; }
.note-flag {
  position: absolute; top: 0; right: 0; width: 0; height: 0;
  border-top: 12px solid #e02424; border-left: 12px solid transparent; cursor: help;
}
.cell-status { font-weight: 700; white-space: nowrap; min-width: 110px; }
.sheet-table td.st-volna { background: var(--green) !important; color: #fff; }
.sheet-table td.st-obsazena { background: var(--amber) !important; color: #1a1300; }
.sheet-table td.st-nebude { background: var(--grey) !important; color: #2b3138; }
.sheet-table td.st-situacni { background: var(--situ) !important; color: #fff; }
.sheet-table td.st-host { background: #6b1d1d !important; color: #fff; }
.sheet-table td.st-redacted { background: #111 !important; color: #ddd; }
.sheet-table td.st-dulezita { background: #7a3db8 !important; color: #fff; }
.row-disabled td:not(.col-detail):not(.cell-status) { opacity: .55; }
.row-mine td.cell-role { box-shadow: inset 4px 0 0 #ffd75e; }
.pending-count { display: block; font-weight: 600; font-size: .72rem; opacity: .9; }
.status-btn {
  background: none; border: 0; color: inherit; font: inherit; font-weight: 700; cursor: pointer; width: 100%;
  display: flex; flex-direction: column; align-items: center; line-height: 1.15;
}
.status-btn small { font-size: .7rem; font-weight: 600; opacity: .85; text-decoration: underline; }
.status-btn:hover small { opacity: 1; }
.detail-btn {
  background: #0b0d10; color: #3d9bff; border: 3px solid #1e90ff; font-weight: 700; font-size: .78rem;
  padding: 3px 10px; cursor: pointer;
}
.detail-btn:hover { background: #10243d; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .78rem; font-weight: 700; }
.chip.st-volna { background: var(--green); color: #fff; }
.chip.st-obsazena { background: var(--amber); color: #1a1300; }
.chip.st-nebude { background: var(--grey); color: #2b3138; }
.chip.st-situacni { background: var(--situ); color: #fff; }
.chip.st-host { background: #6b1d1d; color: #fff; }
.chip.st-redacted { background: #111; color: #ddd; border: 1px solid #444; }
.chip.st-dulezita { background: #7a3db8; color: #fff; }

/* ---------- dialogy ---------- */
.role-dialog {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 22px; border-radius: 14px;
  background: var(--panel); color: var(--text); border: 1px solid #2c4a70; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.role-dialog::backdrop { background: rgba(0, 0, 0, .7); }
.dialog-close { position: absolute; top: 8px; right: 10px; margin: 0; }
.dialog-close button { background: none; border: 0; color: var(--muted); font-size: 1.8rem; cursor: pointer; line-height: 1; }
.dialog-close button:hover { color: #fff; }
.role-detail { display: grid; grid-template-columns: 200px 1fr; gap: 20px; }
.role-portrait { width: 100%; border-radius: 10px; background: #000; object-fit: contain; max-height: 360px; }
.role-info h3 { font-size: 1.5rem; margin-right: 30px; }
.role-stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 10px 0; }
.role-stats dt { color: var(--muted); }
.role-stats dd { margin: 0; font-weight: 700; }
.role-desc { white-space: pre-line; color: #d2dae5; font-size: .93rem; }
.role-note { background: #3a1616; border-left: 3px solid #e02424; padding: 8px 12px; border-radius: 6px; margin: 8px 0; font-size: .9rem; }
.role-dialog h4 { margin: 18px 0 10px; text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; color: #a9c3e2; }
.inventory { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.inventory li { background: #0b0f15; border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center; font-size: .8rem; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.inventory img { width: 72px; height: 72px; object-fit: contain; }
.inv-placeholder { width: 72px; height: 72px; border-radius: 6px; background: #1a212b; }
.keycard { display: flex; gap: 10px; align-items: center; background: #0b0f15; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.keycard code { flex: 1; font-size: .78rem; overflow-wrap: anywhere; color: #b7c6d8; }
.reserve-dialog { width: min(480px, calc(100vw - 32px)); }

/* ---------- formuláře ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
.form label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: span 2; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input, select, textarea {
  font: inherit; color: var(--text); background: #0d1218; border: 1px solid #304055; border-radius: 6px; padding: 7px 9px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #3d82cf; border-color: transparent; }
input[type="checkbox"], input[type="radio"] { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
legend { color: var(--muted); font-size: .85rem; padding: 0 4px; }

/* ---------- admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.user-cell { display: flex; align-items: center; gap: 8px; }
.sub { margin-top: 12px; }
.sub summary { cursor: pointer; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.section-editor-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.section-editor-head form { margin: 0; }
.section-form { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.section-form .grow, .add-slot .grow { flex: 1 1 200px; }
.w-icon { width: 80px; }
.w-num { width: 90px; }
.cols { flex: 1 1 100%; }
.slot-table td { padding: 4px; }
.slot-table input, .slot-table select { padding: 4px 6px; font-size: .85rem; min-width: 90px; }
.slot-table .in-num { width: 64px; min-width: 64px; }
.slot-table .in-short { width: 64px; min-width: 64px; }
.slot-table .in-mid { width: 96px; }
.add-slot { flex-direction: row; flex-wrap: wrap; align-items: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }

.library-set { margin-bottom: 16px; }
.library-set > summary { cursor: pointer; list-style: none; }
.library-set > summary h2 { display: inline; }
.library-set > summary::before { content: "▸ "; color: var(--muted); }
.library-set[open] > summary::before { content: "▾ "; }
.library-section { margin: 18px 0; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.library-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.library-card-main { display: flex; gap: 12px; align-items: center; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; width: 100%; padding: 0; }
.library-card-main img, .lib-noimg { width: 64px; height: 84px; object-fit: contain; background: #000; border-radius: 6px; flex: none; }
.lib-noimg { display: grid; place-items: center; color: var(--muted); }
.library-card-main span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.library-card details { margin-top: 8px; }
.library-card summary { cursor: pointer; color: #7fb3ec; }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 12px; }
  .rp-header { grid-template-columns: 1fr; }
  .rp-header-brand { padding: 8px; flex-direction: row; gap: 10px; }
  .rp-header-brand small { margin: 0; }
  .rp-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .role-detail { grid-template-columns: 1fr; }
  .role-portrait { max-height: 260px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  h1 { font-size: 1.4rem; }
}
