* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
}

.page {
    width: 95%;
    max-width: 1800px;
    margin: 24px auto;
}

h1, h2, h3 {
    margin-top: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.nav-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-link {
    display: inline-block;
    padding: 10px 14px;
    background: #e5e7eb;
    color: #111827;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
}

.nav-link.active {
    background: #2563eb;
    color: white;
}

/* shared layouts */
.layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.workspace-layout {
    display: grid;
    grid-template-columns: minmax(700px, 1fr) 380px;
    gap: 20px;
    align-items: start;
}

.map-layout {
    display: grid;
    grid-template-columns: minmax(700px, 1fr) 340px;
    gap: 20px;
    align-items: start;
}

.card {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.map-pane,
.map-card,
.editor-card {
    margin-bottom: 0;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

input,
select,
textarea,
button {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    margin-bottom: 14px;
}

input[type="color"] {
    height: 44px;
    padding: 4px;
}

textarea {
    resize: vertical;
}

button {
    border: none;
    background: #2563eb;
    color: white;
    cursor: pointer;
    border-radius: 6px;
}

button:hover {
    background: #1d4ed8;
}

.secondary-btn {
    background: #6b7280;
}

.secondary-btn:hover {
    background: #4b5563;
}

.delete-btn {
    width: auto;
    padding: 8px 12px;
    margin: 0;
    background: #dc2626;
}

.delete-btn:hover {
    background: #b91c1c;
}

.edit-btn {
    width: auto;
    padding: 8px 12px;
    margin: 0;
    background: #d97706;
}

.edit-btn:hover {
    background: #b45309;
}

.help {
    font-size: 13px;
    color: #4b5563;
    margin-bottom: 12px;
}

.selection-summary {
    padding: 10px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 14px;
    min-height: 44px;
}

.time-display {
    font-weight: 700;
    text-align: center;
}

.compact-time-display {
    margin-bottom: 0;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-row {
    min-width: 280px;
    flex: 1;
    max-width: 420px;
}

.viewer-toolbar {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.tool-switch {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.tool-btn {
    width: auto;
    min-width: 120px;
    margin-bottom: 0;
    background: #e5e7eb;
    color: #111827;
    font-weight: 600;
}

.tool-btn:hover {
    background: #d1d5db;
}

.tool-btn.active {
    background: #2563eb;
    color: #ffffff;
}

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

.button-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.button-row button {
    width: auto;
    margin-bottom: 0;
}

.opening-block {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
    background: #f9fafb;
}

.radio-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.radio-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
    font-weight: 600;
}

.radio-row input[type="radio"] {
    width: auto;
    margin: 0;
    padding: 0;
}

.opening-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    border-top: 1px solid #e5e7eb;
    padding: 10px 0;
}

.opening-meta {
    font-size: 13px;
    color: #374151;
}

#mapCanvas {
    display: block;
    width: 100%;
    max-width: 100%;
    border: 1px solid #111827;
    background: white;
}

#spaceList,
#buildingList,
#roomList {
    margin-top: 16px;
}

.list-row,
.space-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

.list-main {
    flex: 1;
}

.list-meta {
    color: #4b5563;
    font-size: 13px;
    margin-top: 4px;
}

.list-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.empty-state {
    color: #6b7280;
}

.panel-hidden {
    display: none !important;
}

/* calendar */
.calendar-top-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
}

.calendar-top-item select {
    margin-bottom: 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 18px;
}

.calendar-cell,
.calendar-day-header {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    min-height: 42px;
    padding: 6px;
    background: #fff;
    font-size: 12px;
    cursor: pointer;
}

.calendar-day-header {
    min-height: auto;
    background: #f3f4f6;
    font-weight: 700;
    text-align: center;
    padding: 6px 4px;
    cursor: default;
}

.calendar-cell.muted {
    background: #f9fafb;
    color: #9ca3af;
    cursor: default;
}

.calendar-cell.active-day {
    border: 2px solid #2563eb;
}

.calendar-date {
    font-weight: 700;
    margin-bottom: 0;
}

.schedule-block {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e5e7eb;
}

.schedule-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.schedule-item {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
    padding: 10px 12px;
}

.schedule-title {
    font-weight: 700;
}

.schedule-meta {
    font-size: 12px;
    color: #4b5563;
    margin-top: 4px;
}

.schedule-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.schedule-actions button {
    width: auto;
    margin-bottom: 0;
    padding: 6px 10px;
    font-size: 12px;
}

.event-time-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 1200px) {
    .workspace-layout {
        grid-template-columns: 1fr 340px;
    }
}

@media (max-width: 1100px) {
    .map-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1050px) {
    .workspace-layout {
        grid-template-columns: 1fr;
    }
}

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

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .list-row,
    .space-row,
    .opening-row {
        flex-direction: column;
        align-items: stretch;
    }
}
