:root {
  color-scheme: dark;
  font-family: "Segoe UI", "Malgun Gothic", sans-serif;
  background: #07111f;
  color: #eef4ff;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(245, 158, 11, 0.20), transparent 34%),
    radial-gradient(circle at 85% 15%, rgba(56, 189, 248, 0.17), transparent 32%),
    linear-gradient(145deg, #07111f, #10172b 58%, #091322);
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.card {
  width: min(1020px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 28px;
  background: rgba(9, 18, 35, 0.86);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(18px);
}

.login-card {
  width: min(520px, 100%);
  padding: 42px;
}

.brand h1,
.portal-header h1 {
  margin: 16px 0 10px;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.055em;
}

.brand p,
.portal-header p,
.notice {
  color: #9eacc2;
  line-height: 1.65;
}

.badge {
  display: inline-flex;
  padding: 7px 12px;
  border: 1px solid rgba(245, 158, 11, 0.32);
  border-radius: 999px;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.09);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  color: #d8e2f1;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 14px;
  padding: 14px 15px;
  background: rgba(255, 255, 255, 0.055);
  color: #fff;
  font: inherit;
  outline: none;
}

input:focus,
select:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.13);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #cbd5e1 50%),
    linear-gradient(135deg, #cbd5e1 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% - 3px),
    calc(100% - 14px) calc(50% - 3px);
  background-repeat: no-repeat;
  background-size: 6px 6px;
}

.admin-password-options.is-hidden {
  display: none;
}

.email-choice {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.5;
}

.email-choice input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  accent-color: #f59e0b;
}

button {
  width: 100%;
  margin-top: 22px;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #111827;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.error {
  min-height: 1.35em;
  margin: 12px 0 0;
  color: #fda4af;
}

.login-alert:not(:empty) {
  padding: 12px 14px;
  border: 1px solid rgba(253, 164, 175, 0.45);
  border-radius: 8px;
  background: rgba(190, 24, 93, 0.13);
  line-height: 1.5;
}

.success {
  min-height: 1.35em;
  margin: 8px 0 0;
  color: #86efac;
}

.notice {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
}

.account-box {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.08);
  color: #dbeafe;
}

.account-box strong {
  display: block;
  color: #7dd3fc;
  font-size: 0.92rem;
}

.account-box p {
  margin: 6px 0 0;
  color: #b8c7db;
  font-size: 0.88rem;
  line-height: 1.55;
}

.portal-card {
  padding: 46px;
}

.portal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.portal-header form {
  flex: 0 0 auto;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-actions form {
  margin: 0;
}

button.secondary {
  width: auto;
  margin: 0;
  color: #d9e2ef;
  background: rgba(255, 255, 255, 0.08);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  padding: 14px 18px;
  color: #d9e2ef;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
  font-weight: 800;
}

.password-help {
  margin: 12px 0 0;
  color: #9eacc2;
  font-size: 0.84rem;
  line-height: 1.6;
}

.back-link {
  display: inline-block;
  margin-top: 20px;
  color: #c7d2fe;
  text-decoration: none;
}

/* 활성 메뉴는 데스크톱에서 5열로, 휴대폰에서는 3열로 이어 배치한다. */
.project-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  margin-top: 36px;
}

.project-grid.viewer-project-grid {
  grid-template-columns: minmax(180px, 280px);
  justify-content: center;
}

.viewer-mode-note {
  margin-top: 8px;
  color: #bae6fd;
  font-size: 0.82rem;
  font-weight: 700;
}

[hidden] {
  display: none !important;
}

.portal-header.portal-identity-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.portal-identity-header .portal-user {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: center;
}

.portal-identity-header form {
  margin: 0;
}

.portal-identity-header h1 {
  grid-column: 1 / -1;
}

.project.management {
  background: linear-gradient(150deg, rgba(245, 158, 11, 0.28), rgba(255, 255, 255, 0.03));
}

.project.daily-report {
  grid-column: 3;
  background: linear-gradient(150deg, rgba(59, 130, 246, 0.28), rgba(255, 255, 255, 0.03));
}

.project {
  /* 한 줄에 여러 장이 들어가므로 세로를 줄인다. 종전 220px 은 3열 기준이었다. */
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 22px;
  color: #fff;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease;
}

.project:hover,
.project:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.28);
}

.project.shipment {
  background: linear-gradient(150deg, rgba(245, 158, 11, 0.24), rgba(255, 255, 255, 0.03));
}

.project.feed {
  background: linear-gradient(150deg, rgba(34, 197, 94, 0.22), rgba(255, 255, 255, 0.03));
}

.project.nvr {
  background: linear-gradient(150deg, rgba(6, 182, 212, 0.24), rgba(255, 255, 255, 0.03));
}

.project.entrance {
  background: linear-gradient(150deg, rgba(244, 114, 182, 0.24), rgba(255, 255, 255, 0.03));
}

.project.growth {
  background: linear-gradient(150deg, rgba(168, 85, 247, 0.24), rgba(255, 255, 255, 0.03));
}

.project .adjustment-icon {
  display: block;
  width: 3.05rem;
  height: 3.05rem;
  overflow: visible;
  filter: drop-shadow(0 5px 10px rgba(20, 184, 166, 0.26));
}

.project .adjustment-icon-plate {
  fill: #0f766e;
  stroke: #5eead4;
  stroke-width: 1.5;
}

.project .adjustment-icon-track {
  fill: none;
  stroke: #ccfbf1;
  stroke-width: 3;
  stroke-linecap: round;
}

.project .adjustment-icon-knob {
  fill: #f8fafc;
  stroke: #134e4a;
  stroke-width: 1.5;
}

.project .feed-silo-icon {
  display: block;
  width: 3.05rem;
  height: 3.05rem;
  overflow: visible;
  filter: drop-shadow(0 5px 10px rgba(250, 204, 21, 0.24));
}

.project .feed-silo-roof,
.project .feed-silo-body,
.project .feed-silo-hopper {
  fill: #facc15;
  stroke: #fef9c3;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.project .feed-silo-body {
  fill: #ca8a04;
}

.project .feed-silo-band,
.project .feed-silo-legs,
.project .feed-silo-auger {
  fill: none;
  stroke: #fef9c3;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project .daily-report-icon {
  display: block;
  width: 3.05rem;
  height: 3.05rem;
  overflow: visible;
  filter: drop-shadow(0 5px 10px rgba(59, 130, 246, 0.25));
}

.project .daily-report-sheet {
  fill: #eff6ff;
  stroke: #93c5fd;
  stroke-width: 2;
}

.project .daily-report-clip {
  fill: #3b82f6;
  stroke: #bfdbfe;
  stroke-width: 1.5;
}

.project .daily-report-check {
  fill: none;
  stroke: #22c55e;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project .daily-report-line {
  fill: none;
  stroke: #2563eb;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.project .memo-house-icon {
  display: block;
  width: 3.1rem;
  height: 3.1rem;
  overflow: visible;
  filter: drop-shadow(0 4px 7px rgba(122, 184, 66, 0.28));
}

.project .memo-house-roof,
.project .memo-house-frame {
  fill: none;
  stroke: #7ab842;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project .memo-house-roof {
  stroke-width: 3;
}

.project .memo-house-frame {
  stroke-width: 3;
}

.project .memo-note-paper {
  fill: #ecfeff;
  stroke: #67e8f9;
  stroke-width: 2;
  stroke-linejoin: round;
}

.project .memo-note-fold {
  fill: #bae6fd;
  stroke: #67e8f9;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.project .memo-note-label {
  fill: #164e63;
  font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.project .memo-note-lines {
  fill: none;
  stroke: #0e7490;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.project .memo-pencil-body {
  fill: #fb7185;
  stroke: #fecdd3;
  stroke-width: 1.3;
  stroke-linejoin: round;
}

.project .memo-pencil-wood {
  fill: #fde68a;
  stroke: #f59e0b;
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.project .memo-pencil-lead {
  fill: #1f2937;
}

.project .memo-pencil-seam {
  fill: none;
  stroke: #fff1f2;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.project .cctv-icon {
  display: block;
  width: 2.9rem;
  height: 2.2rem;
  overflow: visible;
  color: #a5f3fc;
  filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.32));
}

.project .cctv-shade,
.project .cctv-body {
  stroke: currentColor;
  stroke-linejoin: round;
}

.project .cctv-shade {
  fill: #164e63;
  stroke-width: 2.5;
}

.project .cctv-body {
  fill: #0e7490;
  stroke-width: 2.5;
}

.project .cctv-lens {
  fill: #082f49;
  stroke: #ecfeff;
  stroke-width: 2;
}

.project .cctv-arm {
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project .cctv-base {
  fill: currentColor;
}

.project .growth-photo-icon {
  display: block;
  width: 3.6rem;
  height: 3.6rem;
  border: 1px solid rgba(167, 243, 208, 0.34);
  border-radius: 0.85rem;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(0, 53, 42, 0.38);
}

.project.codex-chat {
  background: linear-gradient(150deg, rgba(236, 72, 153, 0.24), rgba(255, 255, 255, 0.03));
}

.project.resources {
  background: linear-gradient(150deg, rgba(245, 158, 11, 0.24), rgba(255, 255, 255, 0.03));
}

.project.temperature {
  background: linear-gradient(150deg, rgba(56, 189, 248, 0.23), rgba(255, 255, 255, 0.03));
}

.project.ventilation {
  background: linear-gradient(150deg, rgba(45, 212, 191, 0.24), rgba(255, 255, 255, 0.03));
}

.project.manual {
  background: linear-gradient(150deg, rgba(99, 102, 241, 0.24), rgba(255, 255, 255, 0.03));
}

.project.water {
  background: linear-gradient(150deg, rgba(14, 165, 233, 0.23), rgba(255, 255, 255, 0.03));
}

.project.haccp {
  background: linear-gradient(150deg, rgba(132, 204, 22, 0.21), rgba(255, 255, 255, 0.03));
}

.project.mortality {
  background: linear-gradient(150deg, rgba(168, 85, 247, 0.22), rgba(255, 255, 255, 0.03));
}

.project.biosecurity {
  background: linear-gradient(150deg, rgba(249, 115, 22, 0.22), rgba(255, 255, 255, 0.03));
}

.project.security {
  background: linear-gradient(150deg, rgba(100, 116, 139, 0.25), rgba(255, 255, 255, 0.03));
}

.project.future-card {
  display: none;
}

.project.future-card:hover {
  transform: none;
  border-color: rgba(255, 255, 255, 0.10);
}

.project .icon {
  font-size: 2.2rem;
}

.project .fan-icon {
  position: relative;
  display: block;
  width: 2.45rem;
  height: 2.45rem;
  border: 2px solid rgba(153, 246, 228, 0.82);
  border-radius: 50%;
  color: #5eead4;
  background:
    conic-gradient(
      from 12deg,
      transparent 0deg 12deg,
      currentColor 12deg 54deg,
      transparent 54deg 102deg,
      currentColor 102deg 144deg,
      transparent 144deg 192deg,
      currentColor 192deg 234deg,
      transparent 234deg 282deg,
      currentColor 282deg 324deg,
      transparent 324deg 360deg
    );
  box-shadow:
    inset 0 0 0 3px rgba(6, 31, 29, 0.82),
    0 0 18px rgba(45, 212, 191, 0.22);
}

.project .fan-icon::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 0.48rem;
  height: 0.48rem;
  border: 2px solid rgba(153, 246, 228, 0.92);
  border-radius: 50%;
  background: #0b2925;
  transform: translate(-50%, -50%);
}

.project strong {
  margin-top: 20px;
  font-size: 1.55rem;
}

@media (max-width: 760px) {
  .shell {
    padding: 16px;
  }

  .login-card,
  .portal-card {
    padding: 28px 22px;
    border-radius: 22px;
  }

  .portal-header {
    display: grid;
  }

  .account-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .account-actions form,
  .account-actions button,
  .button-link {
    width: 100%;
  }

  .project-grid {
    gap: 10px;
    margin-top: 20px;
  }

  .project {
    min-height: 120px;
    align-items: center;
    justify-content: center;
    padding: 16px 8px;
    text-align: center;
  }

  .project strong {
    margin-top: 10px;
    font-size: 1.1rem;
  }
}

/* 휴대폰에서는 메뉴 수가 바뀌어도 3열 x n행으로 흐르게 한다.
   각 카드는 44px 최소 터치 영역보다 충분히 크게 유지한다. */
@media (max-width: 520px) {
  .shell {
    min-height: 100svh;
    place-items: start center;
    padding: 8px;
  }

  .portal-card {
    padding: 12px;
    border-radius: 18px;
  }

  .portal-identity-header {
    row-gap: 4px;
  }

  .portal-identity-header .portal-user {
    font-size: 0.82rem;
  }

  .portal-identity-header h1 {
    margin: 8px 0 0;
    font-size: 1.3rem;
    line-height: 1.2;
    letter-spacing: -0.035em;
  }

  .project-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 12px;
  }

  .project-grid.viewer-project-grid {
    grid-template-columns: minmax(150px, 220px);
  }

  .project {
    min-height: 88px;
    align-items: center;
    justify-content: center;
    padding: 8px 2px;
    border-radius: 12px;
    text-align: center;
  }

  .project.daily-report {
    grid-column: 2;
  }

  .project .icon {
    font-size: 1.45rem;
  }

  .project img.icon,
  .project .adjustment-icon,
  .project .feed-silo-icon,
  .project .daily-report-icon,
  .project .learning-icon {
    width: 1.9rem;
    height: 1.9rem;
  }

  .project .memo-house-icon {
    width: 2.4rem;
    height: 2.4rem;
  }

  .project .growth-photo-icon {
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 0.55rem;
    box-shadow: 0 4px 10px rgba(0, 53, 42, 0.32);
  }

  .project .cctv-icon {
    width: 1.8rem;
    height: 1.35rem;
  }

  .project .fan-icon {
    width: 1.65rem;
    height: 1.65rem;
    border-width: 1.5px;
    box-shadow:
      inset 0 0 0 2px rgba(6, 31, 29, 0.82),
      0 0 10px rgba(45, 212, 191, 0.20);
  }

  .project .fan-icon::after {
    width: 0.34rem;
    height: 0.34rem;
    border-width: 1.5px;
  }

  .project strong {
    margin-top: 5px;
    font-size: 0.8rem;
    line-height: 1.15;
  }
}

@media (max-width: 420px) {
  .portal-header.portal-identity-header {
    column-gap: 8px;
  }

  .portal-identity-header .badge {
    padding: 7px 8px;
    font-size: 0.62rem;
    letter-spacing: 0.04em;
  }

  .portal-identity-header button.secondary {
    padding: 10px;
  }
}

/* Main portal: three columns, continuous menu order. */
#portal-view .project-grid:not(.viewer-project-grid) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
#portal-view .project-grid .project.daily-report {
  grid-column: auto;
}
