:root {
    --win-gray: #c0c0c0;
    --win-dark: #808080;
    --win-darker: #404040;
    --win-light: #ffffff;
    --win-blue: #000080;
    --win-blue2: #1084d0;
    --text: #000000;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: "MS Sans Serif", Tahoma, Arial, sans-serif;
    font-size: 16px;
    background: #008080;
    color: var(--text);
}

body {
    padding: 10px;
}

a { color: #000080; }

.desktop {
    min-height: calc(100vh - 20px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.window {
    background: var(--win-gray);
    border-top: 2px solid var(--win-light);
    border-left: 2px solid var(--win-light);
    border-right: 2px solid #000;
    border-bottom: 2px solid #000;
    box-shadow: 1px 1px 0 var(--win-dark);
}

.main-window {
    width: min(1100px, 100%);
}

.title-bar {
    margin: 2px;
    padding: 4px 5px;
    color: white;
    background: linear-gradient(90deg, var(--win-blue), var(--win-blue2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
}

.title-bar-controls {
    display: flex;
    gap: 2px;
}

.title-bar-controls button {
    width: 24px;
    height: 22px;
    padding: 0;
    font-weight: bold;
}

.menu-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border-bottom: 1px solid var(--win-dark);
}

.menu-bar a {
    color: black;
    text-decoration: none;
    padding: 6px 10px;
}

.menu-bar a:active {
    border-top: 1px solid var(--win-dark);
    border-left: 1px solid var(--win-dark);
    border-right: 1px solid white;
    border-bottom: 1px solid white;
}

.window-body {
    padding: 14px;
}

.status-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px;
    padding: 4px;
}

.status-bar > div {
    border-top: 1px solid var(--win-dark);
    border-left: 1px solid var(--win-dark);
    border-right: 1px solid white;
    border-bottom: 1px solid white;
    padding: 4px 6px;
    font-size: 13px;
}

h1 {
    font-size: 24px;
    margin: 4px 0 14px;
}

fieldset {
    margin: 0 0 14px;
    padding: 14px;
    border-top: 2px solid var(--win-dark);
    border-left: 2px solid var(--win-dark);
    border-right: 2px solid white;
    border-bottom: 2px solid white;
}

legend {
    padding: 0 7px;
    font-weight: bold;
}

label {
    display: block;
    margin: 10px 0 5px;
    font-weight: bold;
}

input, select, textarea {
    width: 100%;
    min-height: 42px;
    padding: 8px;
    font: inherit;
    color: black;
    background: white;
    border-top: 2px solid #404040;
    border-left: 2px solid #404040;
    border-right: 2px solid white;
    border-bottom: 2px solid white;
    border-radius: 0;
}

textarea { resize: vertical; }

button, .button {
    display: inline-block;
    min-height: 42px;
    padding: 9px 14px;
    font: inherit;
    font-weight: bold;
    color: black;
    text-decoration: none;
    text-align: center;
    background: var(--win-gray);
    border-top: 2px solid white;
    border-left: 2px solid white;
    border-right: 2px solid #000;
    border-bottom: 2px solid #000;
    cursor: pointer;
}

button:active, .button:active {
    border-top: 2px solid #000;
    border-left: 2px solid #000;
    border-right: 2px solid white;
    border-bottom: 2px solid white;
}

.primary {
    outline: 2px solid var(--win-blue);
    outline-offset: -5px;
}

.danger {
    font-weight: bold;
}

.button-stack {
    display: grid;
    gap: 9px;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

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

.inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inline input[type="number"] {
    max-width: 150px;
}

.inline input[type="checkbox"] {
    width: 22px;
    min-height: 22px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    font-weight: normal;
}

.big-value {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 8px;
}

.hint {
    font-size: 13px;
    margin-top: 6px;
}

.message {
    margin-bottom: 12px;
    padding: 10px;
    border: 2px inset white;
    background: #ffffcc;
}

.message.success { background: #dfffdf; }
.message.error { background: #ffdede; }

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th, td {
    padding: 8px;
    border: 1px solid #808080;
    white-space: nowrap;
}

th {
    background: var(--win-gray);
    text-align: left;
}

.heading-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.summary-box {
    margin-bottom: 14px;
    padding: 10px;
    background: #ffffcc;
    border: 2px inset white;
}

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

.month { min-width: 0; }

.matrix-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(55px, 1fr));
    gap: 4px;
}

.day-cell {
    min-height: 78px;
    padding: 5px;
    text-decoration: none;
    color: black;
    background: #ecf0f1;
    border-top: 2px solid white;
    border-left: 2px solid white;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
}

.day-cell.has-entry {
    color: white;
}

/* Farben identisch zur Windows-PC-Jahresmatrix */
.day-cell.cat-arbeit { background: #229954; color: white; }
.day-cell.cat-urlaub { background: #2980b9; color: white; }
.day-cell.cat-frei { background: #7f8c8d; color: white; }
.day-cell.cat-krank { background: #c0392b; color: white; }
.day-cell.cat-feiertag { background: #8e44ad; color: white; }

.matrix-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px 14px;
    margin: -4px 0 12px;
    padding: 7px 9px;
    border-top: 2px solid #808080;
    border-left: 2px solid #808080;
    border-right: 2px solid white;
    border-bottom: 2px solid white;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.legend-color {
    display: inline-block;
    width: 22px;
    height: 18px;
    border-top: 1px solid white;
    border-left: 1px solid white;
    border-right: 1px solid #404040;
    border-bottom: 1px solid #404040;
}

.legend-arbeit { background: #229954; }
.legend-urlaub { background: #2980b9; }
.legend-frei { background: #7f8c8d; }
.legend-krank { background: #c0392b; }
.legend-feiertag { background: #8e44ad; }

.day-number {
    display: block;
    font-weight: bold;
}

.weekday {
    display: block;
    font-size: 12px;
}

.day-info {
    display: block;
    margin-top: 5px;
    font-size: 13px;
}

@media (max-width: 760px) {
    body { padding: 0; background: var(--win-gray); }

    .desktop { min-height: 100vh; }

    .main-window {
        width: 100%;
        min-height: 100vh;
        border-left: 0;
        border-right: 0;
    }

    .window-body { padding: 10px; }

    .grid.two, .months {
        grid-template-columns: 1fr;
    }

    .menu-bar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .menu-bar a {
        border-top: 2px solid white;
        border-left: 2px solid white;
        border-right: 2px solid #000;
        border-bottom: 2px solid #000;
        text-align: center;
        min-height: 42px;
    }

    .matrix-grid {
        grid-template-columns: repeat(7, minmax(42px, 1fr));
        gap: 2px;
    }

    .matrix-legend {
        justify-content: flex-start;
        gap: 7px 10px;
    }

    .day-cell {
        min-height: 68px;
        padding: 3px;
    }

    .day-info { font-size: 11px; }
    .weekday { font-size: 10px; }

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

    .inline input[type="number"] {
        max-width: 100%;
    }

    .button-row > * {
        flex: 1 1 100%;
    }
}


/* v1.5 – Dashboard näher an der PC-Version */
.balance { font-size: 24px; font-weight: bold; margin-top: 6px; }
.balance.positive { color: #0000cc; }
.balance.negative { color: #800000; }
.month-select { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.month-select label { margin: 0; }
.month-select select { width: auto; min-width: 170px; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.metric-card {
    min-width: 0; padding: 10px; text-align: center; background: var(--win-gray);
    border-top: 2px solid white; border-left: 2px solid white;
    border-right: 2px solid #808080; border-bottom: 2px solid #808080;
}
.metric-card strong { display: block; font-size: 18px; }
.metric-sub { display: block; font-size: 12px; margin-top: 4px; }
.metric-value { display: block; font-size: 25px; font-weight: bold; margin: 9px 0; }
@media (max-width: 900px) { .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .metric-grid { grid-template-columns: 1fr; } .month-select { align-items: stretch; flex-direction: column; } .month-select select { width: 100%; } }


/* v1.6 – Öffentlicher Arbeitsplan & Login */
.public-plan-hint {
    margin: -5px 0 14px;
    padding: 8px;
    background: #ffffcc;
    border-top: 2px solid #808080;
    border-left: 2px solid #808080;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
}
.plan-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.plan-fieldset { min-width: 0; }
.receipt-shell {
    overflow-x: auto;
    padding: 12px;
    background: #808080;
    border-top: 2px solid #404040;
    border-left: 2px solid #404040;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
}
.shift-receipt {
    width: fit-content;
    min-width: min(100%, 390px);
    margin: 0 auto;
    padding: 18px 14px 26px;
    background: #ffffff;
    color: #000000;
    font-family: "Courier New", Consolas, monospace;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre;
    border: 1px solid #b0b0b0;
    box-shadow: 2px 2px 0 #404040;
}
.public-login-area {
    margin: 18px auto 4px;
    max-width: 520px;
    padding: 14px;
    text-align: center;
    border-top: 2px solid #808080;
    border-left: 2px solid #808080;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
}
.public-login-area .hint { margin: 0 0 10px; }
.login-button { min-width: 190px; margin: 4px; }
.login-panel { max-width: 520px; margin: 20px auto; }

@media (max-width: 760px) {
    .plan-grid { grid-template-columns: 1fr; }
    .receipt-shell { padding: 8px 4px; }
    .shift-receipt {
        min-width: 358px;
        padding: 14px 8px 22px;
        font-size: 12px;
    }
    .login-button { width: 100%; margin: 4px 0; }
}


/* v1.7.2 – Arbeitsplan auf Mobilgeräten deutlich größer und untereinander */
.plan-grid {
    grid-template-columns: 1fr;
    gap: 18px;
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
}

.plan-fieldset legend {
    font-size: 16px;
    font-weight: bold;
}

.shift-receipt {
    font-size: 17px;
    line-height: 1.58;
    min-width: 455px;
    padding: 20px 18px 28px;
}

@media (max-width: 760px) {
    .public-plan-hint {
        font-size: 15px;
        line-height: 1.45;
    }

    .plan-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .plan-fieldset {
        margin: 0;
        padding: 8px;
    }

    .plan-fieldset legend {
        font-size: 17px;
    }

    .receipt-shell {
        padding: 8px 3px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .shift-receipt {
        min-width: 430px;
        width: max-content;
        max-width: none;
        padding: 18px 12px 26px;
        font-size: 16px;
        line-height: 1.6;
    }
}

@media (max-width: 390px) {
    .shift-receipt {
        min-width: 410px;
        font-size: 15.5px;
    }
}


/* Programm-Schließen-Fallback für Browser, die window.close() blockieren. */
.closed-desktop {
    min-height: calc(100vh - 20px);
    align-items: center;
}
.closed-window {
    width: min(430px, 100%);
}
.closed-body {
    padding: 28px 18px;
    text-align: center;
    font-size: 18px;
    line-height: 1.5;
}
#appCloseButton {
    cursor: pointer;
}

/* v1.8 Tagesplan / Stempelzeit */
.section-title {
    margin: 14px 0 8px;
    font-weight: 700;
    font-size: 1.08em;
    border-bottom: 1px solid #808080;
    padding-bottom: 4px;
}

/* v1.9.0 – mobile Verwaltung näher an der PC-Version */
.pc-like-menu {
    align-items: stretch;
}
.quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
}
.dashboard-heading form { margin: 0; }
.plan-summary {
    margin: 12px 0;
    padding: 10px;
    background: #ffffcc;
    border-top: 2px solid #808080;
    border-left: 2px solid #808080;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    line-height: 1.5;
}
.entry-filter-bar {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto;
    gap: 10px;
    align-items: end;
}
.entry-filter-bar label { margin-top: 0; }
.entry-selection-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 10px;
}
.entry-selection-tools.bottom-tools { margin: 10px 0 0; }
.entries-table .entry-check {
    width: 24px;
    min-height: 24px;
}
.entry-actions {
    display: flex;
    gap: 5px;
}
.small-button {
    min-height: 32px;
    padding: 5px 8px;
    font-size: 13px;
}

@media (max-width: 760px) {
    .pc-like-menu {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .quick-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .entry-filter-bar {
        grid-template-columns: 1fr;
    }
    .entry-filter-bar button {
        width: 100%;
    }
    .entry-selection-tools > * {
        flex: 1 1 100%;
    }
    .entries-table {
        min-width: 1050px;
    }
}


.message.info { background: #e9efff; }
.message.warning { background: #fff2c7; }

/* Planfoto 1.9.8 – einfache KW-Fotoablage ohne Erkennung */
.plan-photo-action { margin-bottom: 10px; }
.planfoto-fields { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:10px 0; }
.planfoto-fields label { margin-top:0; }
.planfoto-preview-box { margin:12px 0; padding:8px; background:#808080; border:2px inset #fff; text-align:center; }
.planfoto-preview-box img { display:block; max-width:100%; max-height:520px; margin:0 auto; object-fit:contain; background:#fff; }
.planfoto-status { margin:10px 0; }
.planfoto-status.success { background:#d9ffd9; padding:7px; }
.planfoto-status.error { background:#ffd9d9; padding:7px; }
.planfoto-status.info { background:#e9efff; padding:7px; }
.planfoto-archive-list { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.planfoto-archive-item { display:flex; flex-direction:column; gap:4px; padding:10px; color:#000; text-decoration:none; background:#c0c0c0; border-top:2px solid #fff; border-left:2px solid #fff; border-right:2px solid #808080; border-bottom:2px solid #808080; }
.planfoto-archive-item:active { border-top-color:#808080; border-left-color:#808080; border-right-color:#fff; border-bottom-color:#fff; }
.planfoto-archive-item span { font-size:12px; color:#404040; }
@media (max-width:760px) { .planfoto-fields { grid-template-columns:1fr; } .planfoto-archive-list { grid-template-columns:1fr; } }
