/* --- Reset & Variables --- */
:root {
    --bg-start: #0b0d19;
    --bg-end: #121424;
    --glass-bg: rgba(20, 24, 45, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-glow: rgba(0, 242, 254, 0.03);
    
    --text-main: #f1f3f9;
    --text-muted: #9ba1b6;
    
    --cyan: #00f2fe;
    --emerald: #00f59b;
    --rose: #ff4d6d;
    --amber: #ffb703;
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}


html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-start);
    background-image: radial-gradient(circle at 50% 0%, #1c213e 0%, var(--bg-end) 70%);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    padding: 2rem 1rem;
    overflow-x: hidden;
    position: relative;
}

.app-container {
    width: 100%;
    min-width: 0;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3), inset 0 0 12px var(--glass-glow);
    transition: var(--transition-smooth);
}

.glass:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4), inset 0 0 16px rgba(0, 242, 254, 0.05);
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(15, 18, 36, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    backdrop-filter: blur(8px);
}

.site-subtitle {
    margin: 4px 0 0;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.85rem;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 2.5rem;
    height: 2.5rem;
    color: var(--cyan);
}

.pulse {
    animation: heartbeat 2s infinite ease-in-out;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 8px var(--cyan)); }
}

.title-sub h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.title-sub span {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--cyan);
    font-weight: 600;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex: 0 0 auto;
    white-space: nowrap;
}

.indicator-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
    background-color: var(--text-muted);
    box-shadow: 0 0 8px var(--text-muted);
}

.indicator-dot.online {
    background-color: var(--emerald);
    box-shadow: 0 0 10px var(--emerald);
    animation: blink-green 2s infinite;
}

.indicator-dot.offline {
    background-color: var(--rose);
    box-shadow: 0 0 10px var(--rose);
    animation: blink-red 2s infinite;
}

@keyframes blink-green {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; filter: brightness(1.2); }
}
@keyframes blink-red {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; filter: brightness(1.2); }
}

.status-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    line-height: 1;
    white-space: nowrap;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.metric-header i {
    width: 1.25rem;
    height: 1.25rem;
}

.icon-status { color: var(--emerald); }
.icon-uptime { color: var(--cyan); }
.icon-latency { color: var(--amber); }

.metric-value {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -1px;
}

.metric-footer {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: auto;
}

.dashboard-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .dashboard-content {
        grid-template-columns: 1fr;
    }
}


@media (max-width: 480px) {
    body {
        padding: 1rem 0.75rem;
    }

    .main-header {
        gap: 0.75rem;
        padding: 1rem;
    }

    .logo-area {
        min-width: 0;
        gap: 0.75rem;
    }

    .logo-icon {
        width: 2.25rem;
        height: 2.25rem;
        flex: 0 0 auto;
    }

    .title-sub {
        min-width: 0;
    }

    .title-sub h1 {
        font-size: 1.3rem;
        line-height: 1.15;
    }

    .status-indicator {
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }

    .status-text {
        font-size: 0.8125rem;
    }
}

/* Prevent decorative/composited elements and grid children from widening the page on iOS. */
.main-header,
.metrics-grid,
.metric-card,
.dashboard-content,
.chart-section,
.sidebar,
.history-section,
.section-header,
.chart-container {
    min-width: 0;
    max-width: 100%;
}

.chart-container canvas {
    display: block;
    max-width: 100% !important;
}

.chart-section {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 320px;
}

.sidebar {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input[type="url"] {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #ffffff;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition-smooth);
}

.form-group input[type="url"]:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.input-range-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.form-group input[type="range"] {
    flex: 1;
    accent-color: var(--cyan);
    background: rgba(0, 0, 0, 0.2);
    height: 6px;
    border-radius: 3px;
    outline: none;
}

.range-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--cyan);
    min-width: 40px;
}

.quick-status-info {
    margin-top: auto;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.08);
}

.quick-status-info h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.quick-status-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    white-space: nowrap;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    transition: var(--transition-smooth);
    outline: none;
}

.btn i {
    width: 1rem;
    height: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    color: #0b0d19;
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 242, 254, 0.35);
}

.btn-success {
    background: linear-gradient(135deg, #00f59b 0%, #00b894 100%);
    color: #0b0d19;
    box-shadow: 0 4px 15px rgba(0, 245, 155, 0.2);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 245, 155, 0.35);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.history-section {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.history-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.history-table th {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.875rem 1rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.history-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.history-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.table-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem !important;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
}

.badge-success {
    background: rgba(0, 245, 155, 0.1);
    color: var(--emerald);
    border: 1px solid rgba(0, 245, 155, 0.2);
}

.badge-error {
    background: rgba(255, 77, 109, 0.1);
    color: var(--rose);
    border: 1px solid rgba(255, 77, 109, 0.2);
}

.latency-fast { color: var(--emerald); }
.latency-normal { color: var(--amber); }
.latency-slow { color: var(--rose); }

/* --- Shared navigation / analytics additions --- */
.static-info-box {
    font-size: 0.85rem;
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.analytics-link {
    margin-top: 0.75rem;
    text-decoration: none;
}

.header-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    white-space: nowrap;
}

.header-link:hover {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
}

.header-link svg {
    width: 1rem;
    height: 1rem;
}

.analytics-controls {
    padding: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 1rem;
}

.analytics-control-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 150px;
    flex: 1 1 170px;
}

.analytics-control-group label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.analytics-control-group select {
    width: 100%;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    border-radius: 8px;
    padding: 0.75rem 0.85rem;
    font: inherit;
    outline: none;
}

.analytics-control-group select:focus {
    border-color: var(--cyan);
}

.analytics-load-button {
    min-height: 45px;
    flex: 0 0 auto;
}

.analytics-status {
    width: 100%;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.5;
}

.analytics-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
}

.analytics-metric-card {
    padding: 1.15rem;
    min-width: 0;
}

.analytics-metric-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-bottom: 0.55rem;
}

.analytics-metric-value {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    overflow-wrap: anywhere;
}

.analytics-metric-detail {
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-top: 0.45rem;
    min-height: 1.1em;
}

.analytics-chart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.analytics-chart-card {
    padding: 1.25rem;
    min-width: 0;
}

.analytics-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.analytics-chart-header h2 {
    font-size: 1.05rem;
}

.analytics-chart-container {
    position: relative;
    width: 100%;
    height: 360px;
    min-width: 0;
}

.analytics-chart-container canvas {
    display: block;
    max-width: 100% !important;
}

.analytics-chart-note {
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-top: 0.8rem;
    line-height: 1.5;
}

.analytics-meta-card {
    padding: 1.25rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.7;
}

.analytics-meta-card strong {
    color: var(--text-main);
}

@media (max-width: 600px) {
    .analytics-controls {
        padding: 1rem;
    }

    .analytics-load-button {
        width: 100%;
    }

    .analytics-chart-container {
        height: 300px;
    }

    .analytics-chart-header {
        align-items: flex-start;
    }
}

/* 累積・90日稼働率を識別しやすくするが、既存配色を壊さない程度の強調 */
.analytics-metric-highlight {
    border-color: rgba(0, 245, 155, 0.2);
}


/* --- 直近24時間の時間別ステータス --- */
.hourly-status-section {
    padding: 1.25rem 1.4rem;
    min-width: 0;
}

.hourly-status-heading,
.hourly-status-component-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.hourly-status-heading {
    padding-bottom: 0.85rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--glass-border);
}

.hourly-status-heading h2 {
    font-size: 1rem;
}

.hourly-status-heading span,
.hourly-status-overall {
    color: var(--text-muted);
    font-size: 0.78rem;
    white-space: nowrap;
}

.hourly-status-component-row {
    margin-bottom: 0.7rem;
}

.hourly-status-component-name {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.hourly-status-check {
    display: inline-grid;
    place-items: center;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    background: var(--emerald);
    color: #08130e;
    font-size: 0.75rem;
    font-weight: 800;
    flex: 0 0 auto;
}

.hourly-status-strip {
    --hourly-status-hours: 24;
    display: grid;
    grid-template-columns: repeat(var(--hourly-status-hours), minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    min-width: 0;
}

.hourly-status-segment {
    appearance: none;
    -webkit-appearance: none;
    display: block;
    width: 100%;
    min-width: 0;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 2px;
    background: rgba(155, 161, 182, 0.35);
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.hourly-status-segment:hover,
.hourly-status-segment:focus-visible {
    transform: scaleY(1.25);
    filter: brightness(1.2);
    outline: 1px solid rgba(255, 255, 255, 0.75);
    outline-offset: 1px;
}

.hourly-status-segment.operational { background: var(--emerald); }
.hourly-status-segment.degraded { background: var(--amber); }
.hourly-status-segment.outage { background: var(--rose); }
.hourly-status-segment.unknown,
.hourly-status-segment.no-data { background: rgba(155, 161, 182, 0.35); }

.hourly-status-detail {
    min-height: 1.2rem;
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.5;
}

.hourly-status-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1rem;
    margin-top: 0.55rem;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.hourly-status-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.hourly-status-legend-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 2px;
    background: rgba(155, 161, 182, 0.35);
}

.hourly-status-legend-dot.operational { background: var(--emerald); }
.hourly-status-legend-dot.degraded { background: var(--amber); }
.hourly-status-legend-dot.outage { background: var(--rose); }
.hourly-status-legend-dot.unknown { background: rgba(155, 161, 182, 0.35); }

@media (max-width: 600px) {
    .hourly-status-section {
        padding: 1rem;
    }

    .hourly-status-strip {
        gap: 1px;
    }

    .hourly-status-segment {
        height: 16px;
        border-radius: 1px;
    }

    .hourly-status-heading,
    .hourly-status-component-row {
        gap: 0.6rem;
    }

    .hourly-status-heading span,
    .hourly-status-overall {
        font-size: 0.7rem;
    }
}
