/* RS Mediaworks Panel — #771718, #1d1f1e, #949494 (platte tekst) */

:root {
    --rs-red: #771718;
    --rs-red-bright: #a31f22;
    --rs-red-glow: rgba(163, 31, 34, 0.45);
    --rs-dark: #1d1f1e;
    --rs-muted: #949494;
    --rs-surface: #252726;
    --rs-border: #2f3230;
    --rs-text: #e8e8e6;
    --rs-radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

html[data-theme="light"] {
    --rs-dark: #f4f3f1;
    --rs-surface: #ffffff;
    --rs-border: #dadad8;
    --rs-text: #1d1f1e;
    --rs-muted: #949494;
}

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    background: radial-gradient(1200px 600px at 10% -10%, rgba(119, 23, 24, 0.18), transparent),
        radial-gradient(900px 500px at 100% 0%, rgba(80, 80, 80, 0.08), transparent),
        var(--rs-dark);
    color: var(--rs-text);
}

a {
    color: #c9c9c7;
}

html[data-theme="light"] a {
    color: #5c1011;
}

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #0f100f 0%, #1a1c1b 40%, var(--rs-dark) 100%);
    border-right: 1px solid rgba(119, 23, 24, 0.25);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
    padding: 1.25rem 1rem 1rem;
}

html[data-theme="light"] .sidebar {
    background: linear-gradient(180deg, #ebeae8 0%, #f4f3f1 100%);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0.25rem 0.5rem;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--rs-radius);
    background: linear-gradient(145deg, var(--rs-red-bright), var(--rs-red));
    color: #fff;
    font-weight: 800;
    letter-spacing: -0.02em;
    box-shadow: 0 4px 14px var(--rs-red-glow);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-text strong {
    font-size: 0.95rem;
}

.brand-text span {
    font-size: 0.75rem;
    color: var(--rs-muted);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    color: var(--rs-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    border: 1px solid transparent;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
}

.nav-icon-svg {
    flex-shrink: 0;
}

.nav-link:hover {
    background: rgba(119, 23, 24, 0.2);
    color: var(--rs-text);
    border-color: rgba(119, 23, 24, 0.25);
}

.nav-link.is-active {
    background: linear-gradient(90deg, rgba(119, 23, 24, 0.45), rgba(119, 23, 24, 0.15));
    color: #fff;
    border-color: rgba(163, 31, 34, 0.5);
    box-shadow: 0 0 0 1px rgba(163, 31, 34, 0.25), 0 6px 20px rgba(0, 0, 0, 0.2);
}

html[data-theme="light"] .nav-link.is-active {
    color: var(--rs-text);
    background: linear-gradient(90deg, rgba(119, 23, 24, 0.2), rgba(119, 23, 24, 0.06));
    box-shadow: none;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--rs-border);
}

.sidebar-user {
    margin-bottom: 0.65rem;
}

.sidebar-user-name {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--rs-text);
}

.sidebar-user-meta {
    font-size: 0.72rem;
    color: var(--rs-muted);
    word-break: break-all;
}

.btn-sidebar-logout {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: rgba(119, 23, 24, 0.35);
    border: 1px solid rgba(163, 31, 34, 0.5);
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.btn-sidebar-logout:hover {
    background: rgba(163, 31, 34, 0.55);
    box-shadow: 0 4px 12px var(--rs-red-glow);
}

.main {
    flex: 1;
    padding: 2rem clamp(1.25rem, 4vw, 2.5rem);
    overflow-x: auto;
}

.page-header h1 {
    margin: 0 0 0.35rem;
    font-size: 1.65rem;
    font-weight: 700;
}

.muted {
    color: var(--rs-muted);
    font-size: 0.9rem;
}

.card {
    background: var(--rs-surface);
    border: 1px solid var(--rs-border);
    border-radius: var(--rs-radius);
    padding: 1.25rem 1.5rem;
    margin-top: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
}

.card-title {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.form-grid {
    display: grid;
    gap: 1rem;
    max-width: 720px;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--rs-muted);
}

.form-grid input {
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--rs-border);
    background: #1a1c1b;
    color: var(--rs-text);
    font-size: 0.95rem;
}

html[data-theme="light"] .form-grid input {
    background: #fafafa;
}

.form-grid input:focus {
    outline: 2px solid rgba(119, 23, 24, 0.45);
    outline-offset: 1px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
    transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: linear-gradient(180deg, var(--rs-red-bright), var(--rs-red));
    color: #fff;
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 16px var(--rs-red-glow), 0 2px 0 rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    filter: brightness(1.07);
    box-shadow: 0 6px 22px var(--rs-red-glow), 0 2px 0 rgba(0, 0, 0, 0.2);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    color: var(--rs-text);
    border: 1px solid var(--rs-border);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.btn-ghost:hover {
    background: rgba(119, 23, 24, 0.12);
    border-color: rgba(119, 23, 24, 0.35);
}

.btn-back {
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
}

.btn-block {
    width: 100%;
}

.btn-sm-text {
    font-size: 0.82rem;
    padding: 0.4rem 0.65rem;
}

.theme-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.code-inline {
    font-size: 0.85em;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.2);
    font-family: ui-monospace, monospace;
}

html[data-theme="light"] .code-inline {
    background: rgba(0, 0, 0, 0.06);
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--rs-border);
}

.data-table th {
    color: var(--rs-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

html[data-theme="light"] .data-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.03);
}

.link-external {
    word-break: break-all;
}

.pill {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.pill-ok {
    background: rgba(46, 125, 50, 0.25);
    color: #a5d6a7;
}

.pill-off {
    background: rgba(119, 23, 24, 0.35);
    color: #ffcdd2;
}

html[data-theme="light"] .pill-ok {
    background: rgba(46, 125, 50, 0.15);
    color: #2e7d32;
}

html[data-theme="light"] .pill-off {
    background: rgba(119, 23, 24, 0.12);
    color: #771718;
}

.page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.chart-wrap {
    margin-top: 1rem;
    height: 260px;
}

.kpi {
    margin: 0.5rem 0 0;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--rs-text);
}

.kpi-label {
    display: block;
    font-size: 0.85rem;
    color: var(--rs-muted);
    margin-top: 0.15rem;
}

.kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin: 0.75rem 0 0;
    align-items: baseline;
}

.small {
    font-size: 0.82rem;
}

.sub-title {
    margin: 1.25rem 0 0.5rem;
    font-size: 1rem;
}

.inline-form {
    display: inline-block;
    margin-top: 0.75rem;
}

a.btn-small,
.btn.btn-small {
    display: inline-flex;
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    background: linear-gradient(180deg, var(--rs-red-bright), var(--rs-red));
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 3px 12px var(--rs-red-glow);
}

html[data-theme="light"] a.btn-small,
html[data-theme="light"] .btn.btn-small {
    color: #fff;
}

.btn-danger {
    background: linear-gradient(180deg, #b32428, #771718);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 16px rgba(119, 23, 24, 0.45), 0 2px 0 rgba(0, 0, 0, 0.2);
}

.btn-danger:hover {
    filter: brightness(1.06);
}

.card-danger {
    border-color: rgba(119, 23, 24, 0.55);
}

.banner {
    border-radius: var(--rs-radius);
    padding: 0.75rem 1rem;
    margin: 0 0 1rem;
    border: 1px solid var(--rs-border);
}

.banner-ok {
    background: rgba(46, 125, 50, 0.15);
    border-color: rgba(46, 125, 50, 0.35);
}

.banner-err {
    background: rgba(119, 23, 24, 0.2);
    border-color: rgba(119, 23, 24, 0.45);
}

.banner-warn {
    background: rgba(200, 150, 0, 0.12);
    border-color: rgba(200, 150, 0, 0.35);
}

.pill-muted {
    background: rgba(148, 148, 148, 0.2);
    color: var(--rs-muted);
}

.pill-warn {
    background: rgba(200, 150, 0, 0.2);
    color: #e6c200;
}

html[data-theme="light"] .pill-warn {
    color: #7a5f00;
}

/* Auth (login / setup) */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: radial-gradient(800px 400px at 50% -20%, rgba(119, 23, 24, 0.25), transparent), var(--rs-dark);
}

.auth-wrap {
    width: 100%;
    max-width: 420px;
}

.auth-wrap .card {
    margin-top: 0;
}

.auth-card-inner {
    margin-top: 0;
    padding: 1.75rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--rs-muted);
}

.auth-form input {
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--rs-border);
    background: #1a1c1b;
    color: var(--rs-text);
    font-size: 0.95rem;
}

html[data-theme="light"] .auth-form input {
    background: #fafafa;
}

/* Modal */
.modal[hidden] {
    display: none !important;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
}

.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: var(--rs-surface);
    border: 1px solid var(--rs-border);
    border-radius: var(--rs-radius);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(163, 31, 34, 0.2);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--rs-border);
    background: rgba(119, 23, 24, 0.12);
}

.modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-x {
    border: none;
    background: transparent;
    color: var(--rs-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}

.modal-x:hover {
    color: var(--rs-text);
}

.modal-body {
    padding: 1.15rem;
}

.modal-text {
    margin: 0 0 0.75rem;
    line-height: 1.45;
    color: var(--rs-text);
}

.modal-err {
    color: #ffb4b4;
    font-size: 0.85rem;
    min-height: 1.25rem;
    margin: 0 0 0.5rem;
}

html[data-theme="light"] .modal-err {
    color: #771718;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--rs-muted);
}

.modal-input {
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--rs-border);
    background: #1a1c1b;
    color: var(--rs-text);
    font-size: 0.95rem;
}

html[data-theme="light"] .modal-input {
    background: #fafafa;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.85rem 1.15rem 1.1rem;
    border-top: 1px solid var(--rs-border);
}

.pill-soft {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(119, 23, 24, 0.25);
    color: #f0d0d0;
}

html[data-theme="light"] .pill-soft {
    color: #771718;
    background: rgba(119, 23, 24, 0.12);
}

.form-grid select {
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--rs-border);
    background: #1a1c1b;
    color: var(--rs-text);
    font-size: 0.95rem;
}

html[data-theme="light"] .form-grid select {
    background: #fafafa;
}

.inline-row-form {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.select-inline {
    min-width: 8rem;
}

.log-detail {
    max-width: 320px;
    word-break: break-word;
    font-size: 0.85rem;
}

.nowrap {
    white-space: nowrap;
}
