:root {
  --bg: #f5f7f5;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #14532d;
  --primary-hover: #166534;
  --primary-soft: #ecfdf5;
  --accent: #b45309;
  --gold: #d97706;
  --danger: #991b1b;
  --danger-bg: #fef2f2;
  --warn-bg: #fffbeb;
  --info-bg: #eff6ff;
  --radius: 16px;
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.08);
  --font-serif: "Noto Serif KR", Georgia, serif;
  --font-sans: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}

/* 고급 글래스모피즘 상단바 */
.topbar {
  background: rgba(20, 83, 45, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 13px 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar-left { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.nav-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
}
.main-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.main-nav a {
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.18s ease, color 0.18s ease;
}
.main-nav a:hover, .main-nav a.active { background: rgba(255, 255, 255, 0.18); color: #fff; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: 0.88rem; color: #f1f5f9; font-weight: 500; }
.auth-link { color: #e2e8f0; text-decoration: none; font-size: 0.88rem; font-weight: 600; padding: 6px 12px; border-radius: 8px; }
.auth-cta { background: #fff; color: var(--primary) !important; }

/* 메인 컨테이너 */
.container { max-width: 1240px; margin: 28px auto; padding: 0 22px 92px; }

/* 에디토리얼 페이지 비주얼 배너 (공통) */
.page-banner {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  min-height: 210px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-end;
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow-md);
}
.page-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 28, 18, 0.22) 0%, rgba(10, 28, 18, 0.82) 100%);
}
.page-banner-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: clamp(22px, 3.5vw, 34px);
  color: #fff;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}
.page-banner h1, .page-banner h2 {
  font-family: var(--font-serif);
  color: #fff;
  margin: 0 0 6px;
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  letter-spacing: -0.02em;
}
.page-banner p { margin: 0; color: rgba(255, 255, 255, 0.9); font-size: 0.95rem; max-width: 60ch; }
.banner-kicker {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 10px;
}

/* 메인 포털 풀 비주얼 히어로 */
.hero-banner {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  min-height: 410px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow-md);
}
.hero-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, rgba(11, 34, 21, 0.88) 0%, rgba(15, 45, 28, 0.68) 55%, rgba(15, 45, 28, 0.28) 100%);
}
.hero-content {
  position: relative;
  z-index: 1;
  padding: clamp(28px, 5vw, 56px);
  max-width: 720px;
  color: #fff;
}
.hero-pill {
  display: inline-block;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.24);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.hero-banner h1 {
  font-family: var(--font-serif);
  margin: 0 0 14px;
  font-size: clamp(1.65rem, 3.6vw, 2.75rem);
  line-height: 1.28;
  letter-spacing: -0.025em;
  color: #fff;
}
.hero-banner p { margin: 0 0 22px; color: rgba(241, 245, 249, 0.94); font-size: 1rem; }
.hero-search {
  display: flex;
  gap: 8px;
  max-width: 540px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.96);
  padding: 6px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
}
.hero-search input { flex: 1; border: none; background: transparent; padding: 10px 12px; font-size: 0.96rem; color: var(--ink); }
.hero-search input:focus { outline: none; }
.hero-search button { background: var(--primary); color: #fff; padding: 11px 20px; border-radius: 9px; white-space: nowrap; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-outline { background: rgba(255, 255, 255, 0.12); backdrop-filter: blur(6px); border: 1.5px solid rgba(255, 255, 255, 0.72); color: #fff; }
.btn-outline:hover { background: rgba(255, 255, 255, 0.24); }

/* 스플릿 스크린 고급 로그인 / 회원가입 쉘 */
.auth-shell {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--surface);
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  max-width: 980px;
  margin: 24px auto;
}
.auth-visual {
  position: relative;
  min-height: 480px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  padding: 36px;
  color: #fff;
}
.auth-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(14, 38, 24, 0.18) 0%, rgba(14, 38, 24, 0.86) 100%);
}
.auth-visual-inner { position: relative; z-index: 1; }
.auth-visual h2 { font-family: var(--font-serif); color: #fff; font-size: 1.65rem; line-height: 1.35; margin: 0 0 10px; }
.auth-visual p { margin: 0; color: rgba(241, 245, 249, 0.9); font-size: 0.92rem; }
.auth-form-pane { padding: clamp(26px, 4vw, 44px); display: flex; flex-direction: column; justify-content: center; }
.auth-form-pane h1 { font-family: var(--font-serif); font-size: 1.6rem; margin: 0 0 6px; }

/* 카드·패널 및 그리드 */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.section-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.section-head h2 { font-family: var(--font-serif); margin: 0; font-size: 1.3rem; }
.level-tile, .crop-tile {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  background: #fbfdfb;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.level-tile:hover, .crop-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.quick-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.quick-links a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
  background: #f9fbf9;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.quick-links a:hover { border-color: var(--primary); background: var(--primary-soft); }
.quick-links strong { display: block; color: var(--primary); margin-bottom: 2px; }
.quick-links span { font-size: 0.84rem; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

h1, h2, h3 { margin-top: 0; }
.metric { font-family: var(--font-serif); font-size: 1.55rem; font-weight: 700; color: var(--primary); margin-top: 4px; }
.muted { color: var(--muted); font-size: 0.89rem; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge-green { background: #dcfce7; color: #14532d; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.flash { padding: 13px 18px; border-radius: 12px; margin-bottom: 18px; font-weight: 600; }
.flash-success { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.flash-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fca5a5; }

label { display: block; font-weight: 600; font-size: 0.88rem; margin: 12px 0 5px; color: var(--ink2); }
input, select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid #cbd5e1; border-radius: 10px;
  font-size: 0.95rem; font-family: inherit; background: #fff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 83, 45, 0.12);
}
button, .btn {
  display: inline-block; background: var(--primary); color: #fff; border: none;
  padding: 10px 18px; border-radius: 10px; cursor: pointer; font-weight: 600;
  text-decoration: none; font-size: 0.92rem; text-align: center;
  transition: background 0.16s ease, transform 0.12s ease;
}
button:hover, .btn:hover { background: var(--primary-hover); }
.btn-secondary { background: #475569; }
.btn-secondary:hover { background: #334155; }
.btn-danger { background: var(--danger); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 520px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
th { background: #f8fafc; font-weight: 700; color: #334155; white-space: nowrap; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.photo-card { border: 1px solid var(--line); border-radius: 10px; padding: 7px; width: 170px; background: #fff; }
.photo-card img { width: 100%; height: 112px; object-fit: cover; border-radius: 6px; display: block; }

/* 팝업 모달 */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 999; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 18px; max-width: 560px; width: 100%;
  max-height: 85vh; overflow-y: auto;
  padding: 24px; box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
}
.alert-item { padding: 13px 15px; border-radius: 10px; margin-bottom: 10px; border-left: 4px solid var(--primary); background: var(--info-bg); }
.alert-item.warning { border-left-color: var(--accent); background: var(--warn-bg); }
.alert-item.danger { border-left-color: var(--danger); background: var(--danger-bg); }

/* 모바일 하단 탭바 */
.mobile-tabbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  z-index: 600;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-tabbar a {
  flex: 1; text-align: center; padding: 12px 4px;
  color: var(--ink); text-decoration: none; font-size: 0.82rem; font-weight: 600;
}
.mobile-tabbar a:hover { color: var(--primary); background: var(--primary-soft); }

/* 태블릿 (641px ~ 1024px) */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-shell { grid-template-columns: 1fr; max-width: 560px; }
  .auth-visual { min-height: 220px; padding: 24px; }
}

/* 모바일 (768px 이하) */
@media (max-width: 768px) {
  .topbar-inner { padding: 10px 14px; }
  .topbar-left { width: 100%; }
  .nav-toggle { display: inline-block; }
  .main-nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.18); }
  .main-nav.open { display: flex; }
  .topbar-user { width: 100%; justify-content: flex-end; }
  .grid-2, .grid-3, .grid-4, .quick-links { grid-template-columns: 1fr; }
  .container { padding: 0 14px 96px; margin-top: 16px; }
  .panel { padding: 16px; }
  .hero-banner { min-height: 360px; }
  .hero-search { flex-direction: column; background: transparent; padding: 0; box-shadow: none; }
  .hero-search input { background: #fff; border-radius: 10px; }
  .mobile-tabbar { display: flex; }
}

/* 실시간 날씨 위젯 */
.weather-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; }
.weather-days { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.weather-day-card {
  text-align: center;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbf9;
}

/* 모바일 카메라 촬영 및 앨범 업로드 UI */
.camera-upload-box {
  margin: 12px 0;
  padding: 14px;
  border: 1.5px dashed #94a3b8;
  border-radius: 12px;
  background: #f8fafc;
}
.sr-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.camera-btn, .album-btn {
  display: block;
  text-align: center;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  margin: 0;
  font-weight: 700;
  font-size: 0.92rem;
}
.camera-btn { background: var(--primary); color: #fff; }
.camera-btn:hover { background: var(--primary-hover); }
.album-btn { background: #e2e8f0; color: var(--ink); }
.album-btn:hover { background: #cbd5e1; }

/* 영농 통합 캘린더 그리드 */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  min-width: 620px;
}
.cal-head {
  background: #f8fafc;
  text-align: center;
  padding: 9px 4px;
  font-weight: 700;
  font-size: 0.85rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.cal-head.sun { color: #b91c1c; }
.cal-head.sat { color: #1d4ed8; }
.cal-cell {
  min-height: 98px;
  padding: 6px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.cal-cell.empty { background: #f8fafc; }
.cal-cell.today { background: #f0fdf4; outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-day-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.cal-day-num { font-weight: 700; font-size: 0.86rem; }
.cal-add-j { font-size: 0.72rem; color: var(--muted); text-decoration: none; }
.cal-add-j:hover { color: var(--primary); text-decoration: underline; }
.cal-events { display: flex; flex-direction: column; gap: 3px; }
.cal-chip {
  font-size: 0.74rem;
  padding: 2px 5px;
  border-radius: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.cal-event { background: #dcfce7; color: #14532d; }
.cal-journal { background: #dbeafe; color: #1e40af; }
.cal-schedule { background: #fef3c7; color: #92400e; }
.agenda-row { padding: 10px 0; border-bottom: 1px solid var(--line); }

@media (max-width: 768px) {
  .weather-days { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 농사로형 12개월(상·중·하순 36구간) 간트 공정표 & 겸용 탭 */
.view-mode-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab-btn {
  background: #f1f5f9;
  color: var(--ink2);
  border: 1px solid var(--line);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}
.tab-btn:hover { background: #e2e8f0; color: var(--ink); }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.ns-scroll { width: 100%; overflow-x: auto; padding-bottom: 6px; }
.ns-canvas { min-width: 980px; }
.ns-section {
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px dashed #cbd5e1;
}
.ns-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 4px; }
.ns-sec-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  padding-bottom: 8px;
  margin-bottom: 0;
}
.ns-theme-green .ns-sec-title { border-bottom: 2px solid #59b23c; }
.ns-theme-amber .ns-sec-title { border-bottom: 2px solid #f59e0b; }
.ns-theme-emerald .ns-sec-title { border-bottom: 2px solid #4ca64c; }

.ns-months {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  text-align: center;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink2);
  padding: 8px 0 6px;
}
.ns-dekads {
  display: grid;
  grid-template-columns: repeat(36, minmax(0, 1fr));
  gap: 2px;
  margin-bottom: 10px;
}
.ns-dekads span { display: block; height: 7px; border-radius: 2px; }
.ns-bar-green .d1 { background: #4da63c; }
.ns-bar-green .d2 { background: #74c25e; }
.ns-bar-green .d3 { background: #a8dc96; }
.ns-bar-amber .d1 { background: #ea8c00; }
.ns-bar-amber .d2 { background: #f6b23d; }
.ns-bar-amber .d3 { background: #fcd68a; }

.ns-tracks { display: flex; flex-direction: column; gap: 7px; }
.ns-row {
  display: grid;
  grid-template-columns: repeat(36, minmax(0, 1fr));
  gap: 4px;
  align-items: stretch;
}
.ns-label-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 7px 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ns-task-box {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 7px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  white-space: normal;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ns-task-box:hover { background: #f0fdf4; border-color: var(--primary); color: var(--primary); }
.ns-task-box.is-done { background: #dcfce7; border-color: #86efac; color: #14532d; }
.ns-task-amber:hover { background: #fffbeb; border-color: #d97706; color: #92400e; }
.ns-task-pest:hover { background: #fef2f2; border-color: #b91c1c; color: #991b1b; }
.ns-task-summary { cursor: default; background: #fafcfb; color: var(--ink2); font-weight: 500; }

/* v1.5.2 간트 막대 세로 늘어짐 및 텍스트 넘침 방지 보강 */
.ns-task-box {
  min-width: 0;
  overflow: hidden;
  padding: 8px 10px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ns-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: keep-all;
  line-height: 1.35;
}

/* 스마트팜 전용 서브메뉴 및 설비 설치 간트 바 */
.sf-subnav { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sf-tab {
  padding: 9px 15px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink2);
  background: #f1f5f9;
  border: 1px solid var(--line);
}
.sf-tab:hover { background: #e2e8f0; color: var(--ink); }
.sf-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.sf-gantt-list { display: flex; flex-direction: column; gap: 10px; }
.sf-gantt-row {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 12px;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}
.sf-gantt-track {
  position: relative;
  height: 40px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.sf-gantt-bar {
  position: absolute;
  top: 4px;
  bottom: 4px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  background: #14532d;
  color: #fff;
}
.sf-gantt-bar.sev-warning { background: #b45309; }
.sf-gantt-bar.sev-danger { background: #991b1b; }
.sf-gantt-bar.is-done { background: #15803d; opacity: 0.82; }

@media (max-width: 768px) {
  .sf-gantt-row { grid-template-columns: 1fr; gap: 6px; }
}
