:root {
  --bg: #f6f8f7;
  --panel: #ffffff;
  --text: #17211d;
  --muted: #61736b;
  --line: #dfe7e3;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --soft: #e8f5f2;
  --warning-bg: #fffbeb;
  --warning-text: #92400e;
  --success-bg: #dcfae6;
  --success-text: #067647;
  --danger-bg: #fee4e2;
  --danger-text: #b42318;
  --shadow: 0 12px 28px rgba(23, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: none;
  grid-template-columns: 268px minmax(0, 1fr);
}

body.portal-ready .app-shell {
  display: grid;
}

.auth-screen {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  background:
    linear-gradient(118deg, rgba(0, 0, 0, 0.98), rgba(17, 15, 9, 0.94) 50%, rgba(46, 38, 20, 0.82)),
    radial-gradient(circle at 78% 34%, rgba(168, 139, 78, 0.34), transparent 34%);
  color: #fff;
}

.auth-screen::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(136deg, transparent 0 58%, rgba(255, 255, 255, 0.07) 58% 74%, transparent 74%),
    radial-gradient(circle at 20% 80%, rgba(15, 118, 110, 0.16), transparent 28%);
  opacity: 0.9;
}

.auth-screen::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(90deg, transparent, #000 38%, #000 76%, transparent);
}

body.portal-ready .auth-screen {
  display: none;
}

.auth-header {
  position: relative;
  z-index: 2;
  width: min(100%, 1220px);
  margin: 0 auto;
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.auth-logo-mark {
  display: block;
  width: 220px;
  max-width: 42vw;
  text-decoration: none;
}

.auth-logo-mark img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 7px 12px rgba(0, 0, 0, 0.28));
}

.auth-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-nav a {
  border-radius: 999px;
  padding: 10px 16px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.auth-nav a[data-login-link] {
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}

.auth-nav a[data-login-link]:first-child {
  background: #0f766e;
  border-color: #14b8a6;
  color: #fff;
}

.auth-nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.auth-hero {
  position: relative;
  z-index: 1;
  width: min(100%, 1220px);
  margin: auto;
  padding: 80px 28px 110px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.7fr);
  align-items: center;
  gap: 46px;
}

.auth-copy {
  max-width: 760px;
}

.auth-copy h2 {
  margin-bottom: 18px;
  color: #fff;
  font-size: 64px;
  line-height: 1.02;
  text-shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
}

.auth-copy h2 span {
  display: block;
  color: #fff;
  font-size: inherit;
  line-height: inherit;
  letter-spacing: 0;
}

.auth-copy h2 .welcome-title {
  margin-bottom: 8px;
  font-size: 0.72em;
}

.auth-visual {
  min-height: 420px;
  display: grid;
  place-items: center;
}

.auth-visual svg {
  width: min(100%, 520px);
  filter: drop-shadow(0 26px 46px rgba(0, 0, 0, 0.4));
}

.portal-orbit {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-dasharray: 2 16;
  stroke-linecap: round;
  stroke-width: 3;
}

.portal-orbit.muted {
  stroke: rgba(194, 166, 99, 0.24);
}

.portal-shield {
  fill: rgba(255, 255, 255, 0.06);
  stroke: url("#portalGlow");
  stroke-linejoin: round;
  stroke-width: 5;
}

.portal-shield-inner {
  fill: rgba(15, 118, 110, 0.1);
  stroke: rgba(255, 255, 255, 0.36);
  stroke-linejoin: round;
  stroke-width: 3;
}

.portal-lock {
  fill: rgba(255, 255, 255, 0.08);
  stroke: rgba(255, 255, 255, 0.88);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 7;
}

.portal-line {
  fill: none;
  stroke: rgba(194, 166, 99, 0.58);
  stroke-linecap: round;
  stroke-width: 4;
}

.portal-nodes circle {
  fill: rgba(16, 22, 19, 0.96);
  stroke: rgba(132, 216, 207, 0.9);
  stroke-width: 5;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 18px;
}

.brand {
  display: block;
  margin: -6px 0 24px;
  padding: 0;
  background: #326f62;
  border-radius: 10px;
  overflow: hidden;
}

.brand-logo {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  border-radius: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav-item.active {
  background: var(--soft);
  color: var(--brand-dark);
}

.nav-item:not(.active):hover {
  color: var(--brand-dark);
}

.nav-item:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  outline-offset: 2px;
}

.is-hidden {
  display: none !important;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 248, 247, 0.92);
  backdrop-filter: blur(12px);
}

.search {
  width: min(100%, 540px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--text);
}

input[readonly] {
  background: #f5f8f7;
  color: var(--brand-dark);
  font-weight: 900;
}

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

.user-card {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.user-card strong,
.user-card span {
  display: block;
}

.user-card span {
  color: var(--muted);
  font-size: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-dark);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.auth-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.auth-button:hover {
  background: var(--soft);
}

.content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 26px 28px 44px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 20px;
}

.page-title.compact {
  align-items: center;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 18px;
}

.page-title p:not(.eyebrow) {
  margin: 6px 0 0;
  color: var(--muted);
}

.month-select {
  width: 240px;
}

.role-note {
  max-width: 760px;
  color: var(--brand-dark) !important;
  font-weight: 700;
}

.primary,
.secondary,
.ghost {
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary {
  border: 0;
  background: var(--brand);
  color: #fff;
}

.primary:hover {
  background: var(--brand-dark);
}

.secondary,
.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.ghost {
  padding: 8px 11px;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.inline-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.inline-actions .secondary,
.inline-actions .ghost {
  padding: 7px 10px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 28px;
}

.metric-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-grid,
.form-layout,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  gap: 16px;
}

.form-layout {
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
}

.admin-grid {
  grid-template-columns: repeat(2, minmax(300px, 1fr));
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.month-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.month-head h3 {
  margin: 0;
  color: var(--brand-dark);
}

.month-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.week-header,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.week-header {
  margin-bottom: 6px;
}

.week-header span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.calendar-day {
  min-height: 78px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.calendar-day.is-empty {
  border-style: dashed;
  background: #f8fbfa;
}

.calendar-day.is-weekend:not(.is-holiday) {
  background: #fbfbfa;
  color: var(--muted);
}

.calendar-day.is-holiday {
  border-color: rgba(0, 91, 86, 0.35);
  background: #e8f5f2;
}

.day-number {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.calendar-day.is-holiday .day-number {
  color: var(--brand-dark);
}

.calendar-day strong {
  display: block;
  font-size: 12px;
  line-height: 1.25;
}

.calendar-day small {
  display: block;
  margin-top: 5px;
  color: var(--brand-dark);
  font-size: 10px;
  font-weight: 800;
}

.empty-box {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.empty-box {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.detail-list {
  display: grid;
  gap: 12px;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.detail-list span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.stack {
  display: grid;
  gap: 10px;
}

.item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  align-self: flex-start;
  white-space: nowrap;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.pill.warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.pill.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.pill.danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.toolbar,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-form {
  margin-bottom: 12px;
}

.document-folder-layout {
  margin-bottom: 16px;
}

.form-note {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

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

.check-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.document-link {
  text-decoration: none;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.empty-cell {
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.notice {
  margin-bottom: 14px;
  border-left: 4px solid #d97706;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--warning-bg);
  color: #6b4f05;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.modal {
  width: min(620px, calc(100vw - 32px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.modal::backdrop {
  background: rgba(10, 18, 15, 0.48);
  backdrop-filter: blur(3px);
}

.modal-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  background: var(--panel);
  box-shadow: 0 28px 64px rgba(23, 33, 29, 0.22);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.modal-head h3 {
  margin: 2px 0 0;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
}

.icon-button:hover {
  color: var(--text);
  background: var(--soft);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1020px) {
  .auth-header {
    flex-wrap: wrap;
  }

  .auth-logo-mark {
    width: 220px;
  }

  .auth-hero {
    grid-template-columns: 1fr;
    padding-top: 52px;
  }

  .auth-visual {
    min-height: 300px;
  }

  .auth-copy h2 {
    font-size: 44px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics,
  .dashboard-grid,
  .form-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 14px 18px;
  }

  .content {
    padding: 20px 18px 34px;
  }
}

@media (max-width: 640px) {
  .auth-header {
    padding: 18px;
  }

  .auth-nav {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
    flex-wrap: wrap;
  }

  .auth-nav a {
    font-size: 13px;
    padding: 9px 12px;
  }

  .auth-hero {
    padding: 36px 18px 60px;
  }

  .auth-copy h2 {
    font-size: 34px;
  }

  .auth-visual {
    min-height: 220px;
  }

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

  .page-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .month-select {
    width: 100%;
  }

  .user-card {
    justify-content: flex-start;
  }

  .calendar-month {
    overflow-x: auto;
  }

  .week-header,
  .calendar-days {
    min-width: 680px;
  }
}
