:root {
  --ink: #1c1915;
  --muted: #6d655c;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e4dccf;
  --green: #0f6e56;
  --green-soft: #e5f4ee;
  --amber: #c47b2b;
  --amber-soft: #fbf1e2;
  --terra: #a33b32;
  --terra-soft: #f8e8e6;
  --shadow: 0 18px 40px rgba(48, 36, 18, 0.08);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 10% -10%, #efe4cf 0%, transparent 60%),
    var(--paper);
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.eyebrow {
  margin: 0 0 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--green);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}
.panel-wrap { width: min(440px, 100%); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.panel-wrap .card { width: min(440px, 100%); }
h2 { margin: 0; font-size: 26px; font-weight: 600; }
label { display: grid; gap: 6px; margin-bottom: 12px; font-family: "Avenir Next", "Segoe UI", sans-serif; font-size: 14px; }
input[type="text"], input[type="password"], input[type="date"], input:not([type]) {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}
input:focus { outline: 2px solid #b7d9cc; border-color: var(--green); }
.btn {
  border: 0;
  background: var(--ink);
  color: #fffdf8;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn.secondary { background: var(--green); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}
.tabs button.on { background: var(--ink); color: white; border-color: var(--ink); }
.notice {
  background: var(--amber-soft);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 12px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}
.notice.bad { background: var(--terra-soft); }
.notice.ok { background: var(--green-soft); }
.creds { margin: 12px 0; display: grid; gap: 6px; font-family: "Avenir Next", "Segoe UI", sans-serif; }
.creds div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.creds dt { color: var(--muted); }
.creds dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; text-align: right; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.86);
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px);
}
.brand { display: flex; flex-direction: column; }
.brand span, .who span, .muted { color: var(--muted); font-family: "Avenir Next", "Segoe UI", sans-serif; font-size: 14px; }
.who { display: flex; gap: 14px; align-items: center; min-width: 0; }
.who b, .who span { display: block; overflow-wrap: anywhere; }
.page { width: min(820px, calc(100% - 32px)); margin: 24px auto 48px; display: grid; gap: 16px; }
.page > * { min-width: 0; }
.section-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.card.is-folded .section-head { margin-bottom: 0; }
.fold-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.fold-toggle h2 { margin: 0; }
.chevron {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  position: relative;
  color: var(--muted);
}
.chevron::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 5px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}
.fold-toggle[aria-expanded="true"] .chevron::before { transform: rotate(45deg); top: 2px; }
.head-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section-head .tabs, .filters .tabs { margin: 0; }
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
  margin: 0 0 10px;
}
.staff-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.staff-grid h3, .card h3 { font-size: 16px; margin: 12px 0 8px; }
.staff-grid .table-wrap { max-height: 120px; overflow: auto; }
.filters label { margin: 0; }
.filters input[type="date"],
.filters select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}
.profile-card { display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.profile-box {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 12px 14px;
  align-items: start;
}
.profile-box > * { min-width: 0; }
.profile-box h2 {
  font-size: 18px;
  line-height: 1.2;
  margin-bottom: 4px;
}
.profile-box .muted {
  font-size: 12px;
  line-height: 1.35;
  margin: 0 0 8px;
}
.profile-box label {
  margin: 0;
  font-size: 12px;
  gap: 4px;
}
.profile-box input[type="date"] {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
}
.profile-box .range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-items: end;
  margin-bottom: 8px;
}
.profile-box .range .btn,
.profile-box .btn.ghost {
  grid-column: 1 / -1;
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
}
.profile-box .weekdays {
  margin: 0 0 6px;
  gap: 4px 8px;
  font-size: 12px;
}
.profile-box .table-wrap {
  max-height: 92px;
  overflow: auto;
}
.profile-box th,
.profile-box td {
  padding: 5px 4px;
  font-size: 12px;
}
.profile-box > .notice { grid-column: 1 / -1; margin: 0; padding: 8px 10px; font-size: 13px; }
.avatar-upload {
  position: relative;
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 6px;
  cursor: pointer;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}
.avatar-upload em { font-style: normal; color: var(--muted); font-size: 12px; }
.avatar-upload input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
#profile-avatar[hidden],
#avatar-fallback[hidden] { display: none !important; }
#profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.desk-initials.big {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--green-soft);
  display: grid;
  place-items: center;
  font-size: 22px;
}
.code-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
code {
  font-size: 22px;
  letter-spacing: 0.08em;
  background: var(--paper);
  padding: 8px 12px;
  border-radius: 12px;
}
.range, .weekdays, .cal-nav { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.weekdays { margin: 10px 0; font-family: "Avenir Next", "Segoe UI", sans-serif; }
.weekdays label { display: flex; gap: 6px; align-items: center; margin: 0; }
.cal-nav { margin-bottom: 8px; }
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar button, .calendar .dow {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  min-height: 40px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}
.calendar .dow { color: var(--muted); font-size: 12px; text-align: center; }
.calendar button { border-color: var(--line); cursor: pointer; background: #fff; }
.calendar button.on { background: var(--ink); color: white; }
.calendar button.focus { box-shadow: inset 0 0 0 2px var(--green); }
.calendar button:disabled { opacity: 0.35; cursor: default; }
.calendar button.taken { background: var(--terra-soft); color: var(--terra); }
.calendar button.mine { background: #e7eef8; color: #3d6cb5; }
.calendar button.busy,
.calendar button.vacation,
.calendar button.remote,
.calendar button.vru { background: #f3efe6; }
.calendar button.weekend,
.calendar button.holiday {
  background: #f7ecec;
  color: #c9b0b0;
  border-color: #f0dcdc;
  opacity: 1;
}
.calendar.books-cal button {
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  font-size: 13px;
}
.calendar.books-cal button small {
  display: block;
  font-size: 10px;
  line-height: 1.1;
  color: inherit;
  opacity: 0.85;
}
.calendar.books-cal button.mine {
  opacity: 1;
  cursor: default;
}
.dot.holiday { background: #e8cfcf; }

.office-map {
  background: #f7f3ea;
  border-radius: 18px;
  padding: 12px;
  border: 1px dashed #d9d0c2;
  overflow-x: auto;
}
.plan { min-width: 540px; }
.window {
  height: 22px;
  margin: 0 8px;
  background: linear-gradient(#c5deee, #eaf4fb 58%, #f4f8fb);
  border: 2.5px solid #2a241c;
  border-bottom: 0;
  display: grid;
  place-items: center;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 10px;
  color: #5d7b8c;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  box-shadow: inset 0 10px 12px rgba(255, 255, 255, 0.45);
}
.room {
  display: grid;
  grid-template-columns: max-content minmax(110px, 1fr) max-content;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "left mid right"
    "left entry right";
  min-height: 460px;
  min-width: 540px;
  border: 3px solid #2a241c;
  background: #f7f3ea;
  box-shadow: inset 0 0 0 6px #f3eee6, inset 0 0 0 8px #2a241c;
}
.col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: space-evenly;
  padding: 12px 0;
}
.col.left { grid-area: left; align-items: flex-start; }
.col.center { grid-area: mid; align-items: center; padding-top: 8px; }
.col.right { grid-area: right; align-items: flex-end; }
.aisle-line {
  flex: 1;
  width: 12px;
  border-radius: 99px;
  background: repeating-linear-gradient(#ece4d6, #ece4d6 8px, #ddd3c3 8px, #ddd3c3 16px);
  opacity: 0.7;
}
.entry {
  grid-area: entry;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  padding-bottom: 2px;
}
.plan-door {
  grid-column: 2;
  width: 56px;
  height: 56px;
  color: #2a241c;
  margin-bottom: -8px;
}
.plan-door svg { display: block; width: 100%; height: 100%; }
.entry .station {
  grid-column: 3;
  justify-self: start;
  margin-left: 6px;
}
.annex {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed #d9d0c2;
}
.annex-label {
  margin: 0;
  color: var(--muted);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 13px;
  letter-spacing: 0.03em;
}
.annex-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 12px;
}
.station { display: flex; align-items: center; gap: 10px; }
.station.chair-right { flex-direction: row; }
.station.chair-left { flex-direction: row-reverse; }
.station.chair-down { flex-direction: column; }
.station.chair-up { flex-direction: column-reverse; }
.chair {
  width: 26px;
  height: 36px;
  position: relative;
  flex: 0 0 26px;
  background: transparent;
  border: 0;
  box-shadow: none;
  display: block;
}
.station.chair-right .chair { transform: rotate(-90deg); }
.station.chair-left .chair { transform: rotate(90deg); }
.station.chair-up .chair { transform: rotate(180deg); }
.chair i { display: block; position: absolute; box-sizing: border-box; }
.chair-back {
  left: 5px;
  top: 0;
  width: 16px;
  height: 13px;
  border: 2px solid #5e5346;
  border-bottom: 0;
  border-radius: 9px 9px 2px 2px;
  background: #e4d4bc;
}
.chair-seat {
  left: 2px;
  top: 11px;
  width: 22px;
  height: 11px;
  border: 2px solid #5e5346;
  border-radius: 5px 5px 8px 8px;
  background: #efe4d0;
  z-index: 1;
}
.chair-stem {
  left: 12px;
  top: 21px;
  width: 2px;
  height: 8px;
  background: #6a5e50;
}
.chair-star {
  left: 3px;
  bottom: 1px;
  width: 20px;
  height: 8px;
  background:
    radial-gradient(circle at 50% 50%, #6a5e50 1.6px, transparent 1.7px),
    linear-gradient(#6a5e50, #6a5e50) 50% 50% / 20px 2px no-repeat,
    linear-gradient(#6a5e50, #6a5e50) 50% 50% / 2px 8px no-repeat,
    linear-gradient(32deg, transparent 46%, #6a5e50 46%, #6a5e50 54%, transparent 54%) 50% 50% / 16px 8px no-repeat,
    linear-gradient(-32deg, transparent 46%, #6a5e50 46%, #6a5e50 54%, transparent 54%) 50% 50% / 16px 8px no-repeat;
}
.desk {
  position: relative;
  border: 1px solid var(--line);
  background: white;
  border-radius: 16px 16px 8px 8px;
  min-height: 72px;
  min-width: 100px;
  padding: 8px 46px 8px 10px;
  text-align: left;
  cursor: pointer;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}
.col.left .desk,
.col.right .desk {
  width: 108px;
  min-width: 108px;
  min-height: 96px;
}
.desk b {
  display: block;
  font-size: 13px;
  font-family: "Iowan Old Style", Palatino, serif;
  white-space: nowrap;
}
.desk.reserve { border-style: dashed; }
.desk small { color: var(--muted); display: block; margin-top: 4px; font-size: 12px; }
.desk.free { background: var(--green-soft); }
.desk.mine { background: #e7eef8; }
.desk.taken { background: var(--terra-soft); }
.desk.pick { outline: 3px solid var(--ink); }
.desk.static { cursor: default; }
.desk.weekend,
.desk.holiday {
  background: #f7ecec;
  color: #a33b32;
}
.desk-avatar {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fffdf8;
  box-shadow: 0 1px 4px rgba(44, 36, 24, 0.32);
}
.map-nav { margin: 0; }
.map-nav input[type="date"] { padding: 8px 10px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 12px 0; font-family: "Avenir Next", "Segoe UI", sans-serif; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.free { background: var(--green); }
.dot.mine { background: #3d6cb5; }
.dot.taken { background: var(--terra); }
.dot.pick { background: var(--ink); }
.dot.reserve { background: transparent; border: 1px dashed var(--ink); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-family: "Avenir Next", "Segoe UI", sans-serif; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.linkish {
  background: none;
  border: 0;
  color: var(--terra);
  cursor: pointer;
  padding: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.kpi-grid { display: grid; width: 100%; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  min-width: 0;
}
.kpi.on { outline: 2px solid var(--ink); }
.kpi span { display: block; color: var(--muted); font-family: "Avenir Next", "Segoe UI", sans-serif; font-size: 13px; }
.kpi strong { font-size: 34px; letter-spacing: -0.04em; }
.chart { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 48px; gap: 8px; align-items: center; font-family: "Avenir Next", "Segoe UI", sans-serif; font-size: 13px; }
.bar { height: 12px; background: #efe8dc; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; }

@media (max-width: 860px) {
  .auth-layout { padding: 20px 12px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi strong { font-size: 28px; }
  .profile-card, .section-head { align-items: flex-start; flex-direction: column; }
  .profile-box { grid-template-columns: 1fr; }
  .staff-grid { grid-template-columns: 1fr; }
  .page { width: min(820px, calc(100% - 20px)); }
}

@media (max-width: 640px) {
  body { background: var(--paper); }
  .topbar {
    padding: 12px 14px;
    gap: 8px;
  }
  .topbar .who { width: 100%; justify-content: space-between; }
  .page { width: 100%; margin: 12px 0 32px; gap: 10px; padding: 0 10px; }
  .card { border-radius: 16px; padding: 14px; }
  h2 { font-size: 20px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px; }
  .kpi strong { font-size: 22px; }
  .kpi span { font-size: 11px; }
  .section-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .head-tools { justify-content: space-between; }
  .filters { flex-direction: column; align-items: stretch; gap: 8px; }
  .filters label, .filters input, .filters select { width: 100%; }
  .filters .tabs, .head-tools .tabs { width: 100%; }
  .filters .tabs button, .head-tools .tabs button { flex: 1; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .map-nav { width: 100%; }
  .map-nav input[type="date"] { flex: 1; min-width: 0; }
  .range { display: grid; grid-template-columns: 1fr; }
  .weekdays { gap: 4px 10px; }
  .office-map { padding: 8px; }
  .plan { min-width: 460px; }
  .calendar button, .calendar .dow { min-height: 34px; }
  .calendar.books-cal button { min-height: 44px; }
  th, td { padding: 8px 6px; font-size: 13px; white-space: nowrap; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .bar-row { grid-template-columns: 64px minmax(0, 1fr) 40px; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
}
