:root {
    --green: #2e7d32;
    --yellow: #f9a825;
    --red: #c62828;
    --info: #1565c0;
    --orange: #ef6c00;
    --grey: #757575;
    --bg: #f4f5f7;
    --card-bg: #ffffff;
    --text: #1f2933;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    background: #1f2933;
    padding: 14px 24px;
}

.brand {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    text-decoration: none;
}

.content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

h1 { margin: 0 0 12px; }
h2 { margin: 28px 0 10px; font-size: 20px; }

.description {
    background: #eef2f7;
    border-left: 4px solid var(--info);
    padding: 10px 14px;
    border-radius: 6px;
    margin: 6px 0 4px;
}
.desc-cell { color: #52606d; font-size: 14px; max-width: 360px; }

.hint { color: var(--grey); margin-top: 0; }
.empty { color: var(--grey); font-style: italic; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.card {
    display: block;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 18px;
    text-decoration: none;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    border-left: 10px solid var(--grey);
    transition: transform 0.05s ease-in-out;
}

.card:hover { transform: translateY(-2px); }
.card-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.card-subtitle { font-size: 14px; color: #52606d; margin-bottom: 8px; }
.card-state { font-size: 16px; margin-bottom: 6px; }
.card-desc { font-size: 13px; color: #52606d; margin-bottom: 10px; line-height: 1.35; }
.card-meta { font-size: 13px; color: var(--grey); }

.card.offline { opacity: 0.65; }
.warn { color: var(--red); font-weight: 600; }

.color-green { border-left-color: var(--green); }
.color-yellow { border-left-color: var(--yellow); }
.color-red { border-left-color: var(--red); }
.color-info { border-left-color: var(--info); }
.color-orange { border-left-color: var(--orange); }
.color-grey { border-left-color: var(--grey); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    background: var(--grey);
}
.badge.color-green { background: var(--green); }
.badge.color-yellow { background: var(--yellow); }
.badge.color-red { background: var(--red); }
.badge.color-info { background: var(--info); }
.badge.color-orange { background: var(--orange); }
.badge.color-grey { background: var(--grey); }

.timeline {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.timeline th, .timeline td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid #e4e7eb;
}
.timeline th { background: #eceff1; font-size: 14px; }
.time { white-space: nowrap; color: var(--grey); }

.dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    background: var(--grey);
    vertical-align: middle;
}
.dot.color-green { background: var(--green); }
.dot.color-yellow { background: var(--yellow); }
.dot.color-red { background: var(--red); }
.dot.color-info { background: var(--info); }
.dot.color-orange { background: var(--orange); }
.dot.color-grey { background: var(--grey); }

.raw { color: #9aa5b1; font-size: 12px; margin-left: 6px; }
.muted { color: #9aa5b1; }
.thumb {
    max-height: 160px;
    max-width: 240px;
    width: auto;
    height: auto;
    border-radius: 6px;
    object-fit: contain;
}

.thumb-lg {
    max-height: 480px;
    max-width: 100%;
    width: auto;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
}

.back, .brand { text-decoration: none; }
.back { color: var(--info); }

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

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

.topnav a {
    color: #d9e2ec;
    text-decoration: none;
    font-size: 14px;
}

.topnav a:hover { color: #fff; }

.inline-form { display: inline; margin: 0; }

.link-button {
    background: none;
    border: none;
    color: #d9e2ec;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
}

.link-button:hover { color: #fff; }

.form-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    max-width: 720px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field.full-width { grid-column: 1 / -1; }

.field label { font-size: 14px; font-weight: 600; }
.field input, .field select, .search-form input {
    padding: 10px 12px;
    border: 1px solid #cbd2d9;
    border-radius: 8px;
    font-size: 15px;
}

.btn {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    color: #fff;
    background: var(--info);
}

.btn-primary { background: var(--info); }
.btn-secondary { background: #52606d; }
.btn-danger { background: var(--red); }
.btn-small { padding: 6px 10px; font-size: 12px; margin: 2px 0; }

.form-actions, .search-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

.search-form { margin-bottom: 20px; }
.search-form input { min-width: 260px; }

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert-error {
    background: #ffebee;
    color: #b71c1c;
    border-left: 4px solid var(--red);
}

.alert-success {
    background: #e8f5e9;
    color: #1b5e20;
    border-left: 4px solid var(--green);
}

.status-active { background: var(--green); }
.status-inactive { background: var(--grey); }

.table-wrap { overflow-x: auto; }
.actions { min-width: 220px; }

.sort-link {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}

.sort-link:hover { color: var(--info); }

.admin-links {
    margin: 0 0 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.detail-card {
    background: #fff;
    border: 1px solid #d9e2ec;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 24px;
}

.checkbox-group {
    border: 1px solid #cbd2d9;
    border-radius: 8px;
    padding: 12px 14px;
    margin: 16px 0;
}

.checkbox-group legend {
    font-weight: 600;
    padding: 0 6px;
}

.checkbox-label {
    display: block;
    margin: 6px 0;
    font-size: 15px;
}

.checkbox-label input {
    margin-right: 8px;
}

.cabin-active-form {
    display: inline-flex;
    align-items: center;
    margin-right: 8px;
    vertical-align: middle;
}

.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background: #9aa5b1;
    border-radius: 24px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--green);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 13px;
    font-weight: 600;
    min-width: 24px;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin: 16px 0 24px;
    padding: 14px;
    background: var(--card-bg);
    border: 1px solid #d9e2ec;
    border-radius: 10px;
}

.filter-bar .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.field-wide {
    grid-column: 1 / -1;
}
