/* ============================================================
   Regnskapsprogram — Vanilla CSS
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue:    #2563eb;
    --blue-dk: #1d4ed8;
    --green:   #16a34a;
    --red:     #dc2626;
    --orange:  #d97706;
    --gray-50: #f9fafb;
    --gray-100:#f3f4f6;
    --gray-200:#e5e7eb;
    --gray-400:#9ca3af;
    --gray-600:#4b5563;
    --gray-800:#1f2937;
    --white:   #ffffff;
    --radius:  6px;
    --shadow:  0 1px 3px rgba(0,0,0,.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.5;
}

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }

nav {
    width: 220px;
    flex-shrink: 0;
    background: var(--gray-800);
    padding: 0;
    display: flex;
    flex-direction: column;
}

nav .nav-logo {
    padding: 20px 18px 16px;
    font-size: 16px;
    font-weight: 700;
    color: var(--white);
    border-bottom: 1px solid rgba(255,255,255,.1);
}

nav a {
    display: block;
    padding: 11px 18px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: 14px;
    transition: background .15s, color .15s;
}
nav a:hover, nav a.active { background: rgba(255,255,255,.08); color: var(--white); }

nav .nav-section {
    padding: 14px 18px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--gray-400);
}

nav .nav-logout {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,.1);
}

.main { flex: 1; display: flex; flex-direction: column; overflow: auto; }

header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 12px;
}
header h1 { font-size: 20px; font-weight: 600; }

.content { padding: 28px; }

/* ---- Card ---- */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* ---- Tabeller ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gray-600);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}
td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
th.num, td.num { text-align: right; }

/* ---- Skjema ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 500; color: var(--gray-600); }

input[type=text], input[type=email], input[type=date],
input[type=number], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea { resize: vertical; min-height: 80px; }

/* ---- Knapper ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn-primary  { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-dk); }
.btn-secondary { background: var(--white); color: var(--gray-800); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-danger   { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ---- Status-badges ---- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-draft    { background: var(--gray-100); color: var(--gray-600); }
.badge-sent     { background: #dbeafe; color: #1e40af; }
.badge-paid     { background: #dcfce7; color: #15803d; }
.badge-overdue  { background: #fee2e2; color: #b91c1c; }
.badge-pending  { background: #fef9c3; color: #854d0e; }

/* ---- Varsler / flash ---- */
.alert {
    padding: 11px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* ---- Innloggingsside ---- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
}
.login-box {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
}
.login-box h1 { font-size: 22px; margin-bottom: 24px; }

/* ---- Dashboard stats ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12px; color: var(--gray-600); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 4px; }

/* ---- Fakturalinjer (dynamisk) ---- */
.items-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.items-table th {
    font-size: 12px; padding: 6px 8px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    text-align: left;
}
.items-table td { padding: 6px 4px; vertical-align: middle; }
.items-table input { padding: 6px 8px; }
.items-total { text-align: right; font-weight: 600; font-size: 15px; margin-top: 6px; }

/* ---- Bilag-visning ---- */
.attachment-preview iframe,
.attachment-preview img {
    width: 100%;
    max-height: 500px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

/* ---- Hjelpeklasser ---- */
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-400); font-size: 13px; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }

/* ---- Print (faktura) ---- */
@media print {
    nav, header, .btn, .no-print { display: none !important; }
    .main { display: block; }
    .content { padding: 0; }
    .card { box-shadow: none; border: none; }
}
