/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #1a1a2e;
    color: #e2e8f0;
}

.polygon-detail-card .spec-val {
    color: #e2e8f0;
}

/* 諸元テーブル */
.spec-table-container {
    overflow-x: auto;
    margin-top: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.spec-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
    color: #e2e8f0;
    text-align: left;
}

.spec-table th, .spec-table td {
    padding: 4px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    word-break: keep-all;
    white-space: nowrap;
}

.spec-table th {
    background: rgba(0, 242, 254, 0.15);
    color: #00f2fe;
    font-weight: 600;
}

.spec-table tr:last-child td {
    border-bottom: none;
}

.spec-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.text-center {
    text-align: center;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: rgba(26, 26, 46, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
    border-radius: 16px;
}

.glass-header {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    background: rgba(26, 26, 46, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-3d-toggle {
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    color: #0f172a;
    font-weight: 700;
    font-size: 0.82rem;
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 242, 254, 0.3);
    transition: all 0.2s ease;
}

.btn-3d-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 242, 254, 0.5);
}

.btn-3d-toggle.off {
    background: rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    box-shadow: none;
}

.user-info {
    font-size: 0.85rem;
    color: #a0aec0;
}


/* Login Screen */
.glass-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.login-box {
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-box h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-box p {
    font-size: 0.9rem;
    color: #a0aec0;
    margin-bottom: 2rem;
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn-google {
    background-color: #ffffff;
    color: #333;
}

.btn-microsoft {
    background-color: #0078d4;
    color: white;
}

/* Main App */
#app-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
    background-color: #111;
}

/* Loading Overlay */
#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(10, 10, 20, 0.4);
    pointer-events: none;
}

#loading-overlay.hidden {
    display: none;
}

.spinner-box {
    padding: 20px 35px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 242, 254, 0.2);
    border-top: 4px solid #00f2fe;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-message {
    font-size: 0.95rem;
    font-weight: 600;
    color: #00f2fe;
}

/* 画面下部 1日刻みスライダー ＋ 気象連動バー (広幅化で全31日気象表示) */
.bottom-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    width: calc(100% - 440px);
    max-width: 1450px;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ぴたり連動気象バッジ */
.weather-sync-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.85rem;
    color: #e2e8f0;
    backdrop-filter: blur(8px);
}

.weather-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.weather-icon {
    font-size: 1.05rem;
}

.weather-label {
    color: #94a3b8;
    font-weight: 500;
}

.weather-val {
    color: #f8fafc;
    font-weight: 700;
    font-family: 'Inter', monospace;
}

.weather-item.highlight-et .weather-val {
    color: #38bdf8;
    text-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

.weather-chart-wrapper {
    height: 120px;
    width: 100%;
    margin-top: 4px;
    margin-bottom: 2px;
}

.slider-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.highlight-date {
    color: #00f2fe;
    font-weight: 700;
    font-size: 1.1rem;
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

.lookback-mode-group {
    display: flex;
    gap: 6px;
    background: rgba(15, 23, 42, 0.6);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.lookback-mode-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 4px 10px;
    font-size: 0.76rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lookback-mode-btn:hover {
    color: #f8fafc;
}

.lookback-mode-btn.active {
    background: #00f2fe;
    color: #0f172a;
    font-weight: 700;
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.5);
}

.slider-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    padding-left: 26px;
    padding-right: 26px;
    box-sizing: border-box;
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    margin: 0;
    outline: none;
}

/* Chrome/Safari */
input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #00f2fe 50%, #ff9800 50%);
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    border: 2px solid #0f172a;
}

/* Firefox */
input[type="range"]::-moz-range-track {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #00f2fe 50%, #ff9800 50%);
}
input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    border: 2px solid #0f172a;
}

/* スライダーの日毎メモリ & 日付表示バー (つまみ中心位置に100%完全一致) */
.slider-ticks-container {
    width: 100%;
    height: 72px;
    margin-top: 2px;
    position: relative;
    box-sizing: border-box;
}

.tick-item {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.tick-line {
    width: 1.5px;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    margin-bottom: 2px;
}

.tick-item.has-label .tick-line {
    height: 8px;
    background: #00f2fe;
}

.tick-item.active .tick-line {
    height: 10px;
    background: #00f2fe;
    box-shadow: 0 0 8px #00f2fe;
}

.tick-sat-icons {
    position: absolute;
    top: -34px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    height: 14px;
}
.tick-sat-icons.empty {
    display: none;
}
.tick-sat-icon {
    font-size: 0.85rem;
    opacity: 0.6;
    transition: all 0.2s ease;
    cursor: help;
}
.tick-sat-icon:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* 縦方向にぴたり揃えた天気アイコン・気温・日付 */
.tick-weather-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    font-size: 0.68rem;
    line-height: 1.15;
    pointer-events: none;
}

.tick-icon {
    font-size: 0.88rem;
}

.tick-temp {
    color: #e2e8f0;
    font-weight: 600;
    font-size: 0.66rem;
}

.tick-date {
    color: #94a3b8;
    font-weight: 500;
    white-space: nowrap;
}

.tick-item.active .tick-temp,
.tick-item.active .tick-date {
    color: #00f2fe;
    font-weight: 700;
    text-shadow: 0 0 6px rgba(0, 242, 254, 0.5);
}

/* 右側設定＆ダッシュボードペイン */
#dashboard {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 380px;
    height: calc(100% - 40px);
    z-index: 1000;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.dashboard-header {
    margin-bottom: 18px;
}

.dashboard-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #f8fafc;
}

.setting-section {
    margin-bottom: 16px;
}

.setting-label {
    display: block;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 6px;
}

.glass-select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(15, 23, 42, 0.8);
    color: #00f2fe;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

.glass-select:focus {
    border-color: #00f2fe;
}

.secondary-action-btn {
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 242, 254, 0.12);
    border: 1px solid rgba(0, 242, 254, 0.4);
    color: #00f2fe;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-action-btn:hover {
    background: rgba(0, 242, 254, 0.25);
    border-color: #00f2fe;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.3);
}

.glass-divider {
    border: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 16px 0;
}

.spec-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(0, 242, 254, 0.25);
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.spec-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    line-height: 1.3;
}

.spec-label {
    color: #94a3b8;
    font-weight: 500;
}

.spec-val {
    color: #f8fafc;
    font-weight: 600;
    text-align: right;
}

.highlight-spec {
    background: rgba(0, 242, 254, 0.08);
    padding: 4px 6px;
    border-radius: 4px;
    border-left: 3px solid #00f2fe;
}

.spec-val-cloud {
    font-weight: 700;
    color: #00f2fe;
}

.cloud-good {
    color: #4ade80 !important;
}

.cloud-medium {
    color: #facc15 !important;
}

.cloud-high {
    color: #f87171 !important;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 10px;
}

.empty-hint {
    font-size: 0.85rem;
    color: #64748b;
    font-style: italic;
}

.polygon-badge {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.polygon-badge.active {
    border-color: #00f2fe;
    background: rgba(0, 242, 254, 0.08);
}

.badge-toggle {
    background: #00f2fe;
    color: #0f172a;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.badge-toggle.off {
    background: #475569;
    color: #cbd5e1;
}

/* Charts */
#charts-container {
    margin-top: 15px;
}

.chart-wrapper {
    background: rgba(15, 23, 42, 0.6);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.hidden {
    display: none !important;
}

/* ログイン画面スタイル */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
}

.login-box {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 2.5rem;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
}

.login-box h1 {
    font-size: 1.8rem;
    color: #f8fafc;
    margin-bottom: 0.5rem;
}

.login-box p {
    color: #94a3b8;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.login-box .btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.login-box .btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-google {
    background: #ea4335;
    color: white;
}

.btn-google:hover {
    background: #dc2626;
}

.btn-microsoft {
    background: #00a4ef;
    color: white;
}

.btn-microsoft:hover {
    background: #0284c7;
}

/* ==========================================================================
   🤖 営農AIアドバイスカード (シーズナリティ × 水収支) スタイル
   ========================================================================== */
.ai-advisor-card {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(56, 189, 248, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    padding: 12px;
    font-size: 11px;
}

.ai-stage-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-stage-badge {
    font-weight: 600;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.12);
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid rgba(56, 189, 248, 0.3);
    display: block;
    font-size: 11px;
    box-sizing: border-box;
    width: 100%;
}

.ai-status-badge {
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 4px;
    font-weight: 600;
    line-height: 1.45;
    display: block;
    box-sizing: border-box;
    width: 100%;
    word-break: break-word;
}

.ai-status-badge.good {
    background: rgba(72, 187, 120, 0.2);
    color: #68d391;
    border: 1px solid rgba(72, 187, 120, 0.4);
}

.ai-status-badge.warning {
    background: rgba(237, 137, 54, 0.2);
    color: #f6ad55;
    border: 1px solid rgba(237, 137, 54, 0.4);
}

.ai-status-badge.danger {
    background: rgba(229, 62, 62, 0.2);
    color: #fc8181;
    border: 1px solid rgba(229, 62, 62, 0.4);
}

.ai-status-badge.info {
    background: rgba(66, 153, 225, 0.2);
    color: #63b3ed;
    border: 1px solid rgba(66, 153, 225, 0.4);
}

.ai-data-summary {
    color: #cbd5e0;
    line-height: 1.45;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    border-left: 3px solid #38bdf8;
}

.ai-block-title {
    color: #e2e8f0;
    font-weight: 600;
    margin-top: 6px;
    margin-bottom: 4px;
    font-size: 11px;
}

.ai-list {
    margin: 0 0 6px 0;
    padding-left: 16px;
    color: #e2e8f0;
    line-height: 1.4;
}

.ai-list li {
    margin-bottom: 4px;
}

.ai-tips-list li {
    color: #a0aec0;
}

/* ==============================================================================
 * カスタム農地 (User Custom Polygon) ＆ 描画ツール スタイル
 * ============================================================================== */

.header-center {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-draw-toggle, .btn-import-toggle {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid #10b981;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-draw-toggle:hover, .btn-import-toggle:hover {
    background: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.btn-draw-toggle.active {
    background: #e53e3e;
    color: #fff;
    border-color: #fc8181;
    box-shadow: 0 0 12px rgba(229, 62, 62, 0.6);
}

.draw-guide-banner {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid #10b981;
    color: #f8fafc;
    padding: 8px 18px;
    border-radius: 24px;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
}

.draw-guide-banner.hidden {
    display: none;
}

.btn-cancel-draw {
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    border: 1px solid #ef4444;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
}

.btn-cancel-draw:hover {
    background: #ef4444;
    color: #fff;
}

/* モーダルカード */
.modal-card {
    width: 440px;
    max-width: 90vw;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
    color: #f8fafc;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    margin-bottom: 16px;
}

.modal-header h2 {
    font-size: 16px;
    margin: 0;
    color: #38bdf8;
}

.modal-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
}

.modal-close-btn:hover {
    color: #fff;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-field-group label {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

.modal-field-group input, .modal-field-group select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f8fafc;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

.modal-field-group input:focus, .modal-field-group select:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.modal-row-two {
    display: flex;
    gap: 10px;
}

.modal-row-two .modal-field-group {
    flex: 1;
}

.geom-info-badge {
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    color: #cbd5e0;
    font-family: monospace;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 14px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-primary {
    background: #0284c7;
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.btn-primary:hover {
    background: #0369a1;
}



