* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-family, Arial, sans-serif);
    background: var(--background);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 32px 24px;
}

.user-agent {
    max-width: 300px;
    word-break: break-word;
    font-size: 0.85rem;
}

.audit-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    background: #f3f4f6;
    color: #374151;
}

.audit-created {
    background: #dcfce7;
    color: #166534;
}

.audit-updated {
    background: #dbeafe;
    color: #1d4ed8;
}

.audit-deleted {
    background: #fee2e2;
    color: #b91c1c;
}

.audit-login {
    background: #f3f4f6;
    color: #4b5563;
}

.audit-error {
    background: #ffedd5;
    color: #c2410c;
}

/* Header/navigation */

.site-header {
    background: var(--header-background);
    color: white;
    position: sticky;
    top: 0;
    z-index: 1000;

    backdrop-filter: blur(8px);    
}

.site-nav {
    width: min(96vw, 1700px);
    margin: 0 auto;
    padding: 26px 32px;

    display: flex;
    align-items: center;
    gap: 28px;
}

.site-brand {
    color: white;
    font-size: 1.6rem;
    font-weight: 700;
    white-space: nowrap;
}

.site-nav-links {
    flex: 1;
    display: flex;
    justify-content: center;
    gap: clamp(18px, 2vw, 34px);
}

.site-nav-links a {
    color: white;
    font-size: 1.05rem;
    font-weight: 700;
}

.site-nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Hero */

.hero {
    min-height: 430px;
    background:
        linear-gradient(rgba(0,0,0,0.45), rgba(0,0,0,0.45)),
        url("/assets/images/hero.jpg");
    background-size: cover;
    background-position: center;
    color: white;
    display: flex;
    align-items: center;
}

.hero-content {
    max-width: 1180px;
    margin: 0 auto;
    padding: 80px 24px;
}

.hero h1 {
    font-size: 3.4rem;
    margin: 0 0 16px;
}

.hero p {
    max-width: 620px;
    font-size: 1.25rem;
    line-height: 1.6;
}

/* Content */

.page-title {
    margin-top: 0;
}

.card {
    background: var(--surface);
    border-radius: 14px;
    padding: 26px;
    margin-bottom: 22px;
    box-shadow: var(--card-shadow);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}

.card h2,
.card h3 {
    margin-top: 0;
}

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

/* Forms */

form {
    margin-top: 16px;
}

.form-help {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.4;
}

.contact-honeypot {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
}

label {
    display: block;
    margin-bottom: 16px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    max-width: 420px;
    padding: 10px 12px;
    margin-top: 6px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--input-background);
    color: var(--input-text);
}

textarea {
    max-width: 760px;
    min-height: 120px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
}

button,
.button {
    display: inline-block;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 700;
}

button:hover,
.button:hover {
    opacity: 0.92;
    text-decoration: none;
}

.button-small {
    padding: 8px 12px;
    font-size: 0.9rem;
}

.button-light {
    background: var(--button-light-background);
    color: var(--button-light-text);
}

.button-secondary {
    background: #4b5563;
}

.button-danger {
    background: #dc2626;
}

.alert-error {
    color: #991b1b;
    background: #fee2e2;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert-success {
    color: #166534;
    background: #dcfce7;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.deadline-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
}

.deadline-overdue {
    background: #fee2e2;
    color: #b91c1c;
}

.deadline-urgent {
    background: #fef3c7;
    color: #92400e;
}

.deadline-upcoming {
    background: #dbeafe;
    color: #1d4ed8;
}

.deadline-ok {
    background: #dcfce7;
    color: #166534;
}

.card-list-scroll {
    max-height: 320px;
    margin-top: 16px;
    overflow-y: auto;
}

.card-list-scroll table {
    margin: 0;
}

.card-list-scroll th {
    position: sticky;
    top: 0;
    background: var(--surface);
}

.card-list-item {
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-list-item:last-child {
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: 0;
}

/* Tables */

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

th,
td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--surface-muted);
    font-weight: 700;
}

tr:hover td {
    background: var(--surface-muted);
}

.public-documents-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.public-documents-table th:nth-child(1) {
    width: 22%;
}

.public-documents-table th:nth-child(2) {
    width: 28%;
}

.public-documents-table th:nth-child(3) {
    width: 18%;
}

.public-documents-table th:nth-child(4) {
    width: 9%;
    text-align: right;
}

.public-documents-table th:nth-child(5) {
    width: 11%;
    text-align: center;
}

.public-documents-table th:nth-child(6) {
    width: 12%;
    text-align: right;
}

.public-documents-table td:nth-child(4) {
    text-align: right;
}

.public-documents-table td:nth-child(5) {
    text-align: center;
}

.public-documents-table td:nth-child(6) {
    text-align: right;
}

.public-documents-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.public-documents-table .document-description {
    width: auto;
    max-width: none;
}

.document-title-preview,
.document-description-preview,
.document-filename-preview {
    display: block;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    cursor: help;
}

.public-documents-table-wrapper {
    width: 100%;
    overflow-x: auto;
}

@media (max-width: 850px) {
    .public-documents-table {
        min-width: 900px;
    }
}

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

.admin-header {
    background: var(--admin-header-background);
    color: white;
    padding: 40px 0;
}

.admin-header h1 {
    margin: 0 0 10px;
}

.admin-header p {
    margin: 0;
    opacity: 0.9;
}

.admin-links {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.admin-links a {
    color: white;
    font-weight: 700;
    text-decoration: none;
}

.admin-links a:hover {
    text-decoration: underline;
}

/* Footer */

.site-footer {
    background: var(--footer);
    color: white;
    margin-top: 48px;
}

.site-footer p {
    margin: 6px 0;
    color: rgba(255,255,255,0.82);
}

.footer-grid {
    display: flex;
    justify-content: space-between;
    gap: 24px;
}

/* Password fields */
.password-field {
    display: flex;
    align-items: stretch;
    max-width: 420px;
}

.password-field input[type="password"],
.password-field input[type="text"] {
    flex: 1;
    max-width: none;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    color: var(--input-text);
    background-color: var(--input-background);
    -webkit-text-fill-color: var(--input-text);
}

.password-toggle-button {
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--input-border);
    border-left: 0;
    border-radius: 0 8px 8px 0;
    background: var(--surface-muted);
    color: var(--text);
    cursor: pointer;
    font-size: 0.95rem;
}

.password-toggle-button:hover {
    background: var(--border);
    color: var(--text);
}

.password-toggle-button:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Utilities */

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.sub-hero {
    min-height: 260px;
    background:
        linear-gradient(rgba(0,0,0,0.48), rgba(0,0,0,0.48)),
        url("/assets/images/hero.jpg");
    background-size: cover;
    background-position: center;
    color: white;
    display: flex;
    align-items: center;
}

.sub-hero-content {
    max-width: 1180px;
    margin: 0 auto;
    padding: 56px 24px;
    width: 100%;
}

.sub-hero h1 {
    font-size: 2.6rem;
    margin: 0 0 10px;
    overflow-wrap: break-word;
}

.sub-hero p {
    font-size: 1.15rem;
    margin: 0;
    max-width: 620px;
    overflow-wrap: break-word;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.inline-form {
    display: inline;
}

/* ===== Security recommendation ===== */

.security-recommendation {
    border-left: 6px solid #f59e0b;
}

.security-recommendation h2 {
    margin-top: 0;
    margin-bottom: 12px;
}

.security-recommendation p {
    margin-bottom: 12px;
}

.security-recommendation .button {
    margin-top: 6px;
}

.security-recommendation .button {
    background: #f59e0b;
    color: white;
    margin-top: 6px;
}

.security-recommendation .button:hover {
    background: #d97706;
    opacity: 1;
}

/* ===== GDPR profilepage ===== */
.gdpr-consent .checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.gdpr-consent .checkbox-label input[type="checkbox"] {
    width: auto;
    margin-top: 3px;
    flex-shrink: 0;
}

.gdpr-consent .checkbox-label span {
    display: block;
}

/* ===== Startsida ===== */

.frontpage-grid {
    display: grid;
    grid-template-columns: 25% 50% 25%;
    gap: 24px;
    align-items: start;
    margin-bottom: 24px;
}

.frontpage-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.frontpage-photos {
    margin-top: 24px;
}

.frontpage-section {
    margin-bottom: 24px;
}

.frontpage-section:last-child {
    margin-bottom: 0;
}

.frontpage-section h2 {
    margin-top: 0;
}

.frontpage .card {
    padding: 20px;
}

.frontpage {
    font-size: 0.95rem;
}

.frontpage h2 {
    font-size: 1.4rem;
}

.frontpage h3 {
    font-size: 1.1rem;
}

.frontpage p,
.frontpage li,
.frontpage a {
    font-size: 0.95rem;
    line-height: 1.5;
}

.frontpage-contact-item {
    font-size: 0.92rem;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.frontpage-contact-item h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    line-height: 1.25;
}

.frontpage-contact-item p {
    margin: 2px 0;
    line-height: 1.35;
}

.frontpage-contact-item p:first-of-type {
    margin-top: 0;
}

.frontpage-contact-item p:last-child {
    margin-bottom: 0;
}

.frontpage-contact-item:last-child {
    border-bottom: none;
}

.frontpage-contact-line {
    margin: 0;
}

.frontpage-contact-line + .frontpage-contact-line {
    margin-top: 0;
}

.frontpage-links {
    list-style: none;
    padding-left: 0;
}

.frontpage-links li {
    margin-bottom: 8px;
}

.frontpage-links a {
    text-decoration: none;
}

.frontpage-links a:hover {
    text-decoration: underline;
}

.frontpage-list-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.frontpage-list-table td {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.frontpage-list-table td:first-child {
    width: 90px;
    white-space: nowrap;
    color: var(--muted);
    padding-right: 16px;
}

.frontpage-list-table td:last-child {
    width: auto;
}

.frontpage-list-table tr:last-child td {
    border-bottom: none;
}

/* Google Maps */

.frontpage-map {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 300px;
    overflow: hidden;
    border-radius: 12px;
}

.frontpage-map iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.code-example {
    max-width: 760px;
    font-family: Consolas, monospace;
    background: var(--surface-muted);
    color: var(--text);
}

/* Photos Frontpage */

.frontpage-photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.frontpage-photo-grid img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: 10px;
}

.frontpage-carousel {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    border-radius: 12px;
    background: var(--surface-muted);
}

.frontpage-carousel-track {
    position: relative;
    width: 100%;
    height: 100%;
}

.frontpage-carousel-slide {
    display: none;
    position: relative;
    width: 100%;
    height: 100%;
}

.frontpage-carousel-slide.active {
    display: block;
}

.frontpage-carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 12px;
}

.frontpage-carousel-caption {
    position: absolute;
    left: 16px;
    bottom: 16px;
    background: rgba(17, 24, 39, 0.75);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 700;
}

.frontpage-carousel-button {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border-radius: 999px;
    font-size: 2rem;
    line-height: 1;
    padding: 0;
    background: rgba(17, 24, 39, 0.72);
}

.frontpage-carousel-prev {
    left: 14px;
}

.frontpage-carousel-next {
    right: 14px;
}

/* Information pages */

.info-page-layout {
    display: block;
}

.info-page-image {
    margin-bottom: 20px;
}

.info-page-image img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 12px;
}

.info-page-content {
    min-width: 0;
}

/* ==============================
   Expandable cards
   ============================== */

.expandable-card {
    cursor: pointer;
    transition: all .2s ease;
}

.expandable-card:hover {
    transform: translateY(-2px);
}

.expandable-content {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.expandable-card.active .expandable-content {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
    line-clamp: unset;
}

.expandable-card.active {
    border-left: 4px solid #2563eb;
}

.demo-mode-banner {
    padding: 12px 20px;
    border-bottom: 1px solid #f59e0b;
    background: #fef3c7;
    color: #78350f;
    font-weight: 700;
    text-align: center;
}

.board-broadcast-banner {
    padding: 12px 20px;
    border-bottom: 1px solid #2563eb;
    background: #dbeafe;
    color: #1e3a8a;
}

.board-broadcast-banner strong {
    display: block;
}

.board-broadcast-banner p {
    margin: 4px 0 0;
}

.mfa-reminder-banner {
    padding: 12px 20px;
    border-bottom: 1px solid #f59e0b;
    background: #fef3c7;
    color: #78350f;
    text-align: center;
}

.mfa-reminder-banner a {
    color: #78350f;
    font-weight: 700;
    text-decoration: underline;
}

/* ==============================
   Clickable rows in lists and tables
   ============================== */
.clickable-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.clickable-row:hover {
    background-color: color-mix(
        in srgb,
        currentColor 6%,
        transparent
    );
}

.clickable-row:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

/* ==============================
   Global themes
   ============================== */
.noticeboard-refresh-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Kalender: månadsraster */

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.calendar-nav h2 {
    margin: 0;
}

.calendar-grid-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 22px;
}

.calendar-grid-header,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.calendar-grid-header {
    margin-bottom: 6px;
}

.calendar-grid-header span {
    padding: 4px 6px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}

.calendar-day {
    /* Utan min-width: 0 vägrar rutan krympa under den omöjliga
       nowrap-titelns egen bredd - hela griddkolumnen blir då bredare
       än de andra istället för att titeln trunkeras med ellipsis
       (gäller alla skärmstorlekar, inte bara mobil). */
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    min-height: 76px;
    box-shadow: var(--card-shadow);
}

.calendar-day-number {
    font-weight: 700;
    font-size: 0.9rem;
}

.calendar-day.is-other-month {
    background: var(--surface-muted);
    opacity: 0.6;
}

.calendar-day.is-today {
    border: 2px solid var(--primary);
}

.calendar-day-indicator {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 0.75rem;
}

.calendar-day.has-events .calendar-day-indicator {
    background: var(--primary);
    color: var(--surface);
}

.calendar-day-event-title {
    display: block;
    margin-top: 6px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    cursor: help;
}

/* Klickbar variant (admin) - länken har redan en tydlig pekare, till
   skillnad från den rena informationstexten icke-admins ser ovan. */
a.calendar-day-event-title {
    cursor: pointer;
}

.calendar-day-create-link {
    cursor: pointer;
}

.calendar-day-events {
    margin-top: 6px;
}

.calendar-day-events summary {
    list-style: none;
}

.calendar-day-events summary::-webkit-details-marker {
    display: none;
}

.calendar-day-events summary::after {
    content: ' \25BE';
}

.calendar-day-events ul {
    margin: 6px 0 0;
    padding-left: 16px;
    font-size: 0.8rem;
    list-style: disc;
}

.calendar-day-events li {
    margin-bottom: 4px;
}

/* Mobile */

@media (max-width: 850px) {
    .site-nav {
        flex-direction: column;
        align-items: flex-start;
    }

    .site-nav-links {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .site-nav-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .card-grid,
    .frontpage-grid {
        grid-template-columns: 1fr;
    }

    .calendar-grid-header,
    .calendar-grid {
        min-width: 640px;
    }

    .hero h1 {
        font-size: 2.4rem;
    }

    .sub-hero h1 {
        font-size: 2rem;
    }

    .sub-hero-content {
        padding: 40px 24px;
    }

    .footer-grid {
        flex-direction: column;
    }
}
