:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #64748b;
    --border: #d8dee8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

.page-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.placeholder {
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.placeholder h1 {
    margin: 0 0 12px;
    font-size: 28px;
    line-height: 1.2;
}

.placeholder p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.calendar-header,
.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.calendar-header h1 {
    margin: 0 0 4px;
    font-size: 28px;
    line-height: 1.2;
}

.calendar-header p {
    margin: 0;
    color: var(--muted);
}

.view-switch,
.calendar-toolbar {
    flex-wrap: wrap;
}

.view-switch {
    display: inline-flex;
    flex-wrap: wrap;
    max-width: 100%;
    padding: 3px;
    background: #e8edf4;
    border-radius: 8px;
}

.view-switch a,
.calendar-toolbar a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    color: var(--text);
    text-decoration: none;
    border-radius: 6px;
}

.view-switch a.is-active,
.calendar-toolbar a {
    background: var(--surface);
    border: 1px solid var(--border);
}

.calendar-toolbar a {
    min-width: 112px;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.month-grid__weekday {
    padding: 10px;
    background: #eef2f7;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.month-day {
    min-height: 124px;
    padding: 8px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.month-day:nth-child(7n) {
    border-right: 0;
}

.month-day.is-muted {
    background: #fafbfc;
    color: #94a3b8;
}

.month-day.is-today {
    box-shadow: inset 0 0 0 2px #2563eb;
}

.month-day.is-selected {
    background: #eff6ff;
    box-shadow: inset 0 0 0 2px #1d4ed8;
}

.admin-month-day {
    cursor: pointer;
}

.admin-month-day:hover {
    background: #f8fbff;
}

.month-day__date {
    display: inline-flex;
    color: inherit;
    text-decoration: none;
    border-radius: 999px;
}

.month-day time {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-bottom: 6px;
    font-weight: 700;
}

.month-day__date:hover time {
    background: #dbeafe;
}

.month-day__events {
    display: grid;
    gap: 4px;
}

.event-pill {
    display: block;
    overflow: hidden;
    width: 100%;
    padding: 4px 6px;
    color: var(--event-text);
    background: var(--event-bg);
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.25;
    text-align: left;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-pill.is-cancelled,
.agenda-event.is-cancelled {
    opacity: 0.62;
    text-decoration: line-through;
}

.event-pill.is-hidden {
    opacity: 0.72;
    border: 1px dashed currentColor;
}

.event-pill__status {
    margin-left: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.event-more,
.empty-state {
    color: var(--muted);
    font-size: 13px;
}

.agenda-list {
    display: grid;
    gap: 18px;
}

.agenda-day {
    display: grid;
    gap: 8px;
}

.agenda-day h2 {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
}

.agenda-event {
    display: grid;
    grid-template-columns: 6px 1fr;
    gap: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.agenda-event__marker {
    background: var(--event-bg);
    border-radius: 4px;
}

.agenda-event__meta,
.agenda-event__location {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
}

.agenda-event h3 {
    margin: 0 0 6px;
    font-size: 17px;
}

.agenda-event__title-button {
    padding: 0;
    color: var(--text);
    background: transparent;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-align: left;
}

.agenda-event__title-button:hover {
    text-decoration: underline;
}

.agenda-event p {
    margin: 0;
    line-height: 1.45;
}

.agenda-event__description {
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.agenda-event__description p {
    margin: 0;
}

.service-calendar {
    max-height: 72vh;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgb(15 23 42 / 0.08);
}

.service-admin-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.service-calendar-layout {
    display: grid;
    gap: 16px;
}

.service-admin-card {
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.service-admin-card h2 {
    margin: 0 0 6px;
    font-size: 18px;
}

.service-admin-card p {
    margin: 0 0 14px;
    color: var(--muted);
    line-height: 1.45;
}

.settings-links {
    display: grid;
    gap: 10px;
    margin: 0;
}

.settings-links div {
    display: grid;
    gap: 4px;
}

.settings-links dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.settings-links dd {
    margin: 0;
}

.settings-links code,
.generated-token-card code {
    display: inline-block;
    max-width: 100%;
    padding: 4px 6px;
    overflow-wrap: anywhere;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.token-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.token-actions form {
    margin: 0;
}

.token-actions button {
    min-height: 38px;
    padding: 0 14px;
    color: #ffffff;
    cursor: pointer;
    background: #0f766e;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-weight: 700;
}

.generated-token-card,
.category-preview-card {
    margin-bottom: 16px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.generated-token-card h2,
.category-preview-card p {
    margin: 0 0 10px;
}

.category-preview {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    color: var(--category-text);
    background: var(--category-bg);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.service-table--categories {
    min-width: 760px;
}

.service-table--tokens {
    min-width: 860px;
}

.service-year-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.service-year-form input {
    width: 120px;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

.service-year-form button {
    min-height: 38px;
    padding: 0 14px;
    color: #ffffff;
    cursor: pointer;
    background: #15803d;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-weight: 700;
}

.service-table {
    width: 100%;
    min-width: 1220px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
}

.service-table th,
.service-table td {
    padding: 11px 12px;
    vertical-align: top;
    border-right: 1px solid #dbe4ec;
    border-bottom: 1px solid #dbe4ec;
    line-height: 1.4;
    word-break: break-word;
}

.service-table th:last-child,
.service-table td:last-child {
    border-right: 0;
}

.service-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    color: #173326;
    background: #cfeedd;
    font-weight: 700;
    text-align: left;
    box-shadow: inset 0 -1px 0 #b7d8c5;
}

.service-table tbody tr:nth-child(even) td {
    background: #fbfcfe;
}

.service-table__row--upcoming td,
.service-table__row--upcoming th.service-table__month {
    background: #fff3bf;
}

.service-table__row--upcoming td {
    box-shadow: inset 0 1px 0 #f4d35e, inset 0 -1px 0 #f4d35e;
}

.service-table__row--upcoming td:first-of-type {
    font-weight: 700;
}

.service-table tbody tr:hover td,
.service-table tbody tr:hover th.service-table__month {
    background: #f3f8ff;
}

.service-table__month {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 94px;
    color: #173326;
    background: #e3f5ea;
    font-weight: 700;
    box-shadow: inset -1px 0 0 #dbe4ec;
}

.service-table__empty {
    color: var(--muted);
    text-align: center;
}

.service-table__col-month {
    width: 96px;
}

.service-table__col-date {
    width: 110px;
}

.service-table__col-main {
    width: 140px;
}

.service-table__col-wide {
    width: 170px;
}

.service-table__col-comment {
    width: 240px;
}

.service-table__col-action {
    width: 96px;
}

.service-table--people {
    min-width: 880px;
}

.service-table--duties td[data-label]::before {
    content: none;
}

.capability-pill,
.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    color: #166534;
    background: #dcfce7;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.capability-pill--muted,
.status-pill--muted {
    color: #475569;
    background: #e2e8f0;
}

.service-person-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
}

.table-action {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    color: #ffffff;
    background: #2563eb;
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.admin-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.admin-panel h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.admin-panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.button-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    color: #ffffff;
    background: #2563eb;
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.flash-message,
.form-errors,
.admin-form {
    margin-bottom: 16px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.flash-message {
    color: #166534;
    background: #f0fdf4;
    border-color: #86efac;
}

.form-errors {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

.form-errors h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

.form-errors ul {
    margin: 0;
    padding-left: 20px;
}

.admin-form {
    display: grid;
    gap: 14px;
}

.admin-form label {
    display: grid;
    gap: 6px;
}

.admin-form label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.admin-form input,
.admin-form select,
.admin-form textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

.admin-form textarea {
    resize: vertical;
}

.richtext-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.richtext-toolbar button {
    min-width: 40px;
    min-height: 34px;
    padding: 0 10px;
    color: var(--text);
    cursor: pointer;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-weight: 700;
}

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

.checkbox-line {
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.checkbox-line input {
    width: 18px;
    min-height: 18px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-actions a,
.form-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
}

.form-actions a {
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border);
}

.form-actions button {
    color: #ffffff;
    cursor: pointer;
    background: #2563eb;
    border: 0;
}

.visibility-zone,
.danger-zone {
    margin-bottom: 16px;
    padding: 16px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
}

.visibility-zone h2,
.danger-zone h2 {
    margin: 0 0 6px;
    font-size: 18px;
}

.visibility-zone p,
.danger-zone p {
    margin: 0 0 12px;
    color: #9a3412;
    line-height: 1.45;
}

.visibility-zone__actions,
.danger-zone__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.visibility-zone button,
.danger-zone button {
    min-height: 40px;
    padding: 0 14px;
    color: #ffffff;
    cursor: pointer;
    background: #c2410c;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-weight: 700;
}

.visibility-zone button.visibility-zone__publish {
    background: #15803d;
}

.visibility-zone button.visibility-zone__delete,
.danger-zone button.danger-zone__delete {
    background: #991b1b;
}

.event-dialog {
    width: min(520px, calc(100% - 32px));
    padding: 0;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.event-dialog::backdrop {
    background: rgb(15 23 42 / 0.42);
}

.event-dialog__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border-bottom: 1px solid var(--border);
}

.event-dialog__category {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.event-dialog h2 {
    margin: 0;
    font-size: 22px;
}

.event-dialog__header button {
    width: 32px;
    height: 32px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
}

.event-dialog__details {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 18px 18px 0;
}

.event-dialog__details div {
    display: grid;
    gap: 2px;
}

.event-dialog__details dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.event-dialog__details dd {
    margin: 0;
}

.event-dialog__description {
    margin: 0;
    padding: 18px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.event-dialog__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 18px 18px;
}

.event-dialog__actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    color: #ffffff;
    background: #2563eb;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.event-dialog__actions a:last-child {
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border);
}

.event-dialog__description a,
.agenda-event__description a {
    color: #1d4ed8;
}

@media (max-width: 760px) {
    .page-shell {
        width: min(1120px, calc(100% - 20px));
        padding: 20px 0 28px;
    }

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

    .calendar-header h1 {
        font-size: 24px;
    }

    .calendar-header,
    .calendar-toolbar,
    .admin-panel {
        align-items: flex-start;
        flex-direction: column;
    }

    .view-switch,
    .calendar-toolbar {
        display: flex;
        width: 100%;
    }

    .view-switch a,
    .calendar-toolbar a {
        flex: 0 1 auto;
        min-width: 0;
    }

    .calendar-toolbar {
        align-items: flex-start;
    }

    .calendar-toolbar a {
        min-width: 112px;
    }

    .service-calendar-layout {
        display: flex;
        flex-direction: column;
    }

    .service-calendar {
        order: 1;
    }

    .service-calendar-toolbar {
        order: 2;
        margin-bottom: 0;
    }

    .service-calendar-toolbar a {
        min-height: 34px;
        min-width: auto;
        padding: 0 10px;
        font-size: 14px;
    }

    .service-admin-tools,
    .service-person-grid {
        grid-template-columns: 1fr;
    }

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

    .month-grid {
        display: block;
        border: 0;
        background: transparent;
    }

    .month-grid__weekday {
        display: none;
    }

    .month-day {
        min-height: auto;
        margin-bottom: 8px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 8px;
    }

    .month-day time {
        width: 34px;
        height: 34px;
        margin-bottom: 8px;
        font-size: 15px;
    }

    .event-pill {
        padding: 6px 8px;
        white-space: normal;
    }

    .month-day.is-muted {
        color: #94a3b8;
        background: #f8fafc;
        opacity: 0.8;
    }

    .agenda-list {
        gap: 14px;
    }

    .agenda-day h2 {
        font-size: 14px;
    }

    .agenda-event {
        grid-template-columns: 4px 1fr;
        gap: 10px;
        padding: 12px;
    }

    .agenda-event h3 {
        font-size: 16px;
    }

    .service-calendar {
        max-height: none;
        overflow: visible;
        border: 0;
        box-shadow: none;
        background: transparent;
    }

    .service-table {
        min-width: 0;
        font-size: 12px;
    }

    .service-table th,
    .service-table td {
        padding: 8px;
    }

    .service-table thead th,
    .service-table__month {
        position: static;
        box-shadow: none;
    }

    .service-table--duties {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0;
    }

    .service-table--duties colgroup,
    .service-table--duties thead,
    .service-table--duties .service-table__month {
        display: none;
    }

    .service-table--duties tbody,
    .service-table--duties tr,
    .service-table--duties td {
        display: block;
        width: 100%;
    }

    .service-table--duties tbody {
        display: grid;
        gap: 12px;
    }

    .service-table--duties tr.service-table__row {
        padding: 12px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 8px;
        box-shadow: 0 8px 24px rgb(15 23 42 / 0.06);
    }

    .service-table--duties tr.service-table__row::before {
        display: block;
        margin-bottom: 10px;
        color: #173326;
        content: attr(data-month);
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0;
    }

    .service-table--duties td {
        padding: 7px 0;
        border-right: 0;
        border-bottom: 1px solid #e5e7eb;
    }

    .service-table--duties td:last-child {
        border-bottom: 0;
    }

    .service-table--duties td[data-label] {
        display: grid;
        grid-template-columns: minmax(110px, 120px) minmax(0, 1fr);
        gap: 10px;
        align-items: start;
    }

    .service-table--duties td[data-label]::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: 12px;
        font-weight: 700;
    }

    .service-table--duties td[data-label="Akcja"] {
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .service-table--duties td[data-label="Akcja"]::before {
        content: none;
    }

    .service-table--duties .table-action {
        min-height: 36px;
    }

    .service-table--duties .service-table__row--upcoming {
        border-color: #f4d35e;
        background: #fff9db;
    }

    .service-table--duties .service-table__row--mobile-archived {
        display: none;
    }

    .service-year-form {
        align-items: stretch;
        flex-direction: column;
    }

    .service-year-form input,
    .service-year-form button {
        width: 100%;
    }
}
