:root {
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --panel: #f8fafc;
    --surface: #ffffff;
    --soft: #eef4fb;
    --weekend: #eef8fb;
    --today: #fff3b0;
    --blue: #2563eb;
    --shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: minmax(188px, 218px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    height: 100vh;
    height: 100svh;
}

.topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 22px;
    border-bottom: 1px solid #e5e9ef;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(12px);
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-row.center {
    justify-content: center;
    gap: 10px;
}

.brand-row h1 {
    margin: 0;
    font-size: 21px;
    letter-spacing: 0;
    white-space: nowrap;
}

.app-symbol {
    position: relative;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--brand);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .24);
    color: transparent;
    font-size: 0;
}

.app-symbol::before {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    top: 9px;
    height: 4px;
    border-radius: 4px;
    background: #fff;
}

input[type="color"] {
    min-width: 52px;
    min-height: 40px;
    padding: 3px;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 0;
    border-radius: 6px;
}

input[type="color"]::-moz-color-swatch {
    border: 0;
    border-radius: 6px;
}

.app-symbol::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    height: 17px;
    border-radius: 4px;
    background:
        linear-gradient(#dbeafe 0 0) 0 0 / 5px 5px,
        linear-gradient(#dbeafe 0 0) 9px 0 / 5px 5px,
        linear-gradient(#dbeafe 0 0) 18px 0 / 5px 5px,
        linear-gradient(#dbeafe 0 0) 0 9px / 5px 5px,
        linear-gradient(#dbeafe 0 0) 9px 9px / 5px 5px,
        linear-gradient(#dbeafe 0 0) 18px 9px / 5px 5px;
    background-repeat: no-repeat;
}

.app-symbol.large {
    width: 54px;
    height: 54px;
    margin: 0 auto 12px;
}

.brand-row .app-symbol.large {
    width: 44px;
    height: 44px;
    margin: 0;
}

.top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

.role-pill {
    color: var(--ink);
    font-size: 14px;
}

.text-link {
    color: #0f172a;
    text-decoration: none;
    font-size: 14px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    color: #64748b;
    background: #eef2f6;
    text-decoration: none;
    cursor: pointer;
}

.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: auto;
    border-right: 1px solid #e5e9ef;
    background: rgba(248, 250, 252, .92);
    padding: 8px;
}

.workspace {
    position: relative;
    min-width: 0;
    overflow: hidden;
    background: transparent;
    padding: 8px;
}

#calendar {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--shadow);
}

.side-title button {
    border: 0;
    background: transparent;
    color: #7b8798;
    cursor: pointer;
    font-size: 18px;
}

.side-section {
    margin-top: 8px;
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 12px;
    padding: 7px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .05);
}

.sidebar > .side-section:first-child {
    margin-top: 0;
}

.side-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
    padding: 0 3px;
    font-size: 14px;
}

.calendar-title-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.calendar-title-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 6px;
    color: #64748b;
}

.calendar-title-actions button:hover {
    color: #1d4ed8;
    background: #eff6ff;
}

.calendar-title-actions svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.calendar-group {
    margin-bottom: 4px;
}

.calendar-group-title {
    display: flex;
    align-items: center;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    color: #334155;
    background: #edf2f7;
    font-size: 11px;
    font-weight: 700;
}

.calendar-group-title::before {
    content: "";
    width: 0;
    height: 0;
    margin-right: 5px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 6px solid #94a3b8;
}

.calendar-item {
    display: flex;
    align-items: center;
    width: calc(100% - 12px);
    min-height: 22px;
    margin: 3px 0 3px 12px;
    border: 0;
    border-radius: 8px;
    padding: 3px 7px;
    color: #fff;
    background: var(--calendar-color);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
    transition: opacity .16s ease, filter .16s ease, transform .16s ease, box-shadow .16s ease;
}

.calendar-item:hover {
    filter: brightness(.96);
    transform: translateX(1px);
}

.calendar-item:not(.is-active) {
    opacity: .46;
    filter: saturate(.55) brightness(1.12);
    box-shadow: none;
}

.link-button {
    width: 100%;
    margin-top: 8px;
    border: 1px solid #dbeafe;
    border-radius: 10px;
    padding: 7px 8px;
    color: #1d4ed8;
    background: #eff6ff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
}

.link-button[hidden] {
    display: none;
}

.search-input {
    width: 100%;
    height: 32px;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 0 9px;
    color: #334155;
    background: #eef2f6;
    font-size: 13px;
}

.search-input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, .12);
}

.filter-control {
    position: relative;
    margin-top: 4px;
}

.filter-select-button {
    display: flex;
    align-items: center;
    width: 100%;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 0 9px;
    color: #64748b;
    background: #eef2f6;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.filter-select-button > span {
    min-width: 0;
}

.filter-select-button > span:not(.filter-selected-values) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-select-button.has-selections {
    height: auto;
    min-height: 30px;
    align-items: flex-start;
    padding: 4px 5px;
}

.filter-select-button.has-selections::after {
    margin-top: 8px;
}

.filter-selected-values {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 3px;
}

.calendar-filter-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    min-height: 22px;
    border-radius: 6px;
    padding: 3px 5px;
    color: #fff;
    background: var(--calendar-color);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
}

.calendar-filter-chip b {
    flex: 0 0 auto;
    font-size: 14px;
    font-weight: 400;
    line-height: 1;
}

.calendar-filter-chip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-select-button::after {
    content: "";
    flex: 0 0 auto;
    margin-left: auto;
    border-right: 5px solid transparent;
    border-left: 5px solid transparent;
    border-top: 6px solid #94a3b8;
    transition: transform .15s ease;
}

.filter-select-button.is-open {
    border-color: #3b82f6;
    color: #334155;
    background: #fff;
}

.filter-select-button.is-open::after {
    transform: rotate(180deg);
}

.filter-picker {
    display: none;
    gap: 3px;
    max-height: 216px;
    overflow: auto;
    margin-top: 3px;
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    padding: 4px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .14);
}

.filter-picker.is-open {
    display: grid;
}

.filter-quick-actions {
    display: flex;
    justify-content: flex-end;
    min-height: 26px;
    padding: 5px 1px 0;
}

.clear-all-filters-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 999px;
    padding: 0;
    color: #dc2626;
    background: transparent;
    cursor: pointer;
}

.clear-all-filters-button:hover {
    color: #fff;
    background: #dc2626;
}

.clear-all-filters-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.calendar-filter-choice,
.status-filter-choice {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 24px;
    border-radius: 6px;
    padding: 3px 6px;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.1;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.calendar-filter-choice {
    border: 0;
    color: #fff;
    background: var(--calendar-color);
    font-weight: 600;
}

.calendar-filter-choice:not(.is-active) {
    opacity: .8;
    filter: saturate(.82);
}

.calendar-filter-choice.is-active {
    opacity: 1;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .75);
}

.status-filter-choice {
    gap: 6px;
    border: 1px solid var(--status-color, #94a3b8);
    color: var(--status-color, #64748b);
    background: #fff;
}

.status-filter-choice span {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    color: #fff;
    background: var(--status-color, #94a3b8);
    font-size: 9px;
}

.status-filter-choice.is-active {
    color: #0f172a;
    background: color-mix(in srgb, var(--status-color, #94a3b8) 13%, #fff);
}

.status-filter-choice:not(.is-active) {
    opacity: .72;
}

.sidebar-footer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding: 10px 3px 2px;
    background: inherit;
}

.sidebar-footer-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    color: #64748b;
    background: #fff;
    text-decoration: none;
}

.sidebar-footer-button:hover {
    color: #1d4ed8;
    border-color: #bfdbfe;
    background: #eff6ff;
}

.sidebar-footer-button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.month-picker-popover {
    position: absolute;
    z-index: 18;
    display: none;
    width: 224px;
    transform: translateX(-50%);
    border: 1px solid #dbe4ee;
    border-radius: 10px;
    padding: 10px;
    background: #fff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .2);
}

.month-picker-popover.is-open {
    display: block;
}

.month-picker-head {
    display: grid;
    grid-template-columns: 28px 1fr 28px;
    align-items: center;
    margin-bottom: 8px;
}

.month-picker-head strong {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
}

.month-picker-head button {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 6px;
    color: #64748b;
    background: transparent;
    cursor: pointer;
}

.month-picker-head button:hover {
    color: #1d4ed8;
    background: #eff6ff;
}

.month-picker-weekdays,
.month-picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
}

.month-picker-weekdays {
    margin-bottom: 3px;
    color: #475569;
    font-size: 10px;
}

.month-picker-day {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin: 1px auto;
    border: 0;
    border-radius: 999px;
    color: #334155;
    background: transparent;
    font-size: 11px;
    cursor: pointer;
}

.month-picker-day:hover {
    color: #1d4ed8;
    background: #dbeafe;
}

.month-picker-day.is-other {
    color: #a3afbf;
}

.month-picker-day.is-today {
    color: #fff;
    background: #2563eb;
    font-weight: 700;
}

.month-picker-day.is-selected:not(.is-today) {
    color: #1d4ed8;
    background: #dbeafe;
    font-weight: 700;
}

.fc {
    --fc-border-color: #d9d9d9;
    --fc-today-bg-color: var(--today);
    --fc-small-font-size: 12px;
    font-family: Arial, Helvetica, sans-serif;
}

.fc .fc-toolbar.fc-header-toolbar {
    min-height: 44px;
    height: auto;
    margin: 0;
    padding: 5px 10px;
    border-bottom: 1px solid #e7ebf1;
    gap: 8px;
    flex-wrap: wrap;
}

.fc .fc-button-primary {
    border-color: #dbe4ee;
    border-radius: 10px;
    color: #334155;
    background: #fff;
}

.fc .fc-button {
    padding: 5px 9px;
    font-size: 13px;
    line-height: 1.2;
}

.fc .fc-button-primary:hover,
.fc .fc-button-primary:not(:disabled).fc-button-active {
    border-color: #dbe4ee;
    color: #111827;
    background: #eef2f7;
}

.fc .fc-toolbar-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 7px;
    padding: 4px 7px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.fc .fc-toolbar-title::after {
    content: "";
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
    border-top: 5px solid #94a3b8;
}

.fc .fc-toolbar-title:hover,
.fc .fc-toolbar-title:focus-visible {
    outline: none;
    background: #f1f5f9;
}

.fc .fc-col-header-cell {
    height: 22px;
    font-size: 12px;
    font-weight: 400;
    background: #fff;
}

.fc .fc-day-sat,
.fc .fc-day-sun {
    background: var(--weekend);
}

.fc .fc-dayGridMonth-view .fc-daygrid-day.fc-day-other {
    background: #f3f4f6;
}

.fc .fc-dayGridMonth-view .fc-daygrid-day.fc-day-other .fc-daygrid-day-number {
    color: #94a3b8;
}

.fc .fc-daygrid-day-number {
    color: #0f172a;
    font-size: 14px;
}

.fc .fc-event {
    border: 0;
    border-radius: 5px;
    padding: 1px 4px;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    overflow: hidden;
}

.fc .calendar-colored-event,
.fc .calendar-colored-event .fc-event-main {
    color: #fff;
}

.event-content {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.event-color-stack {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 1px;
    overflow: hidden;
    max-width: 36px;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .32);
}

.event-color-stack span {
    width: 8px;
    height: 10px;
}

.event-status-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-width: 15px;
    height: 15px;
    border-radius: 999px;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
}

.event-time,
.event-title {
    min-width: 0;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-time {
    flex: 0 0 auto;
    font-weight: 600;
}

.event-title {
    flex: 1 1 auto;
    font-weight: 400;
}

.fc .multi-calendar-event {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
    text-shadow: 0 1px 2px rgba(15, 23, 42, .5);
}

.fc .fc-daygrid-event-harness {
    margin-top: 1px;
}

.fc .fc-daygrid-event {
    max-width: 100%;
    min-height: 17px;
    line-height: 15px;
    white-space: nowrap;
}

.fc .fc-daygrid-day.is-density-compact .fc-daygrid-event {
    min-height: 16px;
    padding: 1px 3px;
    font-size: 11.5px;
    line-height: 14px;
}

.fc .fc-daygrid-day.is-density-dense .fc-daygrid-event {
    min-height: 14px;
    margin-top: 0;
    padding: 0 2px;
    font-size: 10.5px;
    line-height: 12.5px;
}

.fc .fc-daygrid-day.is-density-ultra .fc-daygrid-event {
    min-height: 13px;
    margin-top: 0;
    padding: 0 2px;
    font-size: 9.5px;
    line-height: 11.5px;
}

.fc .fc-daygrid-day.is-density-dense .event-content,
.fc .fc-daygrid-day.is-density-ultra .event-content {
    gap: 2px;
}

.fc .fc-daygrid-day.is-density-dense .event-status-icon,
.fc .fc-daygrid-day.is-density-ultra .event-status-icon {
    min-width: 12px;
    height: 12px;
    font-size: 9px;
}

.fc .fc-daygrid-day.is-density-dense .event-color-stack,
.fc .fc-daygrid-day.is-density-ultra .event-color-stack {
    height: 8px;
}

.fc .fc-daygrid-block-event .fc-event-main {
    min-width: 0;
}

.fc .fc-event-title,
.fc .fc-event-time {
    overflow: hidden;
    text-overflow: ellipsis;
}

.fc .fc-daygrid-more-link {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    height: 18px;
    padding: 0 5px;
    border-radius: 5px;
    color: #0f172a;
    background: #e2e8f0;
    font-size: 12px;
    font-weight: 700;
}

.fc .fc-daygrid-day-frame {
    min-height: 112px;
}

.fc .fc-eightWeeks-view .fc-daygrid-day-frame {
    min-height: 0;
}

.fc .fc-multimonth .fc-daygrid-day-frame {
    min-height: 28px;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(8px);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 30;
    max-width: min(420px, calc(100vw - 36px));
    transform: translateY(16px);
    opacity: 0;
    pointer-events: none;
    border-radius: 9px;
    padding: 11px 14px;
    color: #0f172a;
    background: #e2e8f0;
    box-shadow: 0 16px 45px rgba(15, 23, 42, .18);
    transition: opacity .18s ease, transform .18s ease;
    font-size: 14px;
    font-weight: 700;
}

.toast.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.toast.error {
    color: #7f1d1d;
    background: #fee2e2;
}

.toast.success {
    color: #065f46;
    background: #d1fae5;
}

.modal.is-open {
    display: flex;
}

.modal-panel {
    width: min(680px, 100%);
    max-height: 92vh;
    overflow: auto;
    border: 1px solid rgba(226, 232, 240, .85);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 28px 90px rgba(15, 23, 42, .26);
}

.calendar-manager-panel {
    width: min(1080px, 100%);
}

.modal-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.calendar-manager {
    display: grid;
    gap: 14px;
    padding: 18px;
}

.calendar-create-form {
    display: grid;
    grid-template-columns: minmax(180px, 1.3fr) minmax(150px, .9fr) minmax(142px, .65fr) minmax(132px, auto) auto;
    align-items: end;
    gap: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 14px;
    background: #f8fafc;
}

.calendar-manager-list {
    display: grid;
    gap: 8px;
}

.calendar-manager-row {
    display: grid;
    grid-template-columns: minmax(170px, 1.2fr) minmax(140px, .85fr) minmax(142px, .65fr) minmax(120px, auto) minmax(96px, auto) auto;
    align-items: center;
    gap: 10px;
    border: 1px solid #e5e9ef;
    border-radius: 14px;
    padding: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}

.calendar-color-picker {
    position: relative;
    display: block;
}

.calendar-color-button {
    display: grid;
    grid-template-columns: 34px minmax(72px, 1fr);
    align-items: center;
    gap: 9px;
    width: 100%;
    min-height: 40px;
    padding: 4px 9px 4px 4px;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    color: #334155;
    background: #fff;
    cursor: pointer;
}

.calendar-color-button:hover,
.calendar-color-button:focus-visible {
    border-color: #2563eb;
    outline: 2px solid rgba(37, 99, 235, .13);
}

.calendar-color-preview {
    width: 32px;
    height: 28px;
    border: 1px solid rgba(15, 23, 42, .14);
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}

.calendar-color-native {
    position: absolute;
    width: 1px !important;
    height: 1px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    opacity: 0;
    pointer-events: none;
}

.calendar-color-value {
    min-width: 0;
    overflow: hidden;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.calendar-manager-row.is-disabled {
    opacity: .58;
    background: #f8fafc;
}

.field-control {
    display: grid;
    gap: 6px;
}

.field-control small {
    max-width: 170px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.25;
}

.field-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
}

.field-label {
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.state-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid #dbe4ee;
    border-radius: 999px;
    padding: 8px 12px;
    color: #475569;
    background: #f8fafc;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease;
}

.state-toggle:hover {
    transform: translateY(-1px);
}

.state-toggle.is-on {
    border-color: #bfdbfe;
    color: #1d4ed8;
    background: #eff6ff;
}

.state-toggle.is-off {
    color: #64748b;
    background: #f1f5f9;
}

.mini-check {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
}

.mini-check input {
    width: 16px;
    height: 16px;
}

.empty-state {
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 18px;
    color: var(--muted);
    text-align: center;
}

.modal-head,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid #e5e9ef;
}

.modal-actions {
    justify-content: flex-end;
    border-top: 1px solid #e5e9ef;
    border-bottom: 0;
}

.modal-head h2 {
    margin: 0;
    font-size: 20px;
}

.event-form {
    display: grid;
    gap: 14px;
    padding: 18px;
}

.event-calendar-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 130px;
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 9px;
    background: #f8fafc;
}

.event-calendar-choice {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    border: 1px solid #dbe4ee;
    border-radius: 999px;
    padding: 7px 11px;
    color: #475569;
    background: rgba(255, 255, 255, .72);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease, opacity .16s ease;
}

.event-calendar-choice span {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--calendar-color);
}

.event-calendar-choice:hover {
    transform: translateY(-1px);
    border-color: #bfdbfe;
}

.event-calendar-choice.is-active {
    border-color: color-mix(in srgb, var(--calendar-color) 72%, #ffffff);
    color: #0f172a;
    background: color-mix(in srgb, var(--calendar-color) 18%, #ffffff);
}

.event-status-picker {
    display: none;
    gap: 6px;
    max-height: 146px;
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 9px;
    background: #f8fafc;
}

.event-status-picker.is-open {
    display: grid;
}

.status-select-button {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    padding: 8px 10px;
    color: #334155;
    background: #fff;
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

.status-select-button::after {
    content: "⌄";
    margin-left: auto;
    color: #94a3b8;
}

.status-select-button span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    border-radius: 999px;
    color: #fff;
    background: var(--status-color);
    font-size: 10px;
    font-weight: 700;
}

.event-status-choice {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    border: 1px solid var(--status-color);
    border-radius: 8px;
    padding: 4px 8px;
    color: var(--status-color);
    background: #fff;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
}

.event-status-choice span,
.status-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    color: #fff;
    background: var(--status-color);
    font-size: 10px;
    font-weight: 700;
}

.event-status-choice.is-active {
    color: #0f172a;
    background: color-mix(in srgb, var(--status-color) 14%, #ffffff);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--status-color) 15%, transparent);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

label {
    display: grid;
    gap: 6px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    padding: 9px 10px;
    color: #111827;
    background: #fff;
}

select[multiple] {
    min-height: 104px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-row input {
    width: auto;
}

.color-field {
    align-content: start;
}

.color-control {
    display: grid;
    grid-template-columns: 18px 1fr;
    align-items: center;
    gap: 8px;
}

.color-control input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.color-control input[type="color"] {
    min-height: 38px;
    padding: 4px;
}

.color-control input[type="color"]:disabled {
    opacity: .45;
}

.primary-button,
.secondary-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.primary-button {
    color: #fff;
    background: var(--brand);
}

.secondary-button {
    color: #334155;
    background: #e2e8f0;
}

.danger-button {
    margin-right: auto;
    color: #fff;
    background: #b91c1c;
}

.danger-button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.compact-button {
    min-height: 30px;
    padding: 6px 10px;
    font-size: 12px;
}

.admin-entry-button {
    min-height: 34px;
    padding: 8px 12px;
    white-space: nowrap;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: #f5f7fb;
}

.auth-card {
    width: min(440px, 100%);
    border-radius: 12px;
    padding: 30px;
    background: #fff;
    box-shadow: 0 18px 60px rgba(15, 23, 42, .12);
}

.auth-card h1 {
    margin: 0 0 8px;
    text-align: center;
}

.auth-card p {
    margin: 0 0 20px;
    text-align: center;
    color: var(--muted);
}

.stack {
    display: grid;
    gap: 14px;
}

.alert {
    margin: 0 0 16px;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
}

.alert.success {
    color: #065f46;
    background: #d1fae5;
}

.alert.error {
    color: #991b1b;
    background: #fee2e2;
}

.muted-link {
    display: block;
    margin-top: 16px;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
}

.admin-page {
    min-height: 100vh;
    background: #f5f7fb;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 22px;
    border-bottom: 1px solid #e5e9ef;
    background: #fff;
}

.admin-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.admin-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 18px;
}

.admin-page-tabs {
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    gap: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 5px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
    overflow-x: auto;
}

.admin-page-tabs .admin-tab {
    border-radius: 9px;
    padding: 9px 14px;
}

.full-span {
    grid-column: 1 / -1;
}

.admin-panel {
    border-radius: 10px;
    padding: 20px;
    background: #fff;
    box-shadow: 0 10px 35px rgba(15, 23, 42, .08);
}

.admin-panel h1 {
    margin: 0 0 16px;
    font-size: 22px;
}

.admin-page-panel {
    display: none;
}

.admin-page-panel.is-active {
    display: block;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.panel-heading h1 {
    margin-bottom: 5px;
}

.panel-heading p {
    max-width: 720px;
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    border-bottom: 1px solid #e5e9ef;
    padding: 10px;
    text-align: left;
}

th {
    color: #475569;
    background: #f8fafc;
}

.log-action {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 2px 8px;
    color: #1d4ed8;
    background: #dbeafe;
    font-size: 12px;
    font-weight: 800;
}

.admin-tools-panel {
    width: min(1040px, 100%);
}

.user-modal-panel {
    width: min(620px, 100%);
}

.admin-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 18px 0;
    border-bottom: 1px solid #e5e9ef;
    background: #fff;
}

.admin-tab {
    border: 0;
    border-radius: 9px 9px 0 0;
    padding: 10px 14px;
    color: #64748b;
    background: transparent;
    font-weight: 800;
    cursor: pointer;
}

.admin-tab:hover {
    color: #0f172a;
    background: #f1f5f9;
}

.admin-tab.is-active {
    color: #1d4ed8;
    background: #eff6ff;
}

.admin-tools-content {
    padding: 18px;
}

.admin-tab-panel {
    display: none;
}

.admin-tab-panel.is-active {
    display: block;
}

.admin-log-wrap {
    max-height: min(58vh, 560px);
    border: 1px solid #e5e9ef;
    border-radius: 10px;
}

.admin-log-wrap table {
    min-width: 860px;
}

.admin-install-frame {
    width: 100%;
    min-height: 620px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #f8fafc;
}

.status-admin-form,
.status-admin-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(150px, .7fr) 78px minmax(90px, auto) auto;
    align-items: end;
    gap: 10px;
}

.status-admin-form {
    margin-bottom: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    background: #f8fafc;
}

.status-admin-list {
    display: grid;
    gap: 8px;
}

.status-admin-row {
    grid-template-columns: 34px minmax(220px, 1fr) minmax(150px, .6fr) 74px minmax(90px, auto) auto;
    border: 1px solid #e5e9ef;
    border-radius: 12px;
    padding: 10px;
    background: #fff;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        height: auto;
        min-height: 100svh;
    }

    .topbar {
        align-items: flex-start;
        gap: 10px;
        padding: 10px 12px;
        flex-wrap: wrap;
    }

    .brand-row {
        gap: 9px;
    }

    .brand-row h1 {
        font-size: 19px;
    }

    .app-symbol {
        width: 38px;
        height: 38px;
        border-radius: 11px;
    }

    .top-actions {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .sidebar {
        display: grid;
        grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
        gap: 12px;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid #e5e9ef;
        padding: 10px 12px;
    }

    .sidebar-footer {
        grid-column: 1 / -1;
        margin-top: 0;
        padding-top: 0;
    }

    .side-section {
        margin-top: 0;
        min-width: 0;
    }

    .calendar-list {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding: 2px 0 6px;
        scroll-snap-type: x proximity;
    }

    .calendar-group {
        flex: 0 0 min(210px, 70vw);
        scroll-snap-align: start;
    }

    .calendar-item {
        width: calc(100% - 10px);
        margin-left: 10px;
    }

    #calendar {
        height: calc(100svh - 320px);
        min-height: 560px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .admin-layout {
        grid-template-columns: 1fr;
        width: 100%;
        padding: 14px;
    }

    .calendar-create-form,
    .calendar-manager-row,
    .status-admin-form,
    .status-admin-row {
        grid-template-columns: 1fr 1fr;
    }

    .calendar-create-form .primary-button,
    .calendar-manager-row .secondary-button,
    .status-admin-form .primary-button,
    .status-admin-row .secondary-button {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    .role-pill {
        display: none;
    }

    .admin-header {
        align-items: flex-start;
        padding: 12px;
        flex-wrap: wrap;
    }

    .admin-header-actions {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
    }

    .admin-panel {
        padding: 14px;
    }

    .panel-heading {
        display: grid;
        gap: 12px;
    }

    .panel-heading .primary-button {
        width: 100%;
    }

    .admin-tabs {
        overflow-x: auto;
        padding-inline: 12px;
    }

    .admin-tab {
        white-space: nowrap;
    }

    .admin-tools-content {
        padding: 14px;
    }

    .sidebar {
        grid-template-columns: 1fr;
    }

    .side-title {
        margin-bottom: 7px;
        font-size: 16px;
    }

    .fc .fc-toolbar.fc-header-toolbar {
        align-items: stretch;
    }

    .fc .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 4px;
        width: 100%;
    }

    .fc .fc-toolbar-title {
        width: 100%;
        justify-content: center;
        text-align: center;
        font-size: 16px;
    }

    #calendar {
        height: calc(100svh - 220px);
        min-height: 520px;
    }

    .modal {
        padding: 10px;
        align-items: flex-end;
    }

    .modal-panel {
        width: 100%;
        max-height: 94svh;
        border-radius: 12px 12px 0 0;
    }

    .calendar-create-form,
    .calendar-manager-row,
    .status-admin-form,
    .status-admin-row {
        grid-template-columns: 1fr;
    }

    .modal-actions {
        flex-wrap: wrap;
    }

    .danger-button {
        width: 100%;
        margin-right: 0;
    }
}

/* Ajustes da visao 8 semanas: tudo compacto e sem rolagem interna */
body.is-eight-weeks-view .workspace {
    padding-top: 6px;
    padding-bottom: 6px;
}

body.is-eight-weeks-view #calendar {
    height: 100%;
    min-height: 0;
}

body.is-eight-weeks-view .fc .fc-toolbar {
    margin-bottom: 3px;
}

body.is-eight-weeks-view .fc .fc-toolbar-title {
    font-size: 17px;
}

body.is-eight-weeks-view .fc .fc-view-harness,
body.is-eight-weeks-view .fc .fc-scroller,
body.is-eight-weeks-view .fc .fc-scroller-liquid-absolute {
    overflow: hidden !important;
}

body.is-eight-weeks-view .fc .fc-col-header-cell-cushion {
    padding: 1px 3px;
    font-size: 10px;
}

body.is-eight-weeks-view .fc .fc-daygrid-day-number,
body.is-eight-weeks-view .fc .fc-daygrid-week-number {
    padding: 1px 3px;
    font-size: 20px;
}

body.is-eight-weeks-view .fc .fc-daygrid-day-frame {
    min-height: 0;
    padding: 0;
}

body.is-eight-weeks-view .fc .fc-daygrid-day-top {
    min-height: 14px;
}

body.is-eight-weeks-view .fc .fc-daygrid-day-events {
    margin-top: 0;
    margin-bottom: 0;
}

body.is-eight-weeks-view .fc .fc-daygrid-event {
    min-height: 24px;
    margin-top: 2px;
    margin-bottom: 2px;
    font-size: 20px;
    line-height: 22px;
    border-width: 1px;
}

body.is-eight-weeks-view .event-content {
    gap: 2px;
    padding: 0 2px;
    min-height: 22px;
}

body.is-eight-weeks-view .event-title,
body.is-eight-weeks-view .event-time {
    font-size: 20px;
    line-height: 22px;
}

body.is-eight-weeks-view .event-color-stack,
body.is-eight-weeks-view .event-status-icon {
    display: none;
}

body.is-eight-weeks-view .fc .fc-daygrid-more-link {
    font-size: 9px;
    padding: 0 2px;
}

/* Situacao opcional: dropdown sobreposto ao formulario */
.status-field {
    position: relative;
}

.event-status-picker {
    position: absolute;
    z-index: 60;
    left: 0;
    right: 0;
    top: 56px;
    box-shadow: 0 18px 36px rgba(15, 23, 42, .16);
}

.event-status-choice.is-empty {
    --status-color: #94a3b8;
    border-color: #cbd5e1;
    color: #64748b;
}

.event-status-choice.is-empty span,
.status-select-button:not(:has(span)) {
    color: #64748b;
}

@media (max-width: 760px) {
    body.is-eight-weeks-view #calendar {
        height: 100%;
    }
}
