/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --border: #dfe1e6;
    --text: #172b4d;
    --text-light: #5e6c84;
    --primary: #0052cc;
    --primary-hover: #0065ff;
    --danger: #de350b;
    --danger-hover: #ff5630;
    --success: #00875a;
    --warning: #ff991f;
    --col-bg: #ebecf0;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.12);
    --input-bg: #ffffff;
}

[data-theme="dark"] {
    --bg: #1a1c20;
    --card: #23272e;
    --border: #3a3f47;
    --text: #d4d7dd;
    --text-light: #9ba1ab;
    --primary: #4c9aff;
    --primary-hover: #6db3ff;
    --danger: #ff5630;
    --danger-hover: #ff7452;
    --success: #36b37e;
    --warning: #ffab00;
    --col-bg: #2c313a;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
    --input-bg: #2c313a;
}

html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Utility ─────────────────────────────────────────────────── */
.flash { padding: .6rem 1rem; margin: .5rem 1rem; border-radius: var(--radius); font-size: .9rem; }
.flash.success { background: #e3fcef; color: #006644; }
.flash.error   { background: #ffebe6; color: #bf2600; }

/* ── Login ───────────────────────────────────────────────────── */
.login-wrap {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
}
.login-box {
    background: var(--card); padding: 2.5rem 2rem; border-radius: var(--radius);
    box-shadow: var(--shadow); width: 100%; max-width: 360px; text-align: center;
}
.login-box h1 { margin-bottom: 1.5rem; font-size: 1.4rem; }
.login-box input[type="password"] {
    width: 100%; padding: .6rem .8rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 1rem; margin-bottom: 1rem;
    background: var(--input-bg); color: var(--text);
}
.login-box button {
    width: 100%; padding: .65rem; border: none; border-radius: var(--radius);
    background: var(--primary); color: #fff; font-size: 1rem; cursor: pointer;
}
.login-box button:hover { background: var(--primary-hover); }

/* ── Header ──────────────────────────────────────────────────── */
.header {
    background: var(--card); border-bottom: 1px solid var(--border);
    padding: .6rem 1.2rem; display: flex; align-items: center;
    justify-content: space-between; flex-wrap: wrap; gap: .5rem;
    position: sticky; top: 0; z-index: 50;
}
.header h1 { font-size: 1.15rem; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .45rem .85rem; border: none; border-radius: var(--radius);
    font-size: .85rem; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: var(--danger-hover); color: #fff; text-decoration: none; }
.btn-secondary { background: var(--col-bg); color: var(--text); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }
.btn-sm { padding: .3rem .55rem; font-size: .78rem; }

/* ── Search ──────────────────────────────────────────────────── */
.search-input {
    padding: .4rem .7rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: .85rem; width: 200px;
    background: var(--input-bg); color: var(--text);
}

/* ── Dark mode toggle ────────────────────────────────────────── */
.theme-toggle {
    background: var(--col-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .3rem .55rem; font-size: .85rem; cursor: pointer; line-height: 1;
    color: var(--text);
}
.theme-toggle:hover { background: var(--border); }

/* ── Dark mode badge overrides ───────────────────────────────── */
[data-theme="dark"] .badge-payment-ógreitt   { background: #4a1c10; color: #ff8f73; }
[data-theme="dark"] .badge-payment-innborgun { background: #43300e; color: #ffe380; }
[data-theme="dark"] .badge-payment-greitt    { background: #0e3b26; color: #57d9a3; }
[data-theme="dark"] .badge-eta               { background: #0e2a52; color: #85b8ff; }
[data-theme="dark"] .badge-overdue           { background: #4a1c10; color: #ff8f73; }
[data-theme="dark"] .badge-phone             { background: #2c313a; color: var(--text-light); }
[data-theme="dark"] .flash.success           { background: #0e3b26; color: #57d9a3; }
[data-theme="dark"] .flash.error             { background: #4a1c10; color: #ff8f73; }
[data-theme="dark"] .detail-status-pipeline .step.done { background: #0e3b26; color: #57d9a3; }

/* ── Board ───────────────────────────────────────────────────── */
.board {
    display: flex; gap: .75rem; padding: .75rem 1rem;
    overflow-x: auto; align-items: flex-start;
    min-height: calc(100vh - 56px);
}
.column {
    background: var(--col-bg); border-radius: var(--radius);
    min-width: 260px; max-width: 300px; flex: 1 0 260px;
    display: flex; flex-direction: column; max-height: calc(100vh - 70px);
}
.column-header {
    padding: .6rem .75rem; font-weight: 700; font-size: .85rem;
    display: flex; justify-content: space-between; align-items: center;
}
.column-header .count {
    background: var(--border); border-radius: 10px; padding: .1rem .5rem;
    font-size: .75rem; font-weight: 600;
}
.column-cards {
    padding: 0 .5rem .5rem; overflow-y: auto; flex: 1;
}

/* ── Card ────────────────────────────────────────────────────── */
.card {
    background: var(--card); border-radius: var(--radius);
    padding: .65rem .75rem; margin-bottom: .5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.1); cursor: pointer;
    border-left: 4px solid transparent; transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 2px 6px rgba(0,0,0,.16); }
.card.priority-brýnt       { border-left-color: var(--danger); }
.card.priority-mikilvægt    { border-left-color: var(--warning); }

.card-customer { font-weight: 600; font-size: .88rem; margin-bottom: .15rem; }
.card-product  { font-size: .82rem; color: var(--text-light); margin-bottom: .3rem; }
.card-meta     { display: flex; flex-wrap: wrap; gap: .3rem; font-size: .72rem; }
.badge {
    display: inline-block; padding: .1rem .4rem; border-radius: 3px;
    font-weight: 600; font-size: .7rem; text-transform: uppercase;
}
.badge-payment-ógreitt   { background: #ffebe6; color: #bf2600; }
.badge-payment-innborgun { background: #fff7e6; color: #974f0c; }
.badge-payment-greitt    { background: #e3fcef; color: #006644; }
.badge-eta               { background: #deebff; color: #0747a6; }
.badge-overdue           { background: #ffebe6; color: #bf2600; }
.badge-phone             { background: #f4f5f7; color: var(--text-light); }

/* ── Quick-status form on card ───────────────────────────────── */
.card-status-form { margin-top: .4rem; }
.card-status-form select {
    font-size: .75rem; padding: .15rem .3rem; border-radius: 3px;
    border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
}

/* ── Form pages ──────────────────────────────────────────────── */
.form-wrap {
    max-width: 640px; margin: 1.5rem auto; padding: 0 1rem;
}
.form-wrap h2 { margin-bottom: 1rem; }
.form-card {
    background: var(--card); border-radius: var(--radius);
    padding: 1.5rem; box-shadow: var(--shadow);
}
.form-group { margin-bottom: .9rem; }
.form-group label {
    display: block; font-size: .82rem; font-weight: 600;
    margin-bottom: .2rem; color: var(--text-light);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: .5rem .7rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: .9rem; font-family: inherit;
    background: var(--input-bg); color: var(--text);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; gap: .5rem; margin-top: 1rem; }

/* ── Detail page ─────────────────────────────────────────────── */
.detail-wrap {
    max-width: 640px; margin: 1.5rem auto; padding: 0 1rem;
}
.detail-card {
    background: var(--card); border-radius: var(--radius);
    padding: 1.5rem; box-shadow: var(--shadow);
}
.detail-card h2 { margin-bottom: .3rem; }
.detail-card .sub { color: var(--text-light); font-size: .9rem; margin-bottom: 1rem; }
.detail-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1.5rem;
    font-size: .88rem;
}
.detail-grid dt { color: var(--text-light); font-size: .78rem; font-weight: 600; text-transform: uppercase; }
.detail-grid dd { margin-bottom: .4rem; }
.detail-notes { margin-top: 1rem; }
.detail-notes h3 { font-size: .9rem; margin-bottom: .3rem; }
.detail-notes p {
    background: var(--col-bg); padding: .6rem .8rem;
    border-radius: var(--radius); white-space: pre-wrap; font-size: .85rem;
}
.detail-actions { display: flex; gap: .5rem; margin-top: 1.2rem; }
.detail-status-pipeline {
    display: flex; gap: .3rem; margin: 1rem 0; flex-wrap: wrap;
}
.detail-status-pipeline .step {
    padding: .25rem .6rem; border-radius: 3px; font-size: .75rem;
    background: var(--col-bg); color: var(--text-light);
}
.detail-status-pipeline .step.active {
    background: var(--primary); color: #fff; font-weight: 600;
}
.detail-status-pipeline .step.done {
    background: #e3fcef; color: #006644;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
    .board { flex-direction: column; align-items: stretch; }
    .column { max-width: 100%; min-width: 0; max-height: none; }
    .form-row { flex-direction: column; gap: 0; }
}
