/* ── Calendar (Phase A) ─────────────────────────────────────────── */
.cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}
.cal-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.cal-title {
    font-size: 18px;
    font-weight: 700;
    min-width: 160px;
    text-align: center;
    color: var(--text);
}
.cal-view-tabs {
    display: flex;
    gap: 4px;
    background: var(--card-bg, #1f2937);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 3px;
}
.cal-view-tab {
    padding: 6px 12px;
    border: 0;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.cal-view-tab.active {
    background: var(--accent, #6366f1);
    color: #fff;
}
.cal-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
    align-items: center;
}
.cal-filters select,
.cal-filters input {
    height: 32px;
    padding: 4px 8px;
    font-size: 12px;
    width: auto;
    min-width: 0;
    max-width: 160px;
    flex: 0 0 auto;
}
.cal-filters select { width: 140px; }
.cal-filters input  { width: 130px; }

/* Month grid */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    background: var(--border, #334155);
    border: 1px solid var(--border, #334155);
    border-radius: 10px;
    overflow: hidden;
    gap: 1px;
    width: 100%;
    box-sizing: border-box;
}
.cal-dow {
    background: var(--card-bg, #1f2937);
    color: var(--text-muted, #94a3b8);
    text-align: center;
    padding: 8px 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.cal-dow.weekend { color: var(--accent2, #f59e0b); }

.cal-cell {
    background: var(--bg, #0f172a);
    min-height: 110px;
    padding: 4px 6px 6px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cal-cell.other-month {
    background: var(--card-bg, #1f2937);
    opacity: .55;
}
.cal-cell.today .cal-day-num {
    background: var(--accent, #6366f1);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cal-day-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    align-self: flex-start;
    margin-bottom: 2px;
}

.cal-event {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--accent, #6366f1);
    color: #fff;
    border: 0;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.cal-event:hover { filter: brightness(1.15); }
.cal-event.st-pending   { background: #f59e0b; color: #1f2937; }
.cal-event.st-confirmed { background: #10b981; }
.cal-event.st-completed { background: #64748b; }
.cal-event.st-cancelled { background: #ef4444; }
.cal-event.continuation { border-left: 3px dashed rgba(255,255,255,.7); padding-left: 4px; }
.cal-event.starts       { border-radius: 4px 0 0 4px; }
.cal-event.ends         { border-radius: 0 4px 4px 0; }

/* ── Phase C: Drag & Resize ─────────────────────────────────────── */
.cal-event[draggable="true"] { cursor: grab; }
.cal-event.dragging {
    opacity: .45;
    cursor: grabbing;
    outline: 2px dashed #fff;
}
.cal-event .cal-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
    background: rgba(255,255,255,.25);
    border-radius: 0 4px 4px 0;
    opacity: 0;
    transition: opacity .12s;
}
.cal-event { position: relative; padding-right: 8px; }
.cal-event:hover .cal-resize-handle { opacity: 1; }
.cal-event.st-pending .cal-resize-handle { background: rgba(0,0,0,.18); }

.cal-cell.drop-target {
    outline: 2px dashed var(--accent, #6366f1);
    outline-offset: -2px;
    background: rgba(99,102,241,.08);
}
.cal-cell.drop-invalid {
    outline: 2px dashed #ef4444;
    background: rgba(239,68,68,.06);
}

/* Resize ghost overlay */
.cal-resize-ghost {
    position: fixed;
    z-index: 999;
    pointer-events: none;
    background: rgba(99,102,241,.18);
    border: 2px dashed var(--accent, #6366f1);
    border-radius: 4px;
}

/* Confirm modal */
.cal-confirm-mask {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
}
.cal-confirm-box {
    background: var(--card-bg, #1f2937);
    border: 1px solid var(--border, #334155);
    border-radius: 12px;
    padding: 20px 22px;
    min-width: 360px;
    max-width: 520px;
    color: var(--text);
}
.cal-confirm-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.cal-confirm-msg {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
    line-height: 1.5;
}
.cal-confirm-conflicts {
    background: rgba(239,68,68,.08);
    border: 1px solid rgba(239,68,68,.3);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 14px;
    max-height: 200px;
    overflow-y: auto;
}
.cal-confirm-conflicts-head {
    font-size: 13px;
    font-weight: 700;
    color: #ef4444;
    margin-bottom: 6px;
}
.cal-confirm-conflicts-item {
    font-size: 12px;
    padding: 4px 0;
    border-top: 1px dashed rgba(239,68,68,.2);
}
.cal-confirm-conflicts-item:first-child { border-top: 0; }
.cal-confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.cal-more {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent, #6366f1);
    cursor: pointer;
    background: none;
    border: 0;
    text-align: left;
    padding: 0 4px;
}
.cal-more:hover { text-decoration: underline; }

/* Agenda view */
.cal-agenda {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.cal-agenda-day {
    background: var(--card-bg, #1f2937);
    border: 1px solid var(--border, #334155);
    border-radius: 10px;
    padding: 12px 14px;
}
.cal-agenda-day-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border, #334155);
}
.cal-agenda-date {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent, #6366f1);
}
.cal-agenda-dow {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
}
.cal-agenda-event {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    gap: 12px;
    padding: 8px 6px;
    border-radius: 6px;
    cursor: pointer;
    align-items: center;
}
.cal-agenda-event:hover { background: rgba(99,102,241,.08); }
.cal-agenda-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}
.cal-agenda-title { font-size: 13px; font-weight: 600; color: var(--text); }
.cal-agenda-meta  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Legend */
.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}
.cal-legend-item { display: flex; align-items: center; gap: 6px; }
.cal-legend-swatch {
    width: 14px; height: 14px; border-radius: 3px;
    display: inline-block;
}

/* Day popover (more) */
.cal-popover {
    position: fixed;
    z-index: 1000;
    background: var(--card-bg, #1f2937);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 10px;
    min-width: 240px;
    max-width: 320px;
    box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.cal-popover-head {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border, #334155);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cal-popover-close {
    background: none; border: 0; color: var(--text-muted);
    cursor: pointer; font-size: 16px; line-height: 1;
}
.cal-popover .cal-event { margin-bottom: 4px; white-space: normal; }

/* Mobile */
@media (max-width: 768px) {
    .cal-cell { min-height: 70px; padding: 2px 3px; }
    .cal-event { font-size: 10px; padding: 1px 4px; }
    .cal-title { font-size: 15px; min-width: 110px; }
    .cal-filters { width: 100%; margin-left: 0; }
    .cal-filters select,
    .cal-filters input { flex: 1 1 0; max-width: none; width: auto; }
}

/* ── Resource view (Phase B) ────────────────────────────────────── */
.cal-res-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-muted);
}
.cal-res-meta .cal-conflict-badge {
    background: rgba(239, 68, 68, .15);
    color: #ef4444;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 700;
    border: 1px solid rgba(239, 68, 68, .35);
}
.cal-res-wrap {
    overflow-x: auto;
    border: 1px solid var(--border, #334155);
    border-radius: 10px;
    background: var(--bg, #0f172a);
}
.cal-res-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    table-layout: fixed;
}
.cal-res-table th,
.cal-res-table td {
    border-right: 1px solid var(--border, #334155);
    border-bottom: 1px solid var(--border, #334155);
    padding: 0;
    height: 38px;
    vertical-align: middle;
    background: var(--bg, #0f172a);
}
.cal-res-table thead th {
    position: sticky;
    top: 0;
    background: var(--card-bg, #1f2937);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    padding: 6px 2px;
    z-index: 2;
}
.cal-res-table thead th.weekend { color: var(--accent2, #f59e0b); }
.cal-res-table thead th.today {
    background: var(--accent, #6366f1);
    color: #fff;
}
.cal-res-name {
    position: sticky;
    left: 0;
    background: var(--card-bg, #1f2937) !important;
    text-align: left;
    padding: 6px 10px !important;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    min-width: 160px;
    max-width: 220px;
    z-index: 1;
    border-right: 2px solid var(--accent, #6366f1) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-res-name.has-conflict {
    color: #ef4444;
}
.cal-res-name .cal-res-count {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 4px;
}
.cal-res-day {
    width: 32px;
    min-width: 32px;
    cursor: default;
    padding: 0 !important;
}
.cal-res-day.today { background: rgba(99,102,241,.08); }
.cal-res-day.weekend { background: rgba(245,158,11,.04); }
.cal-res-day .cal-res-bar {
    width: 100%;
    height: 22px;
    background: var(--accent, #6366f1);
    cursor: pointer;
    border: 0;
    padding: 0;
    display: block;
}
.cal-res-day .cal-res-bar.st-pending   { background: #f59e0b; }
.cal-res-day .cal-res-bar.st-confirmed { background: #10b981; }
.cal-res-day .cal-res-bar.st-completed { background: #64748b; }
.cal-res-day .cal-res-bar.conflict     {
    background-image: linear-gradient(45deg, rgba(0,0,0,.2) 25%, transparent 25%, transparent 50%, rgba(0,0,0,.2) 50%, rgba(0,0,0,.2) 75%, transparent 75%);
    background-size: 8px 8px;
    outline: 2px solid #ef4444;
    outline-offset: -2px;
}
.cal-res-day .cal-res-bar.starts { border-radius: 4px 0 0 4px; margin-left: 2px; }
.cal-res-day .cal-res-bar.ends   { border-radius: 0 4px 4px 0; margin-right: 2px; }
.cal-res-day .cal-res-bar.starts.ends { border-radius: 4px; margin: 0 2px; }
.cal-res-day .cal-res-bar:hover { filter: brightness(1.2); }

