:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #eef4f2;
  --text: #17211e;
  --muted: #61716b;
  --line: #d7e0dd;
  --navy: #06283b;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --gold: #c9982f;
  --ok: #15803d;
  --warn: #a16207;
  --bad: #b91c1c;
  --shadow: 0 14px 38px rgba(17, 38, 31, 0.08);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  border-top: 4px solid var(--gold);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-link {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
}

button:hover,
.button-link:hover {
  border-color: #a9bab4;
  background: #f8faf9;
}

button.primary,
.button-link.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

button.primary:hover,
.button-link.primary:hover {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

button.danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--bad);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
.button-link:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(201, 152, 47, 0.42);
  outline-offset: 2px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.portal-loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.portal-shell {
  min-height: calc(100vh - 4px);
}

.portal-header {
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.portal-header-inner,
.portal-main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.portal-header-inner {
  display: flex;
  min-height: 86px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.portal-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.portal-logo {
  display: block;
  width: 150px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 4px;
}

.portal-brand strong,
.portal-brand span {
  display: block;
}

.portal-brand strong {
  font-size: 18px;
}

.portal-brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.portal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.portal-main {
  display: grid;
  gap: 18px;
  padding: 28px 0 56px;
}

.portal-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding: 0 2px 18px;
}

.portal-intro h1 {
  margin: 0;
  color: var(--navy);
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: 0;
}

.portal-intro p {
  max-width: 700px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.session-label {
  display: grid;
  justify-items: end;
  gap: 3px;
  white-space: nowrap;
}

.session-label small {
  color: var(--muted);
}

.portal-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.portal-tabs button {
  flex: 0 0 auto;
  min-height: 44px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.portal-tabs button.active {
  border-bottom-color: var(--teal);
  color: var(--teal);
}

.portal-content,
.stack {
  display: grid;
  gap: 16px;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 16px;
}

.grid-2,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.form-grid .full,
.full {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.checkbox-label {
  display: flex;
  min-height: 42px;
  align-items: flex-start;
  gap: 9px;
  color: var(--text);
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
  margin: 1px 0 0;
  flex: 0 0 auto;
}

.news-list,
.document-list,
.project-list {
  display: grid;
  gap: 0;
}

.news-item,
.document-row,
.project-row,
.record-row {
  display: grid;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 15px 0;
}

.news-item:first-child,
.document-row:first-child,
.project-row:first-child,
.record-row:first-child {
  padding-top: 0;
}

.news-item:last-child,
.document-row:last-child,
.project-row:last-child,
.record-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.news-item h3,
.document-row h3,
.project-row h3 {
  margin: 0;
  font-size: 15px;
}

.news-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-line;
}

.record-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 18px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-block;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.badge.ok {
  background: #dcfce7;
  color: var(--ok);
}

.badge.warn {
  background: #fef3c7;
  color: var(--warn);
}

.badge.bad {
  background: #fee2e2;
  color: var(--bad);
}

.notice {
  border-left: 4px solid var(--teal);
  border-radius: 4px;
  padding: 12px 14px;
  background: #ecfdf5;
  color: #14532d;
  line-height: 1.45;
}

.notice.error {
  border-left-color: var(--bad);
  background: #fff1f2;
  color: var(--bad);
}

.hint,
.empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.empty {
  margin: 0;
  padding: 8px 0;
  font-size: 14px;
}

.login-panel {
  width: min(460px, 100%);
  margin: 0 auto;
}

.emergency-list {
  display: grid;
  gap: 10px;
}

.emergency-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.9fr 40px;
  gap: 8px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.emergency-row button {
  width: 40px;
  padding: 0;
}

@media (max-width: 760px) {
  .portal-header-inner,
  .portal-main {
    width: min(100% - 24px, 1180px);
  }

  .portal-header-inner {
    min-height: 76px;
  }

  .portal-logo {
    width: 122px;
  }

  .portal-brand-copy,
  .portal-header-actions .home-link {
    display: none;
  }

  .portal-main {
    padding-top: 20px;
  }

  .portal-intro {
    display: grid;
    gap: 12px;
  }

  .portal-intro h1 {
    font-size: 25px;
  }

  .session-label {
    justify-items: start;
  }

  .grid-2,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .full,
  .full {
    grid-column: auto;
  }

  .record-main {
    display: grid;
  }

  .emergency-row {
    grid-template-columns: 1fr;
  }

  .emergency-row button {
    justify-self: end;
  }
}

@media (max-width: 430px) {
  .portal-header-actions .admin-link {
    display: none;
  }

  .portal-header-inner {
    justify-content: center;
  }

  .portal-logo {
    width: 146px;
  }

  .portal-tabs {
    margin-right: -12px;
    margin-left: -12px;
    padding: 0 8px;
  }

  .portal-tabs button {
    padding-right: 11px;
    padding-left: 11px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}

.work-time-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #f7faf9;
  border-radius: 6px;
}

.work-time-group output {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.work-time-group input[readonly] {
  background: #eef5f2;
  color: #163d36;
}

@media (max-width: 720px) {
  .work-time-group {
    grid-template-columns: 1fr;
  }

  .work-time-group output {
    grid-column: 1;
  }
}
