@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Serif:wght@500;600&display=swap');

:root {
  color-scheme: light;
  --ink: #1a1917;
  --ink-muted: #4a4844;
  --paper: #f3f0ea;
  --paper-deep: #e6e1d8;
  --rule: #c9c2b6;
  --accent: #6b4c3b;
  --accent-soft: rgba(107, 76, 59, 0.12);
  --dock-line: rgba(26, 25, 23, 0.14);
  --work-on: #a23438;
  --work-off: #2d6a4f;
  --bd-widget-bg: rgba(243, 240, 234, 0.92);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  padding-bottom: 10vh;
}

body.view-app {
  overflow: hidden;
}

/* Москва — угол */
.bd-time-widget {
  position: fixed;
  top: 1rem;
  right: 1rem;
  text-align: right;
  z-index: 30;
  line-height: 1.25;
  padding: 0.65rem 0.85rem;
  background: var(--bd-widget-bg);
  border: 1px solid var(--rule);
  border-radius: 2px;
  backdrop-filter: blur(6px);
}

.bd-time-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 0.2rem;
}

.bd-time-clock {
  font-size: clamp(1.1rem, 2.2vw, 1.45rem);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink);
}

/* Форма входа — по центру страницы */
.login-panel {
  position: relative;
  z-index: 20;
  min-height: calc(100vh - 10vh);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-form {
  width: 100%;
  max-width: 20rem;
  padding: 1.75rem 1.5rem;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: 0 8px 28px rgba(26, 25, 23, 0.06);
}

.login-form__title {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  color: var(--accent);
  text-align: center;
}

.login-form__label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.login-form__label span {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.login-form__label input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
}

.login-form__submit {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--paper);
  background: var(--accent);
  border: none;
  border-radius: 3px;
}

.login-form__submit:hover {
  filter: brightness(1.05);
}

.login-form__error {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--work-on);
  text-align: center;
}

/* Оболочка после входа.
   Важно: авторский display: grid иначе перебивает [hidden] в части браузеров — форма входа оказывается под невидимой сеткой. */
.app-shell[hidden] {
  display: none !important;
}

.app-shell {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 10vh;
  display: grid;
  grid-template-columns: minmax(11rem, 14rem) 1fr;
  z-index: 15;
  background: var(--paper);
}

.login-panel[hidden] {
  display: none !important;
}

.app-nav {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  border-right: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--paper-deep) 0%, var(--paper) 100%);
  padding: 1rem 0.65rem;
}

.app-nav__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.app-nav__logout {
  flex-shrink: 0;
  width: 100%;
  margin-top: 1rem;
  padding: 0.55rem 0.65rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--work-on);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.app-nav__logout:hover {
  background: rgba(162, 52, 56, 0.08);
  border-color: var(--work-on);
}

.app-nav__title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  margin: 0 0 0.75rem 0.35rem;
}

.app-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.app-nav__item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.65rem;
  text-align: left;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 3px;
}

.app-nav__item:hover {
  background: var(--accent-soft);
}

.app-nav__item--active {
  background: var(--accent-soft);
  font-weight: 600;
  color: var(--accent);
}

.app-main {
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
}

.app-main__title {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  color: var(--accent);
}

.app-main__hint {
  margin: 1rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.app-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.app-actions__btn {
  padding: 0.65rem 1.1rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink);
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.app-actions__btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.app-actions__btn--danger {
  color: var(--work-on);
  border-color: rgba(162, 52, 56, 0.45);
}

.app-actions__btn--danger:hover {
  background: rgba(162, 52, 56, 0.08);
  border-color: var(--work-on);
}

.limits-status-line {
  min-height: 1.25rem;
  margin: 0.75rem 0 0.5rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.limits-preview {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.limits-preview__title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.65rem;
  color: var(--ink-muted);
}

.limits-preview__table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper-deep);
}

.limits-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.limits-preview th,
.limits-preview td {
  padding: 0.35rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.limits-preview th {
  font-weight: 600;
  background: rgba(107, 76, 59, 0.08);
  color: var(--accent);
  white-space: nowrap;
}

.limits-preview tr:last-child td {
  border-bottom: none;
}

.limits-preview__empty {
  padding: 0.75rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* Нижняя панель объектов */
.objects-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: 10vh;
  min-height: 3.25rem;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-items: stretch;
  background: linear-gradient(to top, var(--paper-deep) 0%, #ebe6de 100%);
  border-top: 1px solid var(--rule);
  box-shadow: 0 -6px 24px rgba(26, 25, 23, 0.06);
}

.dock-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.1rem 0.2rem;
  min-width: 0;
  border-left: 1px solid var(--dock-line);
}

.dock-slot:first-child {
  border-left: none;
}

.dock-slot__name {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-weight: 500;
  font-size: clamp(0.38rem, 1.35vmin, 0.62rem);
  line-height: 1.15;
  color: var(--ink-muted);
  margin: 0 0 0.08rem;
  max-height: 2.4em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  padding: 0 1px;
}

.dock-slot__clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: clamp(0.55rem, 2.5vmin, 0.95rem);
  line-height: 1;
  letter-spacing: 0.02em;
  transition: color 0.35s ease;
}

.dock-slot__clock--working {
  color: var(--work-on);
}

.dock-slot__clock--off {
  color: var(--work-off);
}

.objects-dock--error {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-template-columns: none;
  padding: 0 0.75rem;
}

.objects-dock__error-text {
  margin: 0;
  font-size: clamp(0.55rem, 1.8vmin, 0.75rem);
  color: var(--work-on);
  text-align: center;
  line-height: 1.2;
}

@media (max-width: 36rem) {
  .bd-time-widget {
    position: static;
    margin: 0.75rem 1rem 0 auto;
    max-width: 12rem;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    bottom: 10vh;
    overflow-y: auto;
  }

  .app-nav {
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }
}
