/* Interner Bereich – gleiche Gestaltung wie die Website (Inter, Akzent #b22222, helles Layout). */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #fafafa; --card: #fff; --alt: #f4f4f6;
  --ink: #17181c; --muted: #686c74; --line: #e6e7ea;
  --accent: #b22222; --accent-dark: #8f1b1b;
  --danger: #b3261e; --success: #2f7d4f;
  --radius: 10px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px rgba(10, 10, 13, 0.05);
  --shadow-md: 0 18px 40px -12px rgba(10, 10, 13, 0.18), 0 4px 10px -4px rgba(10, 10, 13, 0.06);
  --font: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss03";
}
::selection { background: var(--accent); color: #fff; }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: 1.25rem; margin: 0; }
h2 { margin: 0 0 1rem; font-size: 1.25rem; }
h3 { margin: 1.25rem 0 .75rem; font-size: 1rem; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

/* ---- Kopfzeile wie auf der Website ---- */
.top { background: rgba(250, 250, 250, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-inner { max-width: 1160px; margin: 0 auto; padding: 14px 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; text-decoration: none; line-height: 1.3; }
.brand:hover { color: var(--ink); }
.brand img { width: 34px; height: 34px; flex-shrink: 0; }
.brand-name-full, .brand-name-sub { display: block; }
.brand-name-sub { font-size: .62rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-top: 1px; }
.area { padding-left: 1rem; border-left: 1px solid var(--line); display: flex; align-items: center; gap: .5rem; }
.area .back { text-decoration: none; color: var(--muted); }
.area .back:hover { color: var(--accent); }
.top-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.top-actions form { margin: 0; }

main { max-width: 1160px; margin: 0 auto; padding: 1.5rem 1rem 3rem; display: grid; gap: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow-sm); }

/* ---- Bedienelemente ---- */
button, .button, input, select, textarea {
  font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: .55rem .75rem;
}
button, .button {
  cursor: pointer; text-decoration: none; display: inline-block; font-weight: 600; font-size: .95rem;
  border-radius: 999px; padding: .55rem 1.2rem; border: 2px solid var(--line); color: var(--ink);
  transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
button:hover, .button:hover { border-color: var(--ink); color: var(--ink); }
button:active, .button:active { transform: scale(.97); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 8px 20px -8px rgba(178, 34, 34, .6); }
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; transform: translateY(-1px); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.danger:hover { background: var(--danger); color: #fff; }
button.small { padding: .2rem .8rem; font-size: .85rem; border-width: 1px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(178, 34, 34, .15); }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: grid; gap: .25rem; font-size: .85rem; color: var(--muted); font-weight: 500; }
label input, label select, label textarea { color: var(--ink); width: 100%; font-weight: 400; }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--ink); }
label.check input { width: auto; accent-color: var(--accent); }
input[readonly] { background: var(--alt); }
.error { color: var(--danger); margin: 0 0 .75rem; }
.ok { color: var(--success); margin: 0 0 .75rem; font-weight: 600; }
.muted { color: var(--muted); padding: 1rem; margin: 0; }

/* ---- Fahrtenbuch ---- */
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.filters label { min-width: 120px; }
.filters .button { margin-left: auto; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1.1rem; display: grid; box-shadow: var(--shadow-sm); border-top: 3px solid var(--accent); }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; color: var(--muted); font-weight: 600; white-space: nowrap; text-transform: uppercase; letter-spacing: .06em; background: var(--alt); }
tbody tr:hover { background: var(--alt); }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); padding: 1.5rem; width: min(640px, calc(100vw - 1.5rem)); box-shadow: var(--shadow-md); }
dialog::backdrop { background: rgba(10, 10, 13, .55); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grid .wide { grid-column: 1 / -1; }
.dlg-actions { display: flex; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap; }
.spacer { flex: 1; }

.veh-list { list-style: none; margin: 0 0 .5rem; padding: 0; display: grid; gap: .5rem; }
.veh-list li { display: flex; align-items: center; gap: .75rem; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .85rem; background: var(--alt); }
.veh-list .info { flex: 1; }
.veh-list .info small { display: block; color: var(--muted); }
.veh-list li.inactive { opacity: .55; }

/* ---- Login & Übersicht ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; max-width: none; }
.login .card { width: min(380px, 100%); display: grid; gap: 1rem; padding: 1.75rem; box-shadow: var(--shadow-md); }
.login .brand { justify-content: center; margin-bottom: .25rem; }
.login h1 { text-align: center; font-size: 1.1rem; color: var(--muted); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.tile { display: grid; gap: .35rem; text-decoration: none; color: inherit; border-top: 3px solid var(--accent); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.tile:hover { color: inherit; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.tile strong { font-size: 1.1rem; }
.tile span { color: var(--muted); font-size: .9rem; }

.pw-card { max-width: 480px; }
.pw-form { display: grid; gap: .75rem; }

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .filters .button { margin-left: 0; }
  .area { border-left: 0; padding-left: 0; width: 100%; }
}

/* ==========================================================================
   Geräte-Anpassung: iPhone, iPad, Desktop
   ========================================================================== */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
.center { text-align: center; }
code { background: var(--alt); padding: 0 .3rem; border-radius: 4px; word-break: break-all; }

/* Notch / Home-Indikator (Vollbild als Web-App) */
.top { padding-top: env(safe-area-inset-top); }
.top-inner { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
main { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); padding-bottom: calc(3rem + env(safe-area-inset-bottom)); }

/* Touch-Geräte (iPhone/iPad): große Tippflächen, keine Hover-Effekte */
@media (pointer: coarse) {
  button, .button, input:not([type=checkbox]), select, textarea { min-height: 44px; }
  button.small { min-height: 36px; padding-left: 1rem; padding-right: 1rem; }
  input[type=checkbox] { width: 22px; height: 22px; }
  label.check { min-height: 44px; }
}
@media (hover: none) {
  .tile:hover { transform: none; box-shadow: var(--shadow-sm); }
  tbody tr:hover { background: transparent; }
  button:hover, .button:hover { border-color: var(--line); }
  button.primary:hover { transform: none; background: var(--accent); border-color: var(--accent); }
}
/* iOS zoomt in Felder unter 16 px hinein */
@media (max-width: 1024px) { input, select, textarea { font-size: 16px; } }

/* iPad & kleine Fenster */
@media (max-width: 900px) {
  .filters label { flex: 1 1 140px; }
  .filters .button { margin-left: 0; }
}

/* iPhone: Tabellen als Karten, Dialoge als Vollbild, Aktionen in eigener Zeile */
@media (max-width: 700px) {
  .top-inner { gap: .5rem .75rem; padding-top: 10px; padding-bottom: 10px; }
  .top-actions { margin-left: 0; width: 100%; }
  .top-actions > * { flex: 1 1 auto; }
  .top-actions form { display: flex; }
  .top-actions form button { flex: 1; }
  main { padding-top: 1rem; }
  .card { padding: 1rem; }
  .tabs { position: sticky; top: 0; }

  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
  table.responsive tr:last-child { border-bottom: 0; }
  table.responsive td { border: 0; padding: .15rem 0; text-align: left; white-space: normal; display: flex; justify-content: space-between; gap: 1rem; }
  table.responsive td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .8rem; flex: 0 0 38%; max-width: 38%; }
  table.responsive td.num { text-align: right; }
  table.responsive td:empty { display: none; }
  table.responsive td.actions { justify-content: flex-end; padding-top: .5rem; }
  .table-wrap { overflow: visible; }

  dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; border-radius: 0;
           padding: calc(1rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left)); overflow-y: auto; }
  .dlg-actions { position: sticky; bottom: 0; background: var(--card); margin: 1rem -1rem 0; padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .dlg-actions button { flex: 1 1 auto; }
  .dlg-actions .spacer { display: none; }
  .tile { padding: 1rem; }
}
@media (display-mode: standalone) { body { user-select: none; -webkit-user-select: none; } input, textarea, select { user-select: text; -webkit-user-select: text; } }

/* ==========================================================================
   Projektverwaltung
   ========================================================================== */
.mainnav { max-width: 1160px; margin: 0 auto; padding: .75rem max(1rem, env(safe-area-inset-left)) 0; display: flex; gap: .5rem; }
.nav-btn, .tab { border-width: 1px; }
.nav-btn { flex: 0 0 auto; }
.nav-btn.active, .tab.active { background: #131418; border-color: #131418; color: #fff; }
.nav-btn.active:hover, .tab.active:hover { color: #fff; }
.tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin: .25rem 0 1rem; }
.toolbar { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input[type=search] { flex: 1 1 260px; }
label.inline { display: grid; gap: .15rem; }
label.inline.check { display: flex; align-items: center; gap: .5rem; padding-bottom: .4rem; color: var(--ink); }
.project-bar { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; border-left: 3px solid var(--accent); }
.project-bar .grow { flex: 1 1 280px; }
.project-bar select { font-weight: 600; }
.project-actions { display: flex; gap: .5rem; }
#view-project > .muted-text { margin: .5rem 0 .75rem; }
.muted-text a { color: var(--accent); }
.inset { background: var(--alt); box-shadow: none; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 1rem 0; }
.dlg-actions.wrap { flex-wrap: wrap; }
.button.disabled, button:disabled { opacity: .45; pointer-events: none; }
tr.dim { opacity: .55; }
td.strong { font-weight: 600; }
td.actions { white-space: nowrap; display: table-cell; }
td.actions .small { margin-left: .25rem; }

.badge { display: inline-block; padding: .05rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--alt); color: var(--muted); }
.badge.active { background: rgba(47, 125, 79, .12); color: var(--success); }
.badge.onHold { background: rgba(200, 140, 0, .14); color: #8a6100; }
.badge.done { background: rgba(60, 110, 200, .12); color: #2d5aa8; }
.badge.late { background: rgba(179, 38, 30, .12); color: var(--danger); margin-top: .35rem; }
.bar { height: 8px; border-radius: 999px; background: var(--alt); overflow: hidden; min-width: 120px; margin-top: .25rem; }
.bar > i { display: block; height: 100%; background: var(--success); }
.bar.warn > i { background: #c88c00; }
.bar.over > i { background: var(--danger); }

/* Kanban-Board */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.column { background: var(--alt); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; min-height: 160px; transition: background .15s, border-color .15s; }
.column.over { border-color: var(--accent); background: rgba(178, 34, 34, .05); }
.column h3 { margin: 0 0 .75rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; }
.column .count { background: var(--card); border-radius: 999px; padding: 0 .55rem; color: var(--ink); }
.cards { display: grid; gap: .6rem; min-height: 60px; }
.card-task { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .75rem; box-shadow: var(--shadow-sm); cursor: grab; display: grid; gap: .25rem; }
.card-task.dragging { opacity: .4; }
.card-task.milestone { border-left: 3px solid var(--accent); }
.card-task strong { overflow-wrap: anywhere; }
.card-task small { display: block; }
.card-actions { display: flex; gap: .35rem; justify-content: flex-end; margin-top: .35rem; }

/* Zeitplan (Gantt) */
.gantt-card { padding: 0; overflow: hidden; }
.gantt { display: flex; overflow: auto; max-height: 70vh; position: relative; -webkit-overflow-scrolling: touch; }
.g-labels { position: sticky; left: 0; z-index: 3; width: min(220px, 38vw); flex: 0 0 auto; background: var(--card); border-right: 1px solid var(--line); }
.g-head { background: var(--alt); border-bottom: 1px solid var(--line); position: relative; }
.g-label { padding: 0 .75rem; display: flex; align-items: center; border-bottom: 1px solid var(--line); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; font-size: .9rem; }
.g-label.done { color: var(--muted); text-decoration: line-through; }
.g-body { position: relative; flex: 0 0 auto; }
.g-tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); padding: 4px 4px 0; font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; white-space: nowrap; }
.g-top { font-weight: 600; color: var(--ink); }
.g-rows { position: relative; background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 39px, var(--line) 39px, var(--line) 40px); }
.g-deps { position: absolute; left: 0; top: 46px; pointer-events: none; z-index: 1; }
.g-deps .dep { fill: none; stroke: #686c74; stroke-width: 1.2; }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .7; z-index: 1; pointer-events: none; }
.g-bar { position: absolute; z-index: 2; border-radius: 6px; background: #8d96a8; color: #fff; font-size: .78rem; display: flex; align-items: center; padding: 0 .5rem; overflow: hidden; white-space: nowrap; cursor: grab; touch-action: none; box-shadow: var(--shadow-sm); user-select: none; -webkit-user-select: none; }
.g-bar::before, .g-bar::after { content: ""; position: absolute; top: 0; bottom: 0; width: 9px; cursor: ew-resize; }
.g-bar::before { left: 0; } .g-bar::after { right: 0; }
.g-bar.s-doing { background: var(--accent); }
.g-bar.s-done { background: var(--success); }
.g-bar.ms { background: #131418; transform: rotate(45deg) scale(.7); border-radius: 3px; cursor: pointer; }
.g-bar.ms::before, .g-bar.ms::after { display: none; }
.g-bar.dragging { opacity: .8; cursor: grabbing; z-index: 5; }

@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
  .mainnav { padding-top: .5rem; overflow-x: auto; }
  .nav-btn { flex: 1 1 0; }
  .project-actions { width: 100%; }
  .project-actions button { flex: 1; }
  .toolbar > * { flex: 1 1 100%; }
  .toolbar > button { flex: 1 1 auto; }
  td.actions { display: flex; flex-wrap: wrap; gap: .35rem; }
  td.actions .small { margin-left: 0; flex: 1 1 auto; }
}

.tab .count { background: rgba(10, 10, 13, .08); border-radius: 999px; padding: 0 .5rem; margin-left: .25rem; font-size: .78rem; }
.tab.active .count { background: rgba(255, 255, 255, .22); }
#acc-dlg .pw-form { padding-bottom: 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
#acc-dlg h3 { margin-top: 0; }
.msg { margin: 0; }

/* Passcode / Login */
.code-input { font-size: 1.6rem !important; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; }
.login.wide-login .card { width: min(560px, 100%); }
.totp-box { display: grid; gap: 1rem; }
.totp-box .steps { margin: 0; padding-left: 1.25rem; display: grid; gap: 1rem; }
.totp-box .qr { width: 200px; max-width: 60%; background: #fff; padding: 6px; border: 1px solid var(--line); border-radius: 8px; margin: .5rem 0; }
.totp-box .qr svg { display: block; width: 100%; height: auto; }
.totp-box .totp-key { display: inline-block; letter-spacing: .08em; user-select: all; -webkit-user-select: all; }
.totp-box .totp-code { display: block; margin-top: .5rem; font-size: 1.4rem; letter-spacing: .2em; text-align: center; max-width: 12rem; }
.codes { background: var(--alt); border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem; font: 600 1rem/1.7 ui-monospace, "SF Mono", Menlo, monospace; columns: 2; margin: 0; user-select: all; -webkit-user-select: all; }
.acc-totp-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
#acc-dlg { max-height: 92dvh; overflow-y: auto; }

.total-km { margin: 0; padding: .5rem .75rem; background: var(--alt); border-radius: 8px; font-weight: 600; }
