/* ==========================================================================
   it.support - warm paper design (Hjem, Saker, Standardsvar, Admin)
   Serif display (Instrument Serif) for titles, Inter for UI text,
   JetBrains Mono for clock times. Colours live in the tokens below.
   ========================================================================== */

:root {
    --paper: #F3F0EA;
    --surface: #FDFCF9;
    --surface-sunk: #F7F4EE;
    --line: #E3DED4;
    --line-strong: #D5CFC3;
    --ink: #1C1B19;
    --ink-2: #4F4B45;
    --muted: #736E66;
    --accent: #D4A13C;
    --accent-soft: #F6EBD3;
    --danger: #B3261E;
    --danger-soft: #F7E3E0;
    --success: #3E7A4E;
    --success-soft: #E4EFE6;

    --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    --radius: 18px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(28, 27, 25, 0.04), 0 12px 32px rgba(28, 27, 25, 0.06);

    /* Bootstrap hooks, so its components pick up the palette. */
    --bs-body-font-family: var(--font-body);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--paper);
    --bs-border-color: var(--line);
    --bs-secondary-color: var(--muted);
    --bs-link-color-rgb: 28, 27, 25;
    --bs-link-hover-color-rgb: 28, 27, 25;
}

html,
body {
    font-family: var(--font-body);
    background-color: var(--paper);
    color: var(--ink);
    height: 100%;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    min-height: 100%;
}

.main {
    overflow: auto;
    padding-bottom: 72px;
}

/* must be same height as the footer */
#footer {
    position: relative;
    margin-top: -72px;
    /* negative value of footer height */
    height: 72px;
    clear: both;
}

a {
    color: var(--ink);
    text-underline-offset: 3px;
}

.text-muted {
    color: var(--muted) !important;
}

.min-width-0 {
    min-width: 0;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---- Top navigation ---- */
.site-nav {
    background: rgba(243, 240, 234, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
}

#nav-heading {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ink);
}

.pill-nav {
    display: flex;
    gap: 0.25rem;
}

.pill-nav a {
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.pill-nav a:hover {
    color: var(--ink);
}

.pill-nav a.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--line);
}

/* ---- Avatar (profile menu) ---- */
.avatar-badge {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
}

.avatar-0 { background: #8C4A3C; }
.avatar-1 { background: #3F4E5E; }
.avatar-2 { background: #4F6B4A; }
.avatar-3 { background: #9A7128; }
.avatar-4 { background: #5E5270; }

/* ---- Footer ---- */
.site-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 72px;
    color: var(--muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--line);
}

.site-footer a {
    color: var(--ink-2);
}

/* ---- Flash messages ---- */
.alert {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
}

.alert-success { border-left: 4px solid var(--success); }
.alert-warning { border-left: 4px solid var(--accent); }
.alert-danger { border-left: 4px solid var(--danger); }
.alert-info { border-left: 4px solid var(--ink-2); }

/* ==========================================================================
   Shared page building blocks
   ========================================================================== */

.page {
    max-width: 1140px;
    margin: 0 auto;
    padding: 3.5rem 0 4rem;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem 2rem;
    margin-bottom: 2.5rem;
}

.eyebrow,
.section-label {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.6rem;
}

.display {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(2.75rem, 7vw, 5rem);
    line-height: 1;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 0.9rem;
}

.lede {
    font-size: 1.2rem;
    color: var(--ink-2);
    margin: 0;
    max-width: 44rem;
}

.serif {
    font-family: var(--font-display);
    font-weight: 400;
}

.mono {
    font-family: var(--font-mono);
    font-weight: 500;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel-body {
    padding: 1.5rem 1.75rem;
}

/* Bootstrap cards (older markup) get the same look as .panel. */
.card {
    background: var(--surface);
    border: 1px solid var(--line) !important;
    border-radius: var(--radius);
    box-shadow: none !important;
}

.tag {
    display: inline-flex;
    align-items: center;
    background: #ECE8E0;
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.2rem 0.75rem;
    white-space: nowrap;
}

.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-accent { background: var(--accent-soft); color: #7A5714; }
.tag-success { background: var(--success-soft); color: var(--success); }

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

/* Editorial list: rows separated by hairlines, no card around them. */
.rule-list {
    border-top: 1px solid var(--line-strong);
}

.rule-row {
    position: relative;
    display: grid;
    grid-template-columns: 6rem minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 1rem;
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
}

.rule-row:hover {
    color: var(--ink);
    background: linear-gradient(to right, transparent, rgba(253, 252, 249, 0.7) 10%, rgba(253, 252, 249, 0.7) 90%, transparent);
}

.rule-row .time {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--ink-2);
}

.rule-row .time.hot {
    color: var(--danger);
}

.rule-row .title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rule-row .aside {
    color: var(--muted);
    font-size: 0.95rem;
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .rule-row {
        grid-template-columns: 4rem minmax(0, 1fr);
    }
    .rule-row .aside {
        grid-column: 2;
        text-align: left;
        white-space: normal;
    }
    .rule-row .title {
        white-space: normal;
        font-size: 1.45rem;
    }
}

/* ---- Buttons ---- */
.btn {
    border-radius: 999px;
    font-weight: 600;
    padding: 0.55rem 1.25rem;
}

.btn-sm {
    padding: 0.3rem 0.85rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 0.8rem 1.9rem;
    font-size: 1.05rem;
}

.btn-ink,
.btn-primary,
.btn-dark {
    background: var(--ink);
    border: 2px solid var(--ink);
    color: #fff;
}

.btn-ink:hover,
.btn-ink:focus,
.btn-ink:disabled,
.btn-primary:hover,
.btn-primary:focus,
.btn-dark:hover,
.btn-dark:focus {
    background: #33312D;
    border-color: #33312D;
    color: #fff;
}

.btn-ghost {
    background: transparent;
    border: 2px solid var(--accent);
    color: var(--ink);
}

.btn-ghost:hover,
.btn-ghost:focus {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--ink);
}

.btn-quiet,
.btn-outline-secondary,
.btn-outline-primary,
.btn-outline-dark,
.btn-secondary {
    background: transparent;
    border: 1px solid var(--line-strong);
    color: var(--ink);
}

.btn-quiet:hover,
.btn-outline-secondary:hover,
.btn-outline-primary:hover,
.btn-outline-dark:hover,
.btn-secondary:hover {
    background: var(--surface);
    border-color: var(--ink-2);
    color: var(--ink);
}

.btn-outline-danger {
    border: 1px solid #E2B4AF;
    color: var(--danger);
    background: transparent;
}

.btn-outline-danger:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
}

/* ---- Forms ---- */
.form-control,
.form-select {
    background-color: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--ink);
}

.form-control:focus,
.form-select:focus {
    background-color: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 161, 60, 0.2);
}

.form-label {
    font-weight: 500;
    color: var(--ink-2);
}

.form-check-input:checked {
    background-color: var(--ink);
    border-color: var(--ink);
}

.form-check-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 161, 60, 0.2);
}

.search-box {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 0.6rem 1rem 0.6rem 2.4rem;
    width: 100%;
    font-size: 0.95rem;
    color: var(--ink);
}

.search-box:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 161, 60, 0.2);
}

.search-box-wrap {
    position: relative;
}

.search-box-wrap::before {
    content: "";
    position: absolute;
    left: 0.95rem;
    top: 50%;
    width: 0.9rem;
    height: 0.9rem;
    transform: translateY(-50%);
    border: 1.6px solid var(--muted);
    border-radius: 50%;
    pointer-events: none;
}

.search-box-wrap::after {
    content: "";
    position: absolute;
    left: 1.72rem;
    top: calc(50% + 0.42rem);
    width: 0.4rem;
    height: 1.6px;
    background: var(--muted);
    transform: rotate(45deg);
    pointer-events: none;
}

/* ---- Tabs (Saker) ---- */
.tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
}

.tab-nav a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.35rem 0;
    border-bottom: 2px solid transparent;
}

.tab-nav a:hover {
    color: var(--ink);
}

.tab-nav a.active {
    color: var(--ink);
    border-bottom-color: var(--accent);
}

/* ---- Priority / status labels ---- */
.badge {
    border-radius: 999px;
    font-weight: 600;
}

.badge-priority-high { background: var(--danger-soft); color: var(--danger); }
.badge-priority-normal { background: #ECE8E0; color: var(--ink-2); }
.badge-priority-low { background: transparent; color: var(--muted); border: 1px solid var(--line-strong); }

/* ---- Keyword chips (Standardsvar) ---- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #ECE8E0;
    color: var(--ink-2);
    border-radius: 999px;
    padding: 0.3rem 0.8rem;
    font-size: 0.88rem;
    font-weight: 500;
}

.chip button {
    background: none;
    border: none;
    color: var(--muted);
    line-height: 1;
    padding: 0;
    font-size: 0.95rem;
}

.chip-add-input {
    border: 1px dashed var(--line-strong);
    border-radius: 999px;
    background: transparent;
    padding: 0.3rem 0.8rem;
    font-size: 0.88rem;
    width: 9rem;
}

/* ---- Suggested canned response callout (saksside) ---- */
.suggestion-card {
    border: 1px solid #EBD6A8;
    background: #FBF4E4;
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
}

/* ==========================================================================
   Hjem
   ========================================================================== */

.sync-box {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.sync-meta {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.35;
    text-align: right;
}

.next-card {
    padding: 2.25rem 3.25rem 2.5rem;
    margin-bottom: 3rem;
}

.next-card-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 1.4rem;
}

.next-card-top .eyebrow {
    margin: 0;
}

.next-card-top .position {
    margin-left: auto;
    color: var(--muted);
    letter-spacing: 0.08em;
    font-size: 0.9rem;
}

.next-card-title {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    line-height: 1.05;
    color: var(--ink);
    text-decoration: none;
    margin-bottom: 1.2rem;
}

.next-card-title:hover {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-thickness: 1px;
}

.next-card-quote {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.6rem;
    line-height: 1.45;
    color: var(--ink-2);
    margin: 1.25rem 0 2rem;
    max-width: 52rem;
}

.next-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.empty-state {
    padding: 3rem 3.25rem;
    margin-bottom: 3rem;
}

.empty-state .serif {
    font-size: 2.5rem;
    line-height: 1.1;
    margin-bottom: 0.5rem;
}

.team-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 0 2.5rem;
    border-top: 1px solid var(--line-strong);
}

.team-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--line);
}

.team-row .name {
    font-family: var(--font-display);
    font-size: 1.45rem;
}

.team-row .count {
    font-family: var(--font-mono);
    color: var(--ink-2);
}

@media (max-width: 767.98px) {
    .page {
        padding-top: 2rem;
    }
    .next-card,
    .empty-state {
        padding: 1.5rem 1.4rem 1.75rem;
    }
    .next-card-quote {
        font-size: 1.3rem;
    }
    .sync-meta {
        text-align: left;
    }
}

/* ==========================================================================
   Saker (list + single case)
   ========================================================================== */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    margin-bottom: 1.5rem;
}

.ticket-row {
    display: grid;
    grid-template-columns: auto 5rem minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}

.ticket-row:hover {
    background: linear-gradient(to right, transparent, rgba(253, 252, 249, 0.7) 10%, rgba(253, 252, 249, 0.7) 90%, transparent);
}

.ticket-row .form-check-input {
    align-self: center;
    margin: 0;
}

.ticket-row .ticket-subject {
    font-family: var(--font-display);
    font-size: 1.55rem;
    line-height: 1.15;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticket-row .ticket-meta {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticket-row .aside {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--muted);
    font-size: 0.92rem;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .ticket-row {
        grid-template-columns: auto 3.5rem minmax(0, 1fr);
    }
    .ticket-row .aside {
        grid-column: 3;
    }
}

.bulk-bar {
    background: var(--ink);
    color: #fff;
    border-radius: 999px;
    padding: 0.5rem 0.6rem 0.5rem 1.25rem;
    margin-bottom: 1rem;
}

.message {
    padding: 1.4rem 1.6rem;
    margin-bottom: 1rem;
}

.message-outbound {
    background: var(--surface-sunk);
    box-shadow: none;
}

.message-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.message-body {
    white-space: pre-wrap;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--ink);
    margin: 0;
}

.side-section + .side-section {
    margin-top: 1.75rem;
}

.attachment-thumb {
    max-height: 120px;
    max-width: 180px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

/* ==========================================================================
   Standardsvar + Admin
   ========================================================================== */

.select-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
}

.select-row:hover {
    color: var(--ink);
}

.select-row .title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    line-height: 1.15;
}

.select-row.active .title {
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}

.template-body {
    white-space: pre-wrap;
    font-family: var(--font-body);
    line-height: 1.6;
    margin: 0 0 1.75rem;
}

.plain-table {
    width: 100%;
    border-collapse: collapse;
}

.plain-table th {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 0 0.6rem;
    border-bottom: 1px solid var(--line-strong);
    text-align: left;
}

.plain-table td {
    padding: 1rem 0;
    border-bottom: 1px solid var(--line);
    vertical-align: baseline;
}

.plain-table td.name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    line-height: 1.15;
}

.admin-link {
    display: block;
    padding: 1.75rem;
    color: var(--ink);
    text-decoration: none;
    transition: border-color 0.15s ease;
}

.admin-link:hover {
    color: var(--ink);
    border-color: var(--ink-2);
}

.admin-link .serif {
    font-size: 2rem;
    line-height: 1.1;
    margin-bottom: 0.35rem;
}
