:root {
    --blue: #21224a;
    --blue-2: #151638;
    --green: #25aa75;
    --green-2: #0a8f70;
    --gray: #f4f7f7;
    --line: #dfe8e8;
    --text: #20243f;
    --muted: #666d82;
    --danger: #d94646;
    --warn: #f2c94c;
    --surface: #ffffff;
    --surface-soft: #f8fbfb;
    --shadow: 0 6px 16px rgba(33, 34, 74, .045);
    --shadow-soft: 0 4px 10px rgba(33, 34, 74, .035);
}

* { box-sizing: border-box; }

html {
    width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
    font-family: "Trebuchet MS", "Segoe UI", Arial, Helvetica, sans-serif;
    background:
        linear-gradient(180deg, #ffffff 0, #ffffff 120px, #f8fbfb 360px, var(--gray) 760px),
        var(--gray);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

.hidden { display: none !important; }

#appView {
    width: 100%;
    min-width: 0;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card, .card, .table-card, dialog {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: var(--shadow);
}

.auth-card {
    width: min(420px, 100%);
    padding: 28px;
    border-top: 4px solid var(--green);
}

.auth-card h1, .brand {
    color: var(--blue);
    letter-spacing: .01em;
}

.auth-card h1 span, .brand span { color: var(--green); }

.auth-card h1 {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-card h1 img {
    width: min(210px, 70%);
    height: auto;
    display: block;
}

label {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
    font-weight: 700;
}

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

input, select, textarea {
    width: 100%;
    inline-size: 100%;
    max-width: 100%;
    min-width: 0;
    border: 1px solid #cadbe3;
    border-radius: 9px;
    padding: 12px 13px;
    background: #fff;
    color: var(--text);
    display: block;
}

label {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.card form,
.table-card form,
dialog form {
    min-width: 0;
    max-width: 100%;
}

input[type="date"],
input[type="month"],
input[type="datetime-local"],
input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    inline-size: 100%;
    min-width: 0;
    max-width: 100%;
    line-height: 1.25;
    box-sizing: border-box;
}

input::-webkit-date-and-time-value {
    max-width: 100%;
    min-width: 0;
    text-align: left;
}

input:focus, select:focus, textarea:focus {
    outline: 0;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(24, 179, 136, .16);
}

button {
    border: 0;
    border-radius: 6px;
    padding: 10px 16px;
    background: var(--green);
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .035em;
    text-transform: uppercase;
    box-shadow: none;
}

button:hover { background: var(--green-2); }
button:disabled {
    cursor: not-allowed;
    opacity: .45;
}
button.secondary, button.ghost {
    background: #fff;
    color: var(--blue);
    border: 1px solid var(--line);
    box-shadow: none;
}
button.ghost:hover,
button.secondary:hover {
    background: #f7fbfa;
    border-color: rgba(37, 170, 117, .36);
}
button.danger { background: var(--danger); }

.topbar {
    display: flex;
    align-items: center;
    gap: 34px;
    padding: 20px 42px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: none;
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    min-width: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 17px;
    flex: 0 0 auto;
}

.brand img {
    width: 150px;
    max-height: 58px;
    display: block;
}

nav {
    display: flex;
    gap: 30px;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
    overflow: visible;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

nav::-webkit-scrollbar { display: none; }

nav button {
    background: transparent;
    color: var(--blue);
    border: 1px solid transparent;
    border-radius: 0;
    padding: 10px 0 12px;
    min-height: 38px;
    box-shadow: none;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .01em;
    text-transform: uppercase;
    flex: 0 0 auto;
    position: relative;
}

nav button:hover,
nav button.active:hover {
    background: transparent;
    color: var(--green);
}

nav button.active {
    border-color: transparent;
    color: var(--green);
    background: transparent;
    box-shadow: none;
}

nav button.active::after,
nav button:hover::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    border-radius: 999px;
    background: var(--green);
}

.session-area {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.current-user {
    color: var(--blue);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
}

.template-task-note,
.task-detail-description {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-line;
}

.task-detail-item.auto-task {
    background: #f4faf8;
    border-left: 4px solid var(--green);
    border-radius: 8px;
    padding: 14px 16px 22px 14px;
    position: relative;
    overflow: hidden;
}

.task-detail-item.auto-task::before {
    content: "";
    position: absolute;
    left: 14px;
    right: 16px;
    bottom: 10px;
    height: 7px;
    background: #dce7ec;
    border-radius: 999px;
}

.task-detail-item.auto-task::after {
    content: "";
    position: absolute;
    left: 14px;
    bottom: 10px;
    width: var(--progress, 0%);
    max-width: calc(100% - 30px);
    height: 7px;
    background: var(--green);
    border-radius: 999px;
}

.task-detail-item.sub-task {
    margin-left: 24px;
}

.auto-progress {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 110px;
    color: var(--blue);
    justify-content: flex-end;
}

.auto-progress strong {
    font-size: 18px;
}

.auto-progress span {
    color: var(--muted);
    font-size: 12px;
}

.page {
    padding: 36px 36px 52px;
    width: 100%;
    min-width: 0;
    max-width: 1280px;
    margin: 0 auto;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

h1 { margin: 0 0 16px; font-size: 30px; }
h1, h2 {
    color: var(--blue);
    font-weight: 800;
    letter-spacing: 0;
}
h1::before {
    content: "";
    display: block;
    width: 42px;
    height: 3px;
    border-radius: 999px;
    background: var(--green);
    margin-bottom: 12px;
}
h2 { margin-top: 0; font-size: 19px; }

.toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 14px;
    box-shadow: none;
}

.grid-5 { grid-template-columns: 2fr 1fr 1fr 1fr 1fr; }

.dashboard-grid, .cards, .two-col {
    display: grid;
    gap: 24px;
    min-width: 0;
}

.dashboard-grid > *,
.cards > *,
.two-col > *,
.project-layout > *,
.vacation-layout > *,
.time-layout > * {
    min-width: 0;
}

.dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cards {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.two-col {
    grid-template-columns: minmax(0, 1fr) 380px;
}

.card, .table-card {
    padding: 26px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.table-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-project-list {
    display: none;
}

.card h2,
.table-card h2 {
    margin-bottom: 18px;
    font-size: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th, td {
    text-align: left;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    overflow-wrap: anywhere;
}

td[data-label]::before {
    content: none;
}

tbody tr:hover {
    background: #f9fcfb;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 12px 0 24px;
}

.stats > div {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.stats strong,
.stats span {
    display: block;
}

.stats strong {
    font-size: 28px;
    color: var(--blue);
    line-height: 1;
}

.stats span {
    margin-top: -8px;
    color: #607184;
}

.deadline-card {
    display: flex;
    flex-direction: column;
}

.deadline-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 12px 0 24px;
}

.deadline-stats > div {
    min-height: 72px;
    display: grid;
    align-content: center;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 13px 14px;
}

.deadline-stats strong,
.deadline-stats span {
    display: block;
}

.deadline-stats strong {
    color: var(--blue);
    font-size: 30px;
    line-height: 1;
}

.deadline-stats span {
    color: var(--muted);
    line-height: 1.2;
}

.deadline-list {
    display: grid;
    gap: 10px;
}

.deadline-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.deadline-row:last-child {
    border-bottom: 0;
}

.deadline-row > div {
    min-width: 0;
}

.deadline-row .link {
    overflow-wrap: anywhere;
}

.deadline-row strong {
    color: var(--blue);
    white-space: nowrap;
}

.deadline-cell {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
}

.danger-text {
    color: var(--danger) !important;
}

.metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
}

.metric strong {
    color: var(--blue);
}

.metric:last-child {
    border-bottom: 0;
}

.dashboard-task-list {
    display: grid;
}

.dashboard-task {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.dashboard-task:last-child {
    border-bottom: 0;
}

.dashboard-task strong,
.dashboard-task span {
    display: block;
    overflow-wrap: anywhere;
}

.dashboard-task .link {
    margin-top: 4px;
}

.dashboard-task small {
    color: var(--muted);
    white-space: nowrap;
    padding-top: 2px;
}

.notification {
    display: grid;
    gap: 4px;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--green);
    border-radius: 4px;
    margin-bottom: 0;
    background: #fff;
    box-shadow: none;
}

.notification.warn {
    border-left-color: var(--warn);
}

.notification.danger {
    border-left-color: var(--danger);
}

.notification span {
    color: var(--muted);
}

.task-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.task-pager span {
    color: var(--muted);
    font-weight: 700;
    min-width: 48px;
    text-align: center;
}

.arrow-button {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
    font-size: 26px;
    line-height: 1;
}

.button-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

th {
    color: var(--muted);
    font-size: 13px;
}

.link {
    color: var(--blue);
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eaf2f5;
    font-size: 12px;
}

.status-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.status-options button {
    background: var(--surface-soft);
    color: var(--blue);
    border: 1px solid var(--line);
    padding: 7px 10px;
    box-shadow: none;
}

.status-options button.selected {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.task-detail-list {
    display: grid;
    gap: 0;
    margin-bottom: 14px;
}

.task-detail-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.task-detail-item:first-child {
    padding-top: 4px;
}

.task-detail-title {
    font-weight: 700;
    overflow-wrap: anywhere;
}

.task-detail-status {
    min-width: 0;
}

.dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    box-shadow: 0 0 0 3px rgba(24, 179, 136, .08);
}

.green { background: var(--green); }
.yellow { background: var(--warn); }
.red { background: var(--danger); }
.gray { background: #a8b5c0; }

.progress {
    width: 150px;
    max-width: 100%;
    min-width: 0;
    height: 18px;
    border-radius: 999px;
    overflow: hidden;
    background: #dfe8ef;
    box-shadow: inset 0 1px 2px rgba(6, 31, 61, .1);
}

.bar {
    height: 100%;
    min-width: 0;
    max-width: 100%;
    background: var(--green);
    color: #fff;
    font-size: 12px;
    text-align: center;
}

.copy-row {
    display: flex;
    gap: 8px;
}

.copy-row input {
    font-family: Consolas, monospace;
}

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

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.calendar-weekday {
    background: var(--blue);
    color: #fff;
    padding: 10px;
    font-weight: 700;
    text-align: center;
}

.calendar-day {
    min-height: 150px;
    background: var(--surface);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.calendar-day.weekend {
    background: #eef4f7;
}

.calendar-day.outside-month {
    background: var(--surface-soft);
    color: #8392a2;
}

.calendar-day.outside-month.weekend {
    background: #edf1f5;
}

.calendar-day.today {
    box-shadow: inset 0 0 0 2px var(--green);
}

.calendar-date {
    font-weight: 700;
    color: var(--blue);
}

.calendar-event {
    width: 100%;
    border-radius: 6px;
    padding: 6px 8px;
    text-align: left;
    color: var(--text);
    background: #e5eef3;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-event strong,
.calendar-event small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-event strong {
    font-size: 13px;
}

.calendar-event small {
    margin-top: 3px;
    color: #607184;
    font-size: 11px;
    line-height: 1.25;
}

.calendar-event.green { background: #dcf5ed; border-left: 4px solid var(--green); }
.calendar-event.yellow { background: #fff3c4; border-left: 4px solid var(--warn); }
.calendar-event.red { background: #ffe0e0; border-left: 4px solid var(--danger); }
.calendar-event.gray { background: #eef2f5; border-left: 4px solid #a8b5c0; }
.holiday-event { background: #eef2f6; border-left: 4px solid #7b8794; }
.vacation-event { background: #d7f1ec; border-left: 4px solid var(--green); }
.sick-event { background: #ffe7e7; border-left: 4px solid var(--danger); }
.time-event { background: #e4f0ff; border-left: 4px solid var(--blue-2); }

.calendar-more {
    font-size: 12px;
    color: var(--muted);
}

.vacation-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.8fr) minmax(280px, 1fr);
    gap: 16px;
    align-items: start;
}

.time-layout {
    display: grid;
    grid-template-columns: minmax(260px, .7fr) minmax(320px, 1fr);
    gap: 16px;
    align-items: start;
}

.wide-card {
    grid-column: 1 / -1;
}

.time-status {
    display: grid;
    gap: 5px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    margin-bottom: 14px;
}

.time-status.active {
    border-color: rgba(24, 179, 136, .55);
    background: #dcf5ed;
}

.time-status strong {
    color: var(--blue);
    font-size: 20px;
}

.time-status span {
    color: var(--muted);
}

.time-actions {
    justify-content: flex-start;
}

.time-entry-row,
.absence-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.time-entry-row:last-child,
.absence-row:last-child {
    border-bottom: 0;
}

.time-entry-row span,
.absence-row span,
.absence-row small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

.time-entry-row small {
    color: var(--blue);
    font-weight: 800;
    white-space: nowrap;
}

.editable-time-row .button-row {
    align-items: center;
}

.absence-row {
    grid-template-columns: minmax(0, 1fr);
    border-left: 4px solid var(--green);
    padding-left: 12px;
}

.absence-row.sick {
    border-left-color: var(--danger);
}

.calendar-subhead {
    margin: 22px 0 12px;
}

.calendar-subhead h2 {
    margin-bottom: 4px;
}

.vacation-item {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.vacation-item:last-child {
    border-bottom: 0;
}

.vacation-item span,
.vacation-item small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.compact-buttons {
    flex-wrap: nowrap;
}

#templateList.cards {
    grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
    align-items: start;
}

.template-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.template-card-head {
    align-items: flex-start;
    margin-bottom: 0;
}

.template-card-head h2 {
    margin-bottom: 8px;
}

.template-actions {
    flex: 0 0 auto;
}

.template-task-list {
    display: grid;
    gap: 10px;
}

.template-task-group,
.template-task-single {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--green);
    border-radius: 8px;
    background: #f7fbfa;
}

.template-task-child {
    margin-left: 18px;
    padding: 8px 0 8px 16px;
    border-left: 2px solid var(--line);
}

.template-task-child strong {
    font-size: 15px;
    font-weight: 700;
}

.template-task-note {
    margin-top: 4px;
}

.import-box {
    grid-column: 1 / -1;
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px dashed #abc2cc;
    border-radius: 8px;
    background: var(--surface-soft);
}

.import-box label {
    margin-bottom: 0;
}

.import-actions {
    justify-content: flex-start;
}

.import-box .muted {
    margin: 0;
}

.import-result {
    grid-column: 1 / -1;
}

.import-result-list {
    display: grid;
    gap: 8px;
    margin: 12px 0;
}

.import-result-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--green);
    border-radius: 8px;
    background: #fff;
}

.import-result-row.existing {
    border-left-color: #94a3b8;
}

.import-result-row.warning {
    border-left-color: var(--warn);
}

.import-result-row small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

.import-result-row span {
    color: var(--blue);
    font-weight: 800;
    white-space: nowrap;
}

.import-preview {
    display: grid;
    gap: 10px;
    margin: 12px 0;
}

.import-preview-row {
    display: grid;
    grid-template-columns: 130px minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--green);
    border-radius: 8px;
    background: #fff;
}

.import-preview-row.warning {
    border-left-color: var(--warn);
}

.import-preview-row.existing {
    border-left-color: #94a3b8;
}

.planning-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.planning-card {
    display: grid;
    gap: 12px;
}

.planning-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.planning-projects {
    display: grid;
    gap: 8px;
}

.planning-project {
    display: grid;
    gap: 4px;
    text-align: left;
    color: var(--text);
    background: var(--surface-soft);
    border-left: 4px solid #a8b5c0;
    box-shadow: none;
    white-space: normal;
}

.planning-project.green { border-left-color: var(--green); }
.planning-project.yellow { border-left-color: var(--warn); }
.planning-project.red { border-left-color: var(--danger); }
.planning-project.done {
    opacity: .72;
    background: #f3f7f9;
}
.planning-project.done strong {
    text-decoration: line-through;
    text-decoration-thickness: 1px;
}
.planning-project span {
    color: var(--muted);
    font-size: 12px;
}

.planning-overload {
    border-color: rgba(217, 70, 70, .45);
}

.project-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
}

.comment {
    border-top: 1px solid var(--line);
    padding: 10px 0;
}

::selection {
    background: rgba(24, 179, 136, .24);
}

.muted { color: var(--muted); }
.error { color: var(--danger); margin-top: 10px; }

dialog {
    width: min(760px, calc(100vw - 32px));
    border: 0;
    padding: 0;
}

dialog::backdrop { background: rgba(11, 35, 65, .35); }

#modalForm { padding: 18px; }
#modalBody {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
    margin-top: 14px;
}

#modalBody label:nth-child(2),
#modalBody label:nth-child(3),
#modalBody label:last-child {
    grid-column: 1 / -1;
}

#modalBody textarea {
    min-height: 96px;
}

.modal-head, .modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-actions {
    justify-content: flex-end;
    margin-top: 16px;
}

@media (max-width: 900px) {
    body { font-size: 14px; }
    .topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
        padding: 16px 14px;
        overflow: visible;
    }
    .brand {
        font-size: 18px;
    }
    .brand img {
        width: 138px;
    }
    nav {
        gap: 18px;
        padding-bottom: 6px;
        width: 100%;
        max-width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    nav button {
        padding: 7px 0 9px;
        min-height: 32px;
        flex: 0 1 auto;
        font-size: 12px;
    }
    .session-area {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }
    .current-user {
        white-space: normal;
    }
    .dashboard-grid, .two-col, .project-layout, .grid-5, .vacation-layout, .time-layout { grid-template-columns: minmax(0, 1fr); }
    .page {
        padding: 20px 14px;
        max-width: none;
        overflow: hidden;
    }
    .page-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 16px;
    }
    h1 {
        font-size: 24px;
        margin-bottom: 6px;
    }
    h1::before {
        width: 34px;
        margin-bottom: 10px;
    }
    h2 {
        font-size: 17px;
    }
    .card, .table-card { padding: 16px; }
    .table-card table {
        min-width: 620px;
    }
    .copy-row { flex-direction: column; }
    .stats { grid-template-columns: 1fr; }
    .stats span {
        margin-top: 4px;
    }
    .deadline-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }
    .deadline-stats > div {
        min-height: 64px;
        padding: 10px;
    }
    .deadline-stats strong {
        font-size: 24px;
    }
    .deadline-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
        align-items: start;
    }
    .deadline-row strong {
        padding-left: 18px;
    }
    .dashboard-task {
        grid-template-columns: minmax(0, 1fr);
        gap: 5px;
    }
    .dashboard-task small {
        white-space: normal;
    }
    .button-row {
        justify-content: flex-start;
        width: 100%;
    }
    .button-row button {
        flex: 1 1 auto;
    }
    .vacation-item {
        flex-direction: column;
    }
    .compact-buttons {
        flex-wrap: wrap;
    }
    #modalBody { grid-template-columns: 1fr; }
    .calendar-grid {
        display: grid;
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 1px;
        background: var(--line);
        border: 1px solid var(--line);
        border-radius: 8px;
        overflow: hidden;
    }
    .calendar-weekday {
        display: block;
        padding: 7px 2px;
        font-size: 12px;
    }
    .calendar-day {
        min-height: 92px;
        border: 0;
        margin-bottom: 0;
        border-radius: 0;
        padding: 5px;
        gap: 4px;
    }
    .calendar-date {
        font-size: 12px;
    }
    .calendar-controls {
        width: 100%;
        justify-content: space-between;
    }
    .calendar-event {
        padding: 4px 5px;
    }
    .calendar-event strong {
        font-size: 10px;
        line-height: 1.15;
        white-space: normal;
    }
    .calendar-event small {
        display: none;
    }
    .status-options {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }
    .status-options button {
        white-space: normal;
        width: 100%;
    }
    dialog {
        width: calc(100vw - 18px);
    }
    #modalForm {
        padding: 14px;
    }
}

@media (max-width: 560px) {
    .auth-shell {
        padding: 12px;
    }
    .auth-card {
        padding: 20px;
    }
    .page {
        padding: 14px 10px;
    }
    .card, .table-card {
        padding: 14px;
        border-radius: 4px;
    }
    input, select, textarea {
        min-width: 0;
    }
    .topbar {
        padding: 12px 10px;
    }
    .brand img {
        width: 132px;
    }
    nav {
        margin: 0;
        padding-left: 0;
        padding-right: 0;
        gap: 16px;
    }
    button {
        width: auto;
    }
    table {
        min-width: 0;
    }
    .table-card {
        overflow-x: visible;
    }
    .table-card thead {
        display: none;
    }
    .table-card table,
    .table-card tbody,
    .table-card tr,
    .table-card td {
        display: block;
        width: 100%;
    }
    .table-card tr {
        padding: 10px 0;
        border-bottom: 1px solid var(--line);
    }
    .table-card tr.empty-row {
        padding: 0;
    }
    .table-card td {
        display: grid;
        grid-template-columns: 104px minmax(0, 1fr);
        gap: 12px;
        align-items: center;
        padding: 7px 0;
        border-bottom: 0;
        min-width: 0;
        max-width: 100%;
    }
    .table-card td[data-label]::before {
        content: attr(data-label);
        display: block;
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
        letter-spacing: .02em;
    }
    .table-card td > * {
        min-width: 0;
        max-width: 100%;
    }
    .table-card .badge {
        display: inline-flex;
        justify-self: start;
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .table-card td button {
        justify-self: start;
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .table-card td[colspan] {
        display: block;
    }
    .toolbar {
        gap: 9px;
        padding: 10px;
    }
    .progress {
        width: auto;
        inline-size: auto;
        max-width: 100%;
        justify-self: stretch;
    }
    .table-card td .progress {
        width: auto;
        inline-size: auto;
        min-width: 0;
        max-width: 100%;
        justify-self: stretch;
        align-self: center;
    }
    .bar {
        overflow: hidden;
        white-space: nowrap;
    }
    .table-card td[data-label="Fortschritt"] {
        grid-template-columns: 104px minmax(0, calc(100% - 116px));
        overflow: hidden;
    }
    .table-card td[data-label="Fortschritt"] .progress {
        display: block;
        width: 100%;
        inline-size: 100%;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        justify-self: stretch;
    }
    #projectList.table-card {
        overflow-x: visible;
    }
    #projectList .desktop-table {
        display: none;
    }
    #projectList .mobile-project-list {
        display: grid;
        gap: 14px;
    }
    .mobile-project-card {
        display: grid;
        gap: 10px;
        padding: 14px 0;
        border-bottom: 1px solid var(--line);
    }
    .mobile-project-card:last-child {
        border-bottom: 0;
    }
    .project-card-row,
    .project-card-progress {
        display: grid;
        grid-template-columns: 104px minmax(0, 1fr);
        gap: 12px;
        align-items: center;
        min-width: 0;
        overflow: hidden;
    }
    .project-card-row > span,
    .project-card-progress > span {
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
        letter-spacing: .02em;
    }
    .project-card-row strong {
        min-width: 0;
        font-size: 15px;
        font-weight: 700;
        overflow-wrap: anywhere;
    }
    .project-card-progress .progress {
        width: 100%;
        inline-size: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
        justify-self: stretch;
    }
    .project-card-progress .bar {
        display: block;
        max-width: 100%;
    }
    .calendar-day {
        min-height: 78px;
        padding: 4px;
    }
    .calendar-controls {
        flex-wrap: wrap;
    }
    #calendarTitle {
        order: -1;
        width: 100%;
        font-size: 17px;
    }
}


/* Projektdateien und Konzeptvorbereitung */
.card-head-inline { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.card-head-inline h2 { margin-bottom:4px; }
.project-files-list { display:grid; gap:10px; margin-top:14px; }
.project-file-row { display:grid; grid-template-columns:52px minmax(0,1fr) auto; gap:12px; align-items:center; padding:12px; border:1px solid var(--line); border-radius:12px; background:rgba(255,255,255,.02); }
.project-file-icon { width:48px; height:48px; display:grid; place-items:center; border-radius:10px; background:var(--surface-2, #eef2f5); font-size:11px; font-weight:900; }
.project-file-main { min-width:0; display:grid; gap:3px; }
.project-file-main a { color:inherit; text-decoration:none; }
.project-file-main a:hover { text-decoration:underline; }
.concept-row { display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:12px; align-items:center; padding:14px 0; border-bottom:1px solid var(--line); }
.concept-row:last-child { border-bottom:0; }
@media (max-width: 760px) {
  .card-head-inline, .project-file-row { display:grid; grid-template-columns:1fr; }
  .project-file-icon { display:none; }
  .concept-row { grid-template-columns:1fr auto; }
  .concept-row button { grid-column:1 / -1; }
}
.tb-concept-head{max-width:1100px}.tb-detail-row{display:grid;grid-template-columns:42px 1fr auto;gap:14px;align-items:center;padding:14px 0;border-bottom:1px solid var(--border,#dfe5ea)}.tb-order{width:32px;height:32px;border-radius:50%;display:grid;place-items:center;background:#edf7f3;color:#14845f;font-weight:700}.tb-material-row{display:grid;grid-template-columns:60px 1.2fr .7fr .6fr 1.5fr 42px;gap:8px;margin-bottom:8px}.check-label{display:flex!important;align-items:center;gap:8px;padding-top:28px}.check-label input{width:auto}.report-page{page-break-after:always}.tb-report-images{display:grid;grid-template-columns:1fr 1fr;gap:12px}.tb-report-images img{max-width:100%;max-height:260px;object-fit:contain}.tb-report-table{width:100%;border-collapse:collapse}.tb-report-table th,.tb-report-table td{border:1px solid #555;padding:5px;vertical-align:top}@media(max-width:900px){.tb-material-row{grid-template-columns:50px 1fr}.tb-material-row input:nth-child(n+3){grid-column:span 1}.tb-detail-row{grid-template-columns:36px 1fr}.tb-detail-row .button-row{grid-column:2}}

/* Wärmebrückenkonzept – Phase 2 Hotfix */
.tb-building-card{margin-bottom:16px}.tb-building-card summary{display:flex;justify-content:space-between;gap:16px;cursor:pointer;list-style:none}.tb-building-card summary::-webkit-details-marker{display:none}.tb-details-body{padding-top:18px}.tb-details-body h3{margin:18px 0 8px}.tb-image-selects{align-items:start}.tb-file-preview{height:150px;border:1px dashed var(--line);border-radius:8px;margin-top:8px;display:grid;place-items:center;overflow:hidden;color:var(--muted);background:#fafcfd}.tb-file-preview img{max-width:100%;max-height:100%;object-fit:contain}.tb-material-head,.tb-material-row{display:grid;grid-template-columns:64px minmax(180px,1.2fr) 110px 130px minmax(240px,1.7fr) 44px;gap:8px;align-items:start}.tb-material-head{font-size:12px;font-weight:700;color:var(--muted);padding:0 0 6px}.tb-material-row textarea{min-height:58px;resize:vertical}.tb-detail-row .button-row{flex-wrap:nowrap}dialog:has(#tb-materials){width:min(1120px,calc(100vw - 32px));max-height:94vh}dialog:has(#tb-materials) #modalForm{max-height:94vh;overflow:auto}dialog:has(#tb-materials) #modalBody{display:block}dialog:has(#tb-materials) #modalBody>.grid-2,dialog:has(#tb-materials) #modalBody>.grid-3{margin-bottom:14px}
@media(max-width:900px){.tb-material-head{display:none}.tb-material-row{grid-template-columns:58px 1fr}.tb-material-row textarea,.tb-material-row button{grid-column:span 1}.tb-image-selects{grid-template-columns:1fr}.tb-building-card summary{display:block}}

/* Hott-Therm Dokumenteditor */
.td-page-list{display:flex;flex-direction:column;gap:8px;margin-top:14px}.td-page-row{display:grid;grid-template-columns:42px minmax(0,1fr) auto;align-items:center;gap:12px;padding:11px 12px;border:1px solid #dce4e8;border-radius:8px;background:#fff}.td-page-row.disabled{opacity:.55;background:#f5f7f8}.td-page-index{width:30px;height:30px;border-radius:50%;display:grid;place-items:center;background:#e8f8f1;color:#087a4b;font-weight:700}.td-page-main{min-width:0}.td-page-main strong{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.page-head.compact{margin-bottom:4px}.page-head.compact h2{margin:0}.check-row{display:flex!important;align-items:center;gap:8px}.check-row input{width:auto!important}
@media(max-width:800px){.td-page-row{grid-template-columns:36px 1fr}.td-page-row>.button-row{grid-column:1/-1;justify-content:flex-end}}

/* Phase 4: PDF-Seiteneditor mit Überlagerungen */
.td-overlay-editor{display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:18px;align-items:start}.td-overlay-stage{position:relative;width:min(100%,720px);aspect-ratio:210/297;margin:auto;background:#eef1f3;border:1px solid #cbd5da;box-shadow:0 5px 20px rgba(0,0,0,.12);overflow:hidden}.td-page-background{position:absolute;inset:0;width:100%;height:100%;border:0;background:#fff}.td-overlay-layer{position:absolute;inset:0;pointer-events:none}.td-overlay{position:absolute;box-sizing:border-box;overflow:hidden}.td-overlay-text{white-space:pre-wrap;line-height:1.2;font-weight:600;background:rgba(255,255,255,.72);padding:3px}.td-overlay-image{object-fit:contain}.td-overlay-line{height:0!important;border-top-style:solid;overflow:visible}.td-overlay-line.arrow:after{content:"";position:absolute;right:-1px;top:50%;width:10px;height:10px;border-top:inherit;border-right:inherit;transform:translateY(-50%) rotate(45deg)}.td-overlay-shape{border-style:solid}.td-overlay-shape.circle{border-radius:50%}.td-overlay-tools{position:sticky;top:12px;max-height:72vh;overflow:auto;border-left:1px solid #e0e5e8;padding-left:16px}.td-overlay-tools h3{margin:18px 0 8px}.td-element-list{display:flex;flex-direction:column;gap:7px}.td-element-list>div{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:8px;border:1px solid #dce4e8;border-radius:7px;background:#fff}.td-element-list>div>span:first-child{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.td-element-list button{padding:5px 8px}.button-row.wrap{flex-wrap:wrap}
@media(max-width:1000px){.td-overlay-editor{grid-template-columns:1fr}.td-overlay-tools{position:static;max-height:none;border-left:0;border-top:1px solid #e0e5e8;padding:14px 0 0}}
