:root {
    --djk-green-900: #103b6f;
    --djk-green-700: #1e5fa8;
    --djk-green-100: #e8f1fb;
    --djk-gold-500: #2f8f4e;
    --djk-gold-400: #44a863;
    --text-900: #1f2937;
    --text-700: #374151;
    --bg: #f3f7fc;
    --white: #ffffff;
    --danger: #b91c1c;
    --success: #15803d;
    --shadow: 0 10px 28px rgba(16, 59, 111, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--text-900);
    background: linear-gradient(180deg, #f8faf9 0%, var(--bg) 100%);
}

.top-nav {
    background: var(--white);
    border-bottom: 2px solid #d4e2f1;
}

.top-nav-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.45rem 0.9rem;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
}

.top-nav-link {
    font-size: 0.85rem;
    text-decoration: none;
    color: #20466f;
    padding: 0.28rem 0.55rem;
    border-radius: 8px;
    background: #eef4fb;
}

.top-nav-link.active {
    background: #1e5fa8;
    color: #fff;
}

.top-nav-link-btn {
    border: none;
    cursor: pointer;
    font: inherit;
    line-height: inherit;
}

.page-title {
    margin: 0 0 0.7rem;
    font-size: 1.25rem;
    color: #123f72;
}

.brand-header {
    background: var(--white);
    border-bottom: 4px solid var(--djk-green-700);
    box-shadow: 0 2px 14px rgba(16, 59, 111, 0.1);
}

.brand-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.brand-main {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #4b84c3 0%, var(--djk-green-900) 75%);
    color: var(--white);
    border: 2px solid #d6e3f4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    overflow: hidden;
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--djk-green-900);
}

.brand-subtitle {
    font-size: 0.8rem;
    color: #5a6c80;
}

.brand-tag {
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: #e9f4ed;
    border: 1px solid #c9e6d3;
    color: #237342;
    font-size: 0.8rem;
    font-weight: 700;
}

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

.hero {
    background: linear-gradient(135deg, var(--djk-green-900), var(--djk-green-700));
    color: var(--white);
    border-radius: 16px;
    padding: 1.2rem 1.4rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.hero h1 {
    margin: 0 0 0.35rem;
    font-size: 1.9rem;
}

.hero p {
    margin: 0;
    opacity: 0.95;
}

.card {
    background: var(--white);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1rem;
    border: 1px solid #d8e3ef;
}

.toolbar {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 0.8rem;
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 0.6rem 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    color: var(--white);
    background: var(--djk-gold-500);
}

.btn-primary:hover {
    background: var(--djk-gold-400);
}

.btn-secondary {
    color: var(--white);
    background: var(--djk-green-700);
}

.btn-secondary:hover {
    background: #184f8d;
}

.btn-danger {
    color: var(--white);
    background: var(--danger);
}

.btn-danger:hover {
    background: #a61414;
}

.link {
    color: var(--djk-green-700);
    text-decoration: none;
    font-weight: 600;
}

.link:hover {
    text-decoration: underline;
}

label {
    display: inline-flex;
    flex-direction: column;
    gap: 0.35rem;
    font-weight: 600;
    color: var(--text-700);
}

input, select {
    border: 1px solid #d0d9d4;
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    min-width: 180px;
    font-size: 0.95rem;
    background: var(--white);
}

input:focus, select:focus {
    outline: 2px solid rgba(47, 143, 78, 0.35);
    border-color: var(--djk-gold-500);
}

table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #d5e2ef;
    border-radius: 10px;
    overflow: hidden;
}

th, td {
    padding: 0.65rem;
    border-bottom: 1px solid #e5ebe7;
    text-align: left;
    vertical-align: middle;
}

th {
    color: #dbe9fb;
    background: var(--djk-green-900);
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-pill {
    display: inline-block;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-active {
    color: var(--success);
    background: #e7f7ec;
}

.status-inactive {
    color: #6b7280;
    background: #edf0f2;
}

.flash-ok {
    color: var(--success);
    font-weight: 700;
}

.flash-err {
    color: var(--danger);
    font-weight: 700;
}

.inline {
    display: inline;
}

.js-tooltip {
    position: fixed;
    z-index: 99999;
    display: none;
    max-width: 280px;
    padding: 0.45rem 0.65rem;
    background: #102236;
    color: #fff;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 6px 18px rgba(15, 39, 64, 0.35);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.35;
    white-space: pre-line;
    pointer-events: none;
    text-align: left;
    letter-spacing: 0;
    text-transform: none;
    animation: js-tooltip-fade 0.12s ease-out;
}

.js-tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 5px solid transparent;
}

.js-tooltip[data-placement="top"]::after {
    top: 100%;
    border-top-color: #102236;
}

.js-tooltip[data-placement="bottom"]::after {
    bottom: 100%;
    border-bottom-color: #102236;
}

@keyframes js-tooltip-fade {
    from { opacity: 0; transform: translateY(2px); }
    to { opacity: 1; transform: translateY(0); }
}

[data-tooltip] {
    cursor: help;
}

@media (hover: none) {
    [data-tooltip] {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(18, 63, 114, 0.18);
    }

    .js-tooltip {
        max-width: min(280px, calc(100vw - 16px));
        font-size: 0.88rem;
        padding: 0.55rem 0.75rem;
    }
}

.alloc-chip[data-tooltip],
.team-chip[data-tooltip] {
    cursor: grab;
}

.alloc-chip[data-tooltip]:active,
.team-chip[data-tooltip]:active {
    cursor: grabbing;
}

/* Wochenplan K/R-Viertel: globales th-Styling (hell auf dunkel) hier aushebeln */
.planner-table.quarter-view thead th.quarter-head {
    color: #0a1e33 !important;
    background: #d8e6f4 !important;
    text-transform: none;
    letter-spacing: 0.04em;
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1.2;
    vertical-align: middle;
    border-bottom: 2px solid #1e5fa8;
}

.planner-table.quarter-view thead th.quarter-head.is-today {
    color: #0a1e33 !important;
    box-shadow: inset 0 -3px 0 #ffd54a;
}

.planner-table.quarter-view thead th.day-group-head {
    text-transform: none;
    letter-spacing: normal;
}

/* Trennung Kunstrasen | Rasen (innerhalb eines Tages) */
.planner-table.quarter-view .venue-end {
    border-right: 2px solid #68b981 !important;
}

.planner-table.quarter-view .venue-start {
    border-left: 2px solid #68b981 !important;
}

/* Trennung zwischen Wochentagen (Mo | Di | …) */
.planner-table.quarter-view .weekday-end {
    border-right: 5px solid #123f72 !important;
}

.planner-table.quarter-view .weekday-start {
    border-left: 5px solid #123f72 !important;
}

.planner-table.quarter-view thead th.day-group-head {
    background: linear-gradient(180deg, #184f8d, #123f72) !important;
    color: #fff !important;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    vertical-align: middle;
    text-transform: none !important;
    letter-spacing: normal !important;
    border-left: 5px solid #0d2f56;
    border-right: 5px solid #0d2f56;
}

.planner-table.quarter-view {
    overflow: visible;
    border-collapse: separate;
    border-spacing: 0;
}

.planner-table.quarter-view thead th.time-col.day-group-head {
    position: relative;
    z-index: 9;
    padding: 0;
    background: linear-gradient(180deg, #184f8d, #123f72) !important;
    color: #fff !important;
}

.planner-table.quarter-view thead th.time-corner {
    position: relative;
    z-index: 8;
    padding: 0;
    min-width: 52px;
    width: 52px;
    min-height: 1.6rem;
    border-bottom: 2px solid #1e5fa8;
    color: #0a1e33 !important;
    background: #d8e6f4 !important;
}

.planner-table.quarter-view th.time-col,
.planner-table.quarter-view td.time-col {
    width: 52px;
    min-width: 52px;
}

.planner-table.quarter-view tbody td.time-col {
    position: relative;
    z-index: 6;
    padding: 0;
    overflow: visible;
    background: #f0f6fc;
}

.planner-table.quarter-view .time-col-freeze {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    left: 0;
    z-index: 7;
    box-sizing: border-box;
    width: 52px;
    min-width: 52px;
    pointer-events: none;
}

.planner-table.quarter-view thead th.time-col.day-group-head .time-col-freeze {
    min-height: 2.2rem;
    padding: 0.35rem 0.2rem;
    background: linear-gradient(180deg, #184f8d, #123f72);
    color: #fff;
    font-weight: 700;
}

.planner-table.quarter-view thead th.time-corner .time-col-freeze {
    min-height: 1.6rem;
    height: 100%;
    background: #d8e6f4;
}

.planner-table.quarter-view tbody td.time-col .time-col-freeze {
    height: 28px;
    min-height: 28px;
    background: #f0f6fc;
}

.planner-grid-wrap {
    width: max-content;
    min-width: 100%;
}

.planner-scroll-host {
    display: block !important;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.planner-scroll-host.card {
    display: block !important;
}

.planner-scroll-host.is-hscrolled .time-col-freeze {
    box-shadow: 6px 0 10px rgba(16, 59, 111, 0.18);
}

.planner-table.quarter-view tr.is-now td.time-col .time-col-freeze {
    color: #d9303f;
    font-weight: 700;
}

/* Raster: Termine ohne Lücken (durchgehend vertikal/horizontal) */
.planner-table.quarter-view tbody td.day-cell {
    padding: 0;
    border-bottom: none;
    vertical-align: top;
    height: 28px;
    line-height: 0;
}

.planner-table.quarter-view .hall-surface {
    width: 104px;
    min-width: 104px;
    max-width: 104px;
}

.planner-table.quarter-view thead th.hall-surface {
    white-space: normal;
    line-height: 1.15;
}

.planner-table.quarter-view tbody tr {
    height: 28px;
}

.planner-table.quarter-view tbody td.time-col {
    border-bottom: 1px solid #dce4ed;
    padding: 0;
    vertical-align: middle;
    line-height: 1.2;
}

.planner-table.quarter-view .slot {
    position: relative;
    min-height: 28px;
    height: 28px;
    border-radius: 0;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.planner-table.quarter-view .slot.empty-slot {
    border: none;
    box-shadow: inset 0 -1px 0 rgba(15, 35, 60, 0.08);
}

.planner-table.quarter-view .slot:has(.alloc-chip) {
    box-shadow: none;
}

.planner-table.quarter-view .slot.drop-hover {
    outline: 2px solid #4a90d9;
    outline-offset: -2px;
}

.planner-table.quarter-view .slot.resize-preview {
    box-shadow: inset 0 0 0 2px #1d4e89;
}

body.is-resizing-alloc {
    cursor: ns-resize;
    user-select: none;
}

body.is-resizing-alloc-x,
body.is-resizing-alloc-x .alloc-resize-handle {
    cursor: ew-resize;
}

.alloc-resize-handle {
    position: absolute;
    left: 0;
    right: 0;
    height: 7px;
    z-index: 6;
    cursor: ns-resize;
    touch-action: none;
}

.alloc-resize-handle[data-resize-edge="start"] {
    top: 0;
}

.alloc-resize-handle[data-resize-edge="end"] {
    bottom: 0;
}

.alloc-resize-handle.shares-edge {
    right: 38%;
}

.alloc-resize-handle.is-guest {
    left: auto;
    width: 42%;
    right: 1px;
}

.alloc-resize-handle.is-detached {
    right: 1px;
    bottom: 0;
    left: auto;
    width: 36%;
    z-index: 8;
}

.alloc-resize-handle::before {
    content: "";
    position: absolute;
    left: 50%;
    width: 10px;
    height: 2px;
    border-radius: 1px;
    background: rgba(255, 255, 255, 0.45);
    transform: translateX(-50%);
    opacity: 0.55;
}

.alloc-resize-handle[data-resize-edge="start"]::before {
    top: 1px;
}

.alloc-resize-handle[data-resize-edge="end"]::before {
    bottom: 1px;
}

.alloc-resize-handle[data-resize-edge="left"],
.alloc-resize-handle[data-resize-edge="right"] {
    top: 0;
    bottom: 0;
    height: auto;
    width: 7px;
    cursor: ew-resize;
}

.alloc-resize-handle[data-resize-edge="left"] {
    left: 0;
    right: auto;
}

.alloc-resize-handle[data-resize-edge="right"] {
    right: 0;
    left: auto;
}

.alloc-resize-handle.is-guest[data-resize-edge="left"],
.alloc-resize-handle.is-guest[data-resize-edge="right"] {
    width: 7px;
    height: auto;
}

.alloc-resize-handle[data-resize-edge="left"]::before,
.alloc-resize-handle[data-resize-edge="right"]::before {
    width: 2px;
    height: 10px;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
}

.alloc-resize-handle[data-resize-edge="left"]::before {
    left: 1px;
}

.alloc-resize-handle[data-resize-edge="right"]::before {
    left: auto;
    right: 1px;
}

.alloc-resize-handle:hover::before,
body.is-resizing-alloc .alloc-resize-handle::before,
body.is-resizing-alloc-x .alloc-resize-handle::before {
    background: rgba(255, 255, 255, 0.9);
    opacity: 1;
}

.planner-table.quarter-view .alloc-chip[draggable="true"] {
    cursor: pointer;
}

.planner-edit-popover {
    position: fixed;
    z-index: 1080;
    box-sizing: border-box;
    width: min(19rem, calc(100vw - 1rem));
    padding: 0.7rem 0.75rem 0.75rem;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
    color: #0f172a;
}

.planner-edit-popover-title {
    font-size: 0.9rem;
    font-weight: 800;
    margin-bottom: 0.1rem;
}

.planner-edit-popover-hint {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.planner-edit-popover-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.55rem 0.5rem;
    margin-bottom: 0.65rem;
}

.planner-edit-popover-grid label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    min-width: 0;
    width: 100%;
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.15;
    color: #64748b;
}

.planner-edit-popover-grid label:first-child {
    grid-column: 1 / -1;
}

.planner-edit-popover select {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 2.15rem;
    margin: 0;
    padding: 0.2rem 0.45rem;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    color: #0f172a;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}

.planner-edit-popover-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.planner-edit-popover-actions .btn {
    font-size: 0.75rem;
}

.team-chip.is-complete {
    cursor: default;
    opacity: 0.85;
}

.team-unit-count {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0 0.28rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    font-size: 0.72rem;
    font-weight: 800;
}

.team-unit-count.is-missing,
.team-unit-count.is-open {
    background: #c62828;
    color: #fff;
}

.team-unit-count.is-met {
    background: rgba(255, 255, 255, 0.88);
    color: #102236;
}

.team-unit-count.is-over {
    background: #102236;
    color: #fff;
}

.team-pool-hint {
    margin: -0.15rem 0 0.55rem;
    font-size: 0.78rem;
    line-height: 1.35;
    color: #475569;
}

.alloc-resize-label {
    position: fixed;
    z-index: 40;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: #102236;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
    pointer-events: none;
}

.planner-table.quarter-view .alloc-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 28px;
    min-height: 28px;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-sizing: border-box;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.planner-table.quarter-view .alloc-chip.is-continuation {
    color: transparent !important;
}

.planner-table.quarter-view .alloc-chip.is-start.is-end {
    border-radius: 3px;
}

.planner-table.quarter-view .alloc-chip.is-start:not(.is-end) {
    border-radius: 3px 3px 0 0;
}

.planner-table.quarter-view .alloc-chip.is-end:not(.is-start) {
    border-radius: 0 0 3px 3px;
}

.planner-table.quarter-view .alloc-bundle {
    position: relative;
    width: 100%;
    height: 28px;
    min-height: 28px;
}

.planner-table.quarter-view .alloc-bundle .alloc-chip.is-primary {
    position: relative;
    width: 100%;
    height: 28px;
    min-height: 28px;
}

.planner-table.quarter-view .alloc-bundle.has-guests .alloc-chip.is-primary {
    height: 28px;
    min-height: 28px;
}

.planner-table.quarter-view .alloc-bundle.has-guests .alloc-chip.is-primary.is-start {
    align-items: flex-start;
    padding-top: 3px;
    font-size: 0.62rem;
}

.planner-table.quarter-view .alloc-bundle.has-guests .alloc-chip.is-primary.is-continuation {
    height: 28px;
    min-height: 28px;
}

.planner-table.quarter-view .alloc-chip.alloc-guest-tag {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 14px;
    min-height: 14px;
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 14px;
    border-top: none;
    box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.4);
    overflow: hidden;
    z-index: 3;
}

.venue-aerial-overview {
    display: flex;
    align-items: flex-end;
    gap: 0;
    margin-top: 0.75rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.venue-aerial-time-spacer {
    flex: 0 0 52px;
    min-width: 52px;
    max-width: 52px;
}

.venue-aerial-strip {
    display: flex;
    flex: 1 1 auto;
    gap: 0;
    min-width: 0;
    width: 100%;
    align-items: stretch;
}

.venue-aerial-gap {
    min-width: 0;
}

.venue-aerial-item {
    display: flex;
    flex-direction: column;
    margin: 0;
    min-width: 0;
    border: 1px solid #c5d4e6;
    border-radius: 6px;
    overflow: hidden;
    background: #f4f8fc;
}

.venue-aerial-media {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    background: #d8e6f2;
}

.venue-aerial-item + .venue-aerial-item {
    border-left: none;
    border-radius: 0 6px 6px 0;
}

.venue-aerial-item:first-of-type {
    border-radius: 6px 0 0 6px;
}

.venue-aerial-item:only-of-type {
    border-radius: 6px;
}

.venue-aerial-item img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
}

.venue-aerial-item figcaption {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    padding: 0.2rem 0.35rem;
    font-size: 0.68rem;
    line-height: 1.2;
    background: #e8f1fb;
    color: #123f72;
}

.venue-aerial-codes {
    font-weight: 800;
    letter-spacing: 0.03em;
}

.venue-aerial-label {
    font-weight: 500;
    opacity: 0.9;
}

.venue-aerial-overview:has(.venue-aerial-strip:empty) {
    display: none;
}

.plan-status-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.85rem;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    border: 2px solid;
    font-size: 0.95rem;
    line-height: 1.35;
    margin: 0 0 0.75rem;
}
.plan-status-banner strong {
    font-size: 1.08rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.plan-status-banner.is-preliminary {
    background: #fff4d4;
    border-color: #e0a800;
    color: #6b4e00;
}
.plan-status-banner.is-final {
    background: #e6f6ea;
    border-color: #2f8f4e;
    color: #1e5a32;
}
.plan-status-when {
    font-weight: 700;
    margin-left: auto;
}

@media (max-width: 700px) {
    .brand-wrap {
        flex-direction: column;
        align-items: flex-start;
    }
}
