@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&display=swap');

:root {
    --bg: #f6f7f4;
    --surface: #ffffff;
    --surface-soft: #f0f4f3;
    --text: #202a33;
    --muted: #65727d;
    --line: #dce4e2;
    --primary: #2f667c;
    --primary-dark: #244e60;
    --green: #3f725d;
    --amber: #9a6a1e;
    --red: #a9453f;
    --blue-soft: #e8f2f5;
    --green-soft: #e9f3ee;
    --amber-soft: #fff4dc;
    --red-soft: #fdebea;
    --shadow: 0 14px 38px rgba(32, 42, 51, 0.08);
    --shadow-sm: 0 8px 20px rgba(32, 42, 51, 0.06);
    --radius: 6px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--text);
    font-family: "Roboto", Arial, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

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

a:hover {
    color: var(--primary-dark);
}

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

button,
.button-link {
    min-height: 42px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

button:hover,
.button-link:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    padding: 11px 12px;
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 102, 124, 0.13);
}

label,
legend {
    display: block;
    color: #2d3944;
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.brand span {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    background: var(--blue-soft);
    color: var(--primary-dark);
    font-size: 0.8rem;
    font-weight: 800;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 18px;
}

.topbar nav a {
    color: var(--text);
    font-weight: 700;
}

.topbar form {
    margin: 0;
}

.ghost-button {
    min-height: 36px;
    border-color: var(--line);
    background: #fff;
    color: var(--text);
    padding: 0 12px;
    box-shadow: none;
}

.ghost-button:hover {
    border-color: var(--primary);
    background: var(--blue-soft);
    color: var(--primary-dark);
}

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.auth-page .page {
    width: min(480px, calc(100% - 32px));
}

.auth-shell {
    display: grid;
    min-height: calc(100vh - 124px);
    place-items: center;
}

.auth-panel,
.panel,
.dashboard-hero,
.project-header,
.stat {
    border: 1px solid rgba(220, 228, 226, 0.86);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-panel {
    width: 100%;
    padding: 34px;
}

.auth-panel h1,
.dashboard-hero h1,
.project-header h1 {
    margin: 0;
    color: var(--text);
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.02;
}

.auth-switch {
    margin: 22px 0 0;
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--green);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

.stacked-form {
    display: grid;
    gap: 12px;
    margin-top: 22px;
}

.stacked-form button {
    margin-top: 4px;
}

.dashboard-hero,
.project-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
    gap: 28px;
    align-items: start;
    padding: 30px;
}

.dashboard-hero p {
    max-width: 620px;
}

.quick-project {
    display: grid;
    gap: 10px;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

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

.stat {
    padding: 18px;
}

.stat span {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.stat p {
    margin: 8px 0 0;
    color: var(--muted);
}

.tag-stat.tag-observera {
    background: var(--green-soft);
}

.tag-stat.tag-viktigt {
    background: var(--amber-soft);
}

.content-grid,
.project-layout {
    display: grid;
    grid-template-columns: minmax(320px, 0.82fr) minmax(0, 1.18fr);
    gap: 18px;
    align-items: start;
}

.dashboard-log-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
}

.project-layout {
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.panel {
    padding: 22px;
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-heading h2 {
    margin: 0;
    font-size: 1.15rem;
}

.section-heading span {
    color: var(--muted);
    font-size: 0.9rem;
}

.project-list,
.log-list {
    display: grid;
    gap: 12px;
}

.project-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 14px;
    color: var(--text);
}

.project-row:hover {
    border-color: rgba(47, 102, 124, 0.5);
    box-shadow: var(--shadow-sm);
}

.project-row strong,
.project-row small,
.row-meta span {
    display: block;
}

.project-row small,
.row-meta {
    color: var(--muted);
    font-size: 0.88rem;
}

.row-meta {
    text-align: right;
    white-space: nowrap;
}

.empty {
    margin: 0;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    padding: 18px;
    background: var(--surface-soft);
}

.project-header {
    margin-bottom: 18px;
}

.project-header p {
    margin: 10px 0 0;
    color: var(--muted);
}

.project-meta {
    display: grid;
    gap: 8px;
    justify-items: end;
    color: var(--muted);
}

.back-link {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.form-row {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 12px;
}

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

.borr-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.select-add-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(130px, 0.58fr);
    gap: 8px;
}

input[readonly] {
    background: var(--surface-soft);
    color: var(--muted);
}

.reference-picker {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin: 4px 0 0;
    padding: 12px;
}

.reference-list {
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
}

.reference-list label {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 9px;
    align-items: start;
    margin: 0;
    color: var(--text);
    font-weight: 600;
}

.reference-list input {
    width: 16px;
    height: 16px;
    margin-top: 2px;
}

.log-card {
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: #fff;
    padding: 16px;
}

.log-topline,
.log-meta,
.reference-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.log-topline {
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.88rem;
}

.tag-pill {
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--primary-dark);
    padding: 4px 9px;
    font-size: 0.78rem;
    font-weight: 800;
}

.code-1,
.code-3,
.code-4 {
    border-left-color: var(--red);
}

.code-2,
.code-6,
.code-7,
.code-8 {
    border-left-color: var(--amber);
}

.code-5 {
    border-left-color: var(--green);
}

.code-1 .tag-pill,
.code-3 .tag-pill,
.code-4 .tag-pill {
    background: var(--red-soft);
    color: var(--red);
}

.code-2 .tag-pill,
.code-6 .tag-pill,
.code-7 .tag-pill,
.code-8 .tag-pill {
    background: var(--amber-soft);
    color: var(--amber);
}

.code-5 .tag-pill {
    background: var(--green-soft);
    color: var(--green);
}

.log-card h3 {
    margin: 12px 0 8px;
    font-size: 1.05rem;
}

.borr-details {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 12px;
}

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

.borr-details dt,
.borr-details dd {
    margin: 0;
}

.borr-details dt {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.borr-details dd {
    margin-top: 2px;
    font-weight: 700;
}

.log-card p {
    margin: 0 0 12px;
}

.log-meta {
    color: var(--muted);
    font-size: 0.86rem;
}

.reference-chips {
    margin-top: 12px;
}

.reference-chips a {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--text);
    padding: 5px 8px;
    font-size: 0.82rem;
    font-weight: 700;
}

.subtle-action {
    display: inline-block;
    margin-top: 12px;
    color: var(--primary);
    font-size: 0.88rem;
    font-weight: 800;
}

.flash {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 18px;
    padding: 12px 14px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.flash.success {
    border-color: #bbd8c7;
    background: var(--green-soft);
    color: #2d5b49;
}

.flash.error {
    border-color: #efc4c0;
    background: var(--red-soft);
    color: #8a342f;
}

@media (max-width: 900px) {
    .dashboard-hero,
    .project-header,
    .content-grid,
    .dashboard-log-grid,
    .project-layout {
        grid-template-columns: 1fr;
    }

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

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

    .project-meta {
        justify-items: start;
    }
}

@media (max-width: 620px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 14px 16px;
    }

    .topbar nav {
        width: 100%;
        justify-content: space-between;
    }

    .page {
        width: min(100% - 24px, 1180px);
        padding-top: 18px;
    }

    .auth-panel,
    .panel,
    .dashboard-hero,
    .project-header {
        padding: 18px;
    }

    .inline-form,
    .project-row,
    .form-row,
    .borr-grid,
    .borr-grid.three,
    .select-add-row,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .row-meta {
        text-align: left;
        white-space: normal;
    }

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

    .borr-details {
        grid-template-columns: 1fr;
    }
}
