:root {
  --bg: #97cdff;
  --text: #3b3b3b;
  --muted: #8d8d8d;
  --faint: #d2d2d2;
  --line: #cecece;
  --blue: #2670fd;
  --teal: #2781ac;
  --green: #3caf12;
  --red: #df2228;
  --white: #fff;
  --shadow: 8px 0 22px rgba(21, 21, 21, 0.13);
  --sidebar: 232px;
  --radius: 14px;
  font-family: Inter, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 28px);
  padding: 6px 4px 8px;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 8px 16px;
}
.brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 4px;
}
.brand__name { font-weight: 600; font-size: 13px; line-height: 1.25; }
.brand__inn { margin-top: 2px; font-size: 11px; color: #3a5670; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  color: #1d3348;
}
.nav button svg { flex: 0 0 auto; }
.nav button.is-active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6);
}
.nav button:hover:not(.is-active) { background: rgba(255,255,255,0.35); }
.nav__rule { height: 1px; background: rgba(255,255,255,0.75); margin: 8px 10px; }

.user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 4px;
}
.user img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #fff; }
.user span { font-weight: 500; }
.user__out {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #1d3348;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
}
.user__out:hover { background: rgba(255, 255, 255, 0.5); }

html:not(.is-auth) .app,
html:not(.is-auth) .menu,
html:not(.is-auth) .modal,
html:not(.is-auth) .toast { display: none !important; }
html.is-auth .login { display: none; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login__card {
  width: min(400px, 100%);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
}
.login__card img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #f4f8ff;
  border-radius: 12px;
  padding: 6px;
}
.login__card h1 { margin: 14px 0 0; font-size: 22px; font-weight: 600; }
.login__card p { margin: 4px 0 18px; color: var(--muted); font-size: 13px; }
.login__card label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.login__card input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
}
.login__error { color: var(--red); font-size: 13px; margin: 10px 0 0; }
.login__submit { width: 100%; height: 40px; margin-top: 16px; }

.panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: calc(100vh - 28px);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}
.view { display: none; flex-direction: column; gap: 14px; min-height: 0; flex: 1; }
.view.is-on { display: flex; }

.crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}
.crumb__sep { width: 1px; height: 18px; background: var(--line); }
.crumb__muted { color: var(--faint); display: inline-flex; align-items: center; gap: 6px; }
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
}
.badge--ghost { background: #e8f3fb; color: var(--teal); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar__left, .toolbar__right, .seg, .filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-width: 180px;
}
.search input {
  border: 0;
  width: 140px;
  padding: 0;
  background: transparent;
}
.search input::placeholder { color: var(--faint); font-style: italic; }

.btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--blue);
  color: #fff;
  font-weight: 500;
}
.btn--ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}
.btn--sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn:hover { filter: brightness(0.96); }

.seg button, .chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text);
}
.seg { background: #f4f7fb; border-radius: 8px; padding: 2px; }
.seg button.is-active { background: var(--blue); color: #fff; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
}
.chip.is-active { background: #eaf1ff; border-color: #b9d0ff; color: var(--blue); }

.datebox {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.icon-btn {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: #f2f4f7; }

.cal {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  flex: 1;
  min-height: 280px;
}
.cal__head, .cal__row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.cal__head {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
  border-bottom: 1px solid var(--line);
}
.cal__head div, .day {
  min-height: 42px;
  padding: 10px 8px 8px;
  text-align: center;
  font-weight: 500;
}
.cal__head .is-off { color: var(--faint); }
.day {
  min-height: 118px;
  border-right: 1px solid #eee;
  border-bottom: 1px solid #eee;
  text-align: left;
  background: #fff;
}
.day:nth-child(7n) { border-right: 0; }
.day.is-out { background: #fafafa; }
.day__num { font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.day.is-weekend .day__num { color: var(--faint); }
.task {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: #f4f8ff;
  border-radius: 6px;
  padding: 3px 6px;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.3;
}
.task b { font-weight: 500; display: block; }
.task span { color: var(--muted); }
.task:hover, .task.is-open { background: #e7f0ff; }
.day-list { display: flex; flex-direction: column; gap: 8px; }
.day-list .task { padding: 10px 12px; font-size: 14px; }

.menu {
  position: fixed;
  z-index: 20;
  width: 250px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
}
.menu[hidden] { display: none; }
.menu__time { font-size: 12px; color: var(--muted); }
.menu__title { margin: 2px 0 8px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.menu__meta { font-size: 12px; color: var(--muted); }
.menu__meta strong { display: block; color: var(--green); font-size: 14px; margin-top: 2px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.menu__label { font-weight: 600; margin-bottom: 4px; }
.menu button.item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 6px 2px;
  border-radius: 6px;
}
.menu button.item:hover { background: #f4f7fb; }
.menu button.item.danger { color: var(--red); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.stat {
  border-radius: 10px;
  padding: 8px 10px 10px;
  background: #f7f9fc;
  min-height: 64px;
}
.stat b { display: block; font-size: 18px; font-weight: 600; margin-top: 2px; }
.stat em { font-style: normal; font-size: 12px; color: var(--green); }
.stat em.down { color: var(--red); }
.stat span { font-size: 12px; color: var(--muted); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; flex: 1; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid #eee; white-space: nowrap; font-size: 13px; }
.linkish { border: 0; background: transparent; padding: 0; color: var(--blue); font-weight: 500; cursor: pointer; }
th { font-weight: 500; color: var(--muted); font-size: 13px; background: #fafbfc; position: sticky; top: 0; }
tr.row { cursor: pointer; }
tr.row:hover { background: #f5f9ff; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.pager button {
  min-width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  border-radius: 6px;
}
.pager button.is-active { background: #eaf1ff; color: var(--blue); font-weight: 600; }

.card-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 320px;
  gap: 16px;
  min-height: 0;
  flex: 1;
}
.dirs, .side-card, .form {
  min-height: 0;
  overflow: auto;
}
.dirs button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--text);
}
.dirs button.is-active { background: #eaf1ff; color: var(--blue); }
.dirs h3 { margin: 14px 8px 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.dirs hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}
.section-title h2 { margin: 0; font-size: 16px; font-weight: 600; }
.section-title .line { flex: 1; height: 1px; background: var(--line); }

.fields { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.field { min-width: 140px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.field div { font-weight: 500; }
.identity { display: flex; gap: 14px; align-items: flex-start; }
.identity img { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; }
.history { border-left: 2px solid var(--bg); margin-left: 6px; }
.history__item { display: grid; grid-template-columns: 88px 1fr; gap: 8px; padding: 8px 0 8px 12px; }
.history__item time { color: var(--muted); font-size: 13px; }

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
}
.empty h2 { color: var(--text); font-weight: 600; margin: 0 0 6px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 40, 60, 0.28);
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 16px;
}
.modal[hidden] { display: none; }
.dialog {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.dialog h2 { margin: 0 0 12px; font-size: 16px; }
.dialog label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.dialog input, .dialog select, .dialog textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #1d3348;
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  z-index: 40;
}
.toast[hidden] { display: none; }

.burger { display: none; }

@media (max-width: 1100px) {
  .card-layout { grid-template-columns: 200px minmax(0, 1fr); }
  .side-card { grid-column: 1 / -1; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; padding: 10px; }
  .sidebar {
    display: none;
    position: fixed;
    z-index: 25;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    background: var(--bg);
    padding: 16px;
    box-shadow: var(--shadow);
  }
  .sidebar.is-open { display: flex; }
  .burger { display: inline-grid; gap: 4px; place-content: center; width: 36px; height: 32px; border: 0; background: transparent; }
  .burger span { display: block; width: 16px; height: 2px; background: var(--text); }
  .panel { border-radius: 12px; }
}
