/* =========================================================
   Home-Office-Protokoll · Kalku-Design
   Eigenständiger Look: tiefes Indigo + warmes Amber,
   sorgfältige Typografie, subtile Tiefe und Animation.
   ========================================================= */

@import url('https://rsms.me/inter/inter.css');

:root {
    /* Brand palette — distinctive Kalku indigo + amber accent */
    --indigo-50:  #eef2ff;
    --indigo-100: #e0e7ff;
    --indigo-200: #c7d2fe;
    --indigo-500: #6366f1;
    --indigo-600: #4f46e5;
    --indigo-700: #4338ca;
    --indigo-800: #3730a3;
    --indigo-900: #312e81;
    --indigo-950: #1e1b4b;

    --amber-100: #fef3c7;
    --amber-400: #fbbf24;
    --amber-500: #f59e0b;
    --amber-600: #d97706;

    --slate-50:  #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    --emerald-50:  #ecfdf5;
    --emerald-400: #34d399;
    --emerald-500: #10b981;
    --emerald-600: #059669;
    --emerald-700: #047857;

    --rose-100: #ffe4e6;
    --rose-500: #f43f5e;
    --rose-600: #e11d48;
    --rose-700: #be123c;

    /* Semantic tokens */
    --bg:            var(--slate-50);
    --bg-pattern:    radial-gradient(circle at 20% 0%, rgba(99,102,241,.04) 0%, transparent 40%),
                     radial-gradient(circle at 80% 100%, rgba(245,158,11,.03) 0%, transparent 40%);
    --surface:       #ffffff;
    --surface-2:     var(--slate-50);
    --border:        var(--slate-200);
    --border-strong: var(--slate-300);
    --text:          var(--slate-900);
    --text-muted:    var(--slate-500);

    --primary:        var(--indigo-700);
    --primary-hover:  var(--indigo-800);
    --primary-light:  var(--indigo-100);
    --accent:         var(--amber-500);
    --accent-hover:   var(--amber-600);
    --success:        var(--emerald-600);
    --danger:         var(--rose-600);
    --danger-hover:   var(--rose-700);

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow-sm:  0 1px 2px rgba(15, 23, 42, .04), 0 1px 1px rgba(15, 23, 42, .06);
    --shadow:     0 1px 3px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
    --shadow-lg:  0 8px 24px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .06);
    --shadow-color: 0 10px 40px -10px rgba(67, 56, 202, .35);
}

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

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
    font-feature-settings: "cv11", "ss01", "ss03";  /* nice Inter glyph variants */
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    background-image: var(--bg-pattern);
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

@supports (font-variation-settings: normal) {
    html, body { font-family: 'InterVariable', 'Inter', sans-serif; }
}

/* ---------- Topbar (branded gradient) ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: linear-gradient(92deg, var(--indigo-950) 0%, var(--indigo-800) 60%, var(--indigo-700) 100%);
    border-bottom: 1px solid var(--indigo-950);
    box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 4px 12px -6px rgba(15, 23, 42, .1);
    position: sticky;
    top: 0;
    z-index: 50;
}
.logo {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.01em;
    text-decoration: none;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.logo::before {
    content: '';
    display: inline-block;
    width: 28px;
    height: 28px;
    background:
        linear-gradient(135deg, var(--amber-400) 0%, var(--amber-600) 100%);
    border-radius: 7px;
    box-shadow: 0 2px 6px rgba(245, 158, 11, .4), inset 0 -1px 0 rgba(0,0,0,.15);
    flex-shrink: 0;
    position: relative;
}
.logo::after {
    content: '';
    position: absolute;
    left: 34px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--emerald-400);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(52, 211, 153, .25);
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 2px rgba(52, 211, 153, .25); }
    50%      { box-shadow: 0 0 0 5px rgba(52, 211, 153, .08); }
}

.topbar nav {
    display: flex;
    gap: 4px;
    align-items: center;
}
.greeting {
    color: rgba(255,255,255,.7);
    font-size: 13px;
    font-weight: 500;
    margin-right: 8px;
    padding: 4px 10px;
    background: rgba(255,255,255,.06);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,.08);
}
.nav-link {
    text-decoration: none;
    color: rgba(255,255,255,.82);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: background-color .15s ease, color .15s ease;
    position: relative;
}
.nav-link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}
.nav-link.logout:hover { background: rgba(239, 68, 68, .2); }

/* ---------- Layout ---------- */
.container {
    max-width: 1180px;
    margin: 32px auto;
    padding: 0 28px;
}

.footer {
    text-align: center;
    padding: 40px 16px 24px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ---------- Typography ---------- */
h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 20px;
    color: var(--text);
}
h2 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 16px;
    color: var(--text);
}
h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 20px 0 10px;
    color: var(--slate-700);
}

.subtle { color: var(--text-muted); font-size: 14px; }
.success-line { color: var(--success); font-weight: 500; }

/* ---------- Cards / panels ---------- */
.auth-card,
.policy-card,
.status-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: box-shadow .2s ease;
}
.panel:hover { box-shadow: var(--shadow-lg); }

.auth-card {
    max-width: 440px;
    margin: 8vh auto;
    padding: 36px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

/* ---------- Forms ---------- */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 18px;
}
.form-stack label { display: flex; flex-direction: column; gap: 6px; }
.form-stack label > span {
    font-weight: 500;
    font-size: 13px;
    color: var(--slate-700);
    letter-spacing: -.005em;
}
.form-stack label.checkbox {
    flex-direction: row;
    align-items: center;
    font-weight: 400;
    gap: 10px;
}

input[type="email"],
input[type="password"],
input[type="text"],
textarea,
select {
    font: inherit;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
    color: var(--text);
    width: 100%;
}
input:hover, textarea:hover, select:hover {
    border-color: var(--slate-400);
}
input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--indigo-100);
    background: var(--surface);
}
textarea {
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
    min-height: 88px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.005em;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s ease, transform .05s ease, box-shadow .15s ease, border-color .15s ease;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(15,23,42,.2), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-color), inset 0 1px 0 rgba(255,255,255,.12);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 1px 2px rgba(220,38,38,.25), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
    background: var(--slate-50);
    border-color: var(--slate-400);
}

.btn-small { padding: 6px 12px; font-size: 13px; border-radius: var(--radius-sm); }

/* ---------- Alerts ---------- */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius);
    margin: 16px 0 20px;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid transparent;
}
.alert-error   { background: var(--rose-100); color: var(--rose-700); border-color: rgba(244,63,94,.15); }
.alert-warning { background: var(--amber-100); color: var(--amber-600); border-color: rgba(245,158,11,.2); }
.alert-info    {
    background: linear-gradient(135deg, var(--indigo-50) 0%, #fafbff 100%);
    color: var(--indigo-800);
    border-color: var(--indigo-100);
}

/* ---------- Status cards (dashboard) ---------- */
.status-card { border-left: none; position: relative; overflow: hidden; }
.status-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--slate-300);
}
.status-card.status-active::before { background: linear-gradient(90deg, var(--emerald-500), var(--emerald-400)); }
.status-card.status-idle::before   { background: linear-gradient(90deg, var(--indigo-700), var(--indigo-500)); }

.status-card.status-active {
    background: linear-gradient(180deg, rgba(236,253,245,.8) 0%, var(--surface) 100%);
}

.status-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}
.pulse {
    width: 12px; height: 12px;
    background: var(--emerald-500);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, .6);
    animation: pulse 2s infinite;
    flex-shrink: 0;
}
.pulse-small {
    width: 8px; height: 8px;
    background: var(--emerald-500);
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); }
    70%  { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.readonly-text {
    background: var(--slate-50);
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    color: var(--slate-700);
    font-size: 14px;
    line-height: 1.55;
}

/* ---------- Tables ---------- */
.history-section { margin-top: 24px; }
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    font-size: 14px;
}
.table thead {
    background: var(--slate-50);
    border-bottom: 1px solid var(--border);
}
.table th {
    font-weight: 600;
    color: var(--slate-600);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.06em;
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    color: var(--text);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:hover { background: var(--slate-50); }
.wrap-cell {
    max-width: 320px;
    white-space: pre-wrap;
    word-break: break-word;
}
.row-active   { background: var(--emerald-50); }
.row-active:hover { background: var(--emerald-50) !important; }
.row-inactive { opacity: 0.55; }

/* ---------- Pills / badges ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: -0.005em;
    background: var(--slate-100);
    color: var(--slate-700);
}
.pill-active    { background: #d1fae5; color: #065f46; }
.pill-inactive  { background: var(--slate-200); color: var(--slate-500); }
.pill-admin     { background: var(--indigo-100); color: var(--indigo-800); }
.pill-warning   { background: var(--amber-100); color: var(--amber-600); }

/* ---------- Admin filters ---------- */
.filters {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.filter-form {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 0;
}
.filter-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--slate-600);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

/* ---------- Active-now panel (admin) ---------- */
.active-now-panel {
    background: linear-gradient(180deg, var(--emerald-50) 0%, var(--surface) 100%);
    border-color: rgba(16,185,129,.15);
}
.active-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.active-list li {
    padding: 12px 0;
    border-bottom: 1px solid rgba(16,185,129,.12);
}
.active-list li:first-child { padding-top: 0; }
.active-list li:last-child  { border-bottom: none; padding-bottom: 0; }
.active-plan {
    margin-top: 6px;
    color: var(--slate-600);
    font-size: 14px;
    padding-left: 14px;
    line-height: 1.5;
}

/* ---------- View-screen row (admin/screen) ---------- */
.view-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.view-row:last-child { border-bottom: none; }
.view-row-left { flex: 1; min-width: 0; }
.view-row-right { flex-shrink: 0; }
.view-row-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}
.view-row-buttons .btn { white-space: nowrap; min-width: 200px; }

/* ---------- Policy page ---------- */
.policy-content {
    background: var(--slate-50);
    padding: 22px 24px;
    border-radius: var(--radius);
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.7;
    margin: 18px 0 22px;
    max-height: 440px;
    overflow-y: auto;
    border: 1px solid var(--border);
    color: var(--slate-700);
}

/* ---------- Modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalFade .15s ease;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden { display: none; }
.modal-content {
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius-lg);
    max-width: 540px;
    width: 92%;
    box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
    animation: modalSlide .2s ease;
}
@keyframes modalSlide {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    justify-content: flex-end;
}
.vnc-url {
    display: block;
    background: var(--slate-900);
    color: var(--amber-400);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-family: "SF Mono", "JetBrains Mono", Menlo, monospace;
    font-size: 13px;
    word-break: break-all;
    margin: 12px 0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,.2);
    border: 1px solid var(--slate-800);
}

/* ---------- Actions row (admin/users) ---------- */
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .container { padding: 0 16px; margin: 20px auto; }
    .topbar {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .topbar nav { gap: 2px; }
    .nav-link { padding: 6px 10px; font-size: 13px; }
    .greeting { display: none; }
    .auth-card { margin: 20px auto; padding: 24px; }
    .panel, .status-card, .policy-card { padding: 20px; }
    h1 { font-size: 22px; }
    .filters { flex-direction: column; align-items: stretch; }
    .table { font-size: 13px; }
    .table th, .table td { padding: 10px 8px; }
    .wrap-cell { max-width: 180px; }
    .view-row { flex-direction: column; }
    .view-row-buttons .btn { min-width: 0; }
}

@media (prefers-color-scheme: dark) {
    /* Light-only for now — if you want dark mode later, we add tokens here. */
}
