/* === Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #F8F7F5;
    color: #1a1a1a;
    font-size: 14px;
    line-height: 1.5;
}

/* === Layout === */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 20px; background: #fff; border-bottom: 1px solid #e5e5e5;
    position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-logo { font-weight: 700; font-size: 16px; color: #2B4C7E; cursor: pointer; }
.topbar-nav { display: flex; gap: 4px; }
.topbar-nav button {
    padding: 5px 12px; border-radius: 6px; border: none; background: transparent;
    font-family: inherit; font-size: 13px; color: #666; cursor: pointer; font-weight: 500;
    transition: all 0.15s;
}
.topbar-nav button:hover { background: #f0f0f0; }
.topbar-nav button.active { background: #2B4C7E; color: white; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
    width: 32px; height: 32px; border-radius: 6px; border: 1px solid #ddd;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: #666; cursor: pointer; background: transparent;
    font-family: inherit; transition: all 0.15s;
}
.topbar-btn:hover { background: #f0f0f0; border-color: #bbb; }

.main-content { flex: 1; display: flex; overflow: hidden; }
.calendar-area { flex: 1; overflow: auto; padding: 16px; }

/* === Month Navigation === */
.month-nav {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    margin-bottom: 16px;
}
.month-nav h2 { font-size: 18px; font-weight: 600; color: #2B4C7E; min-width: 200px; text-align: center; }
.month-nav button {
    padding: 6px 12px; border-radius: 6px; border: 1px solid #ddd; background: #fff;
    cursor: pointer; font-family: inherit; font-size: 14px; color: #555; transition: all 0.15s;
}
.month-nav button:hover { background: #f0f0f0; border-color: #bbb; }

/* === Month Grid === */
.month-grid { background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid #e5e5e5; }
.month-header-row {
    display: grid; grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid #e5e5e5;
}
.month-header-cell {
    padding: 8px; text-align: center; font-size: 12px; font-weight: 600;
    color: #888; text-transform: uppercase; letter-spacing: 0.5px;
}
.month-body { display: grid; grid-template-columns: repeat(7, 1fr); }
.month-cell {
    min-height: 90px; padding: 4px 6px; border-right: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: background 0.1s;
    position: relative;
}
.month-cell:nth-child(7n) { border-right: none; }
.month-cell:hover { background: #FAFAF8; }
.month-cell.other-month { opacity: 0.35; }
.month-cell.sunday { background: #F3F2F0; }
.month-cell.holiday-bg { background: #F3F2F0; }
.month-cell.today .month-cell-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 6px; color: white;
}
.month-cell-num {
    font-size: 13px; font-weight: 500; display: inline-block;
    margin-bottom: 2px;
}
.month-cell-num.bold { font-weight: 700; }
.month-cell-events { display: flex; flex-direction: column; gap: 2px; }
.month-event-chip {
    font-size: 11px; padding: 1px 6px; border-radius: 3px; color: white;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.month-event-chip:hover { opacity: 0.85; }

/* === Day View === */
.day-header {
    display: flex; align-items: center; gap: 16px; margin-bottom: 16px;
}
.day-header h2 { font-size: 20px; font-weight: 600; color: #2B4C7E; }
.day-header .day-subtitle { font-size: 14px; color: #888; }

.day-timeline { background: #fff; border-radius: 10px; border: 1px solid #e5e5e5; overflow: hidden; }
.day-hour-row {
    display: flex; min-height: 60px; border-bottom: 1px solid #f5f5f5;
}
.day-hour-label {
    width: 60px; padding: 4px 8px; font-size: 12px; color: #aaa; text-align: right;
    flex-shrink: 0; border-right: 1px solid #f0f0f0;
}
.day-hour-content {
    flex: 1; padding: 2px 8px; position: relative; min-height: 60px;
}
.day-event-block {
    padding: 4px 8px; border-radius: 4px; color: white; font-size: 12px;
    margin-bottom: 2px; cursor: pointer;
}
.day-event-block:hover { opacity: 0.85; }
.day-event-title { font-weight: 500; }
.day-event-time { font-size: 11px; opacity: 0.85; }

.day-allday-section {
    padding: 8px 12px; background: #FAFAF8; border-bottom: 1px solid #e5e5e5;
    display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.day-allday-label { font-size: 11px; color: #999; margin-right: 4px; }

/* === Event Form Modal === */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3); z-index: 200;
    display: flex; align-items: center; justify-content: center;
}
.modal {
    background: #fff; border-radius: 12px; width: 560px; max-width: 95vw;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.modal-header {
    padding: 16px 20px; border-bottom: 1px solid #f0f0f0;
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; color: #2B4C7E; }
.modal-close {
    width: 28px; height: 28px; border: none; background: #f0f0f0; border-radius: 6px;
    cursor: pointer; font-size: 16px; color: #888; display: flex; align-items: center;
    justify-content: center; font-family: inherit;
}
.modal-close:hover { background: #e0e0e0; }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px; border-top: 1px solid #f0f0f0;
    display: flex; gap: 8px; justify-content: flex-end;
}

/* === Form Elements === */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: #555; margin-bottom: 4px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px;
    font-family: inherit; font-size: 14px; background: #fff; color: #1a1a1a;
    transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: #2B4C7E;
}
.form-textarea { resize: vertical; min-height: 60px; }
.form-row { display: flex; gap: 12px; }
.form-row > .form-group { flex: 1; }

.btn {
    padding: 8px 18px; border-radius: 6px; font-family: inherit; font-size: 13px;
    font-weight: 500; cursor: pointer; border: none; transition: all 0.15s;
}
.btn-primary { background: #2B4C7E; color: white; }
.btn-primary:hover { background: #234068; }
.btn-secondary { background: #f0f0f0; color: #555; }
.btn-secondary:hover { background: #e0e0e0; }
.btn-danger { background: transparent; color: #EF4444; border: 1px solid #EF4444; }
.btn-danger:hover { background: #FEF2F2; }

/* === Login === */
.login-page {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: #F8F7F5;
}
.login-card {
    background: #fff; border-radius: 12px; padding: 40px; width: 380px; max-width: 95vw;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    text-align: center;
}
.login-card h1 { font-size: 24px; font-weight: 700; color: #2B4C7E; margin-bottom: 8px; }
.login-card p { font-size: 14px; color: #888; margin-bottom: 24px; }
.login-card .form-group { text-align: left; }
.login-error { color: #EF4444; font-size: 13px; margin-bottom: 12px; }

/* === Toast === */
.toast {
    position: fixed; bottom: 24px; right: 24px; background: #1a1a1a; color: white;
    padding: 10px 20px; border-radius: 8px; font-size: 13px; z-index: 300;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* === Category Color Dot === */
.cat-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    margin-right: 6px; vertical-align: middle;
}

/* === Popover === */
.popover {
    position: absolute; background: white; border-radius: 10px; z-index: 150;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
    width: 300px; overflow: hidden;
}
.popover-header { padding: 12px 16px; border-bottom: 1px solid #f0f0f0; display: flex; gap: 10px; }
.popover-cat-bar { width: 4px; border-radius: 2px; align-self: stretch; flex-shrink: 0; }
.popover-title { font-size: 15px; font-weight: 600; }
.popover-subtitle { font-size: 12px; color: #888; margin-top: 2px; }
.popover-body { padding: 10px 16px; }
.popover-row { font-size: 13px; color: #555; margin-bottom: 6px; }
.popover-footer { padding: 8px 16px; border-top: 1px solid #f0f0f0; display: flex; gap: 6px; justify-content: flex-end; }
.popover-btn {
    padding: 4px 12px; border-radius: 5px; font-size: 12px; cursor: pointer; border: none;
    font-family: inherit; font-weight: 500;
}
