/* PortPiloten – mobil-først stylesheet. Primærfarve #123274. */
:root {
    --primary: #123274;
    --primary-dark: #0d2455;
    --primary-tint: #e8ecf5;
    --bg: #f4f5f8;
    --card: #ffffff;
    --ink: #1c2333;
    --muted: #667085;
    --border: #d9dee8;
    --ok: #1e7a3c;
    --ok-tint: #e2f2e7;
    --warn: #92610a;
    --warn-tint: #fdf0d8;
    --err: #b3261e;
    --err-tint: #fde8e7;
    --info-tint: #e3edf6;
    --progress-tint: #dbe7f7;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(18, 50, 116, .12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

h1 { font-size: 1.5rem; margin: .4em 0; }
h2 { font-size: 1.1rem; margin: .2em 0 .6em; }
a { color: var(--primary); }

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .6rem .9rem;
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow);
}
.brand { font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.header-user { display: flex; align-items: center; gap: .5rem; }
.user-chip { font-size: .8rem; opacity: .85; }
.logout-form { margin: 0; }

/* Bottom-friendly nav */
.app-nav {
    display: flex;
    gap: .25rem;
    overflow-x: auto;
    padding: .4rem .5rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 48px;
    z-index: 9;
}
.app-nav a {
    flex: 0 0 auto;
    padding: .55rem .9rem;
    border-radius: 999px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
}
.app-nav a.active { background: var(--primary-tint); color: var(--primary); }

.app-main { padding: .8rem .9rem 4rem; max-width: 780px; margin: 0 auto; }

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin: .8rem 0;
    box-shadow: var(--shadow);
}
.card-warn { border-left: 5px solid var(--warn); background: var(--warn-tint); }
.card-info { border-left: 5px solid var(--primary); background: var(--info-tint); }

/* Stat grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
    margin: .8rem 0;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .9rem;
    text-decoration: none;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    box-shadow: var(--shadow);
}
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .85rem; color: var(--muted); }

/* Lists */
.item-list { list-style: none; margin: 0; padding: 0; }
.item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .8rem .2rem;
    border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-main { display: flex; flex-direction: column; gap: .15rem; text-decoration: none; color: var(--ink); min-width: 0; }
.row-urgent { border-left: 4px solid var(--err); padding-left: .6rem; }
.row-overdue { border-left: 4px solid var(--warn); padding-left: .6rem; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.activity-list li:last-child { border-bottom: none; }

/* Badges */
.badge {
    display: inline-block;
    padding: .3rem .65rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-new { background: var(--primary-tint); color: var(--primary); }
.badge-info { background: var(--info-tint); color: var(--primary); }
.badge-progress { background: var(--progress-tint); color: var(--primary-dark); }
.badge-warn { background: var(--warn-tint); color: var(--warn); }
.badge-ok { background: var(--ok-tint); color: var(--ok); }
.badge-muted { background: #eef0f4; color: var(--muted); }

/* Buttons – large touch targets */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: .6rem 1.2rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: var(--primary-tint); color: var(--primary); }
.btn-ghost { background: transparent; color: inherit; border-color: currentColor; opacity: .85; }
.btn-block { width: 100%; }
.btn-block + .btn-block { margin-top: .5rem; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: .35rem; }
.stack label { font-weight: 600; font-size: .9rem; margin-top: .6rem; }
.stack input, .stack select, .stack textarea {
    width: 100%;
    min-height: 48px;
    padding: .6rem .75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--ink);
}
.stack textarea { min-height: 96px; resize: vertical; }
.stack input:focus, .stack select:focus, .stack textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}
.form-narrow { max-width: 460px; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: .8rem; }

/* Definition lists */
.def-list { display: grid; grid-template-columns: 40% 60%; gap: .35rem .6rem; margin: 0; }
.def-list dt { color: var(--muted); font-size: .9rem; }
.def-list dd { margin: 0; overflow-wrap: anywhere; }

/* Banners */
.banner {
    padding: .7rem .9rem;
    border-radius: 10px;
    margin: .6rem 0;
    font-weight: 500;
}
.banner-error { background: var(--err-tint); color: var(--err); }
.banner-ok { background: var(--ok-tint); color: var(--ok); }

/* Sticky action bar (one-hand reach) */
.sticky-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: .7rem .9rem calc(.7rem + env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(18, 50, 116, .08);
}

/* Login */
.login-body {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    padding: 1rem;
}
.login-card {
    background: var(--card);
    border-radius: 16px;
    padding: 1.6rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.login-brand { color: var(--primary); margin: 0; font-size: 1.8rem; }
.login-sub { color: var(--muted); margin: .2rem 0 1rem; font-size: .9rem; }

/* Error pages */
.error-box {
    max-width: 420px;
    margin: 15vh auto;
    padding: 1.5rem;
    background: var(--card);
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}

.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* Notes on work orders */
.note-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.note-item { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.note-item:last-child { border-bottom: none; }
.note-item p { margin: .35rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.inline-form { margin: 0; }
.inline-form .btn { min-height: 40px; padding: .3rem .8rem; font-size: .85rem; }

/* Field documentation: checklist, photos, measurements */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist-item {
    display: grid;
    grid-template-columns: 1.4fr auto 1fr;
    gap: .5rem;
    align-items: center;
    padding: .55rem 0;
    border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-label { font-size: .92rem; }
.check-status, .check-notes {
    min-height: 44px;
    padding: .4rem .5rem;
    font-size: .9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
    width: 100%;
}
.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
}
.photo-item { margin: 0; }
.photo-item img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: block;
}
.photo-item figcaption {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    padding: .3rem 0;
    font-size: .8rem;
}
.row-actions { display: flex; align-items: center; gap: .5rem; }
audio { width: 100%; max-width: 320px; }

@media (min-width: 720px) {
    .photo-grid { grid-template-columns: repeat(4, 1fr); }
    .checklist-item { grid-template-columns: 2fr auto 1.5fr; }
}

/* Desktop refinements */
@media (min-width: 720px) {
    .app-nav { top: 54px; }
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
    .app-main { padding-top: 1.2rem; }
}
