/* Vzhled sladěný s mikrotik.cernota.cz: teplý krémový light režim jako
   výchozí, oranžový akcent, zaoblené karty s jemným stínem, boční "rail"
   navigace s popisky. Tmavý režim přes přepínač v topbaru (localStorage). */
:root {
    --bg: #f7f5f1;
    --surface: #ffffff;
    --surface-2: #f1eee7;
    --rail: #ffffff;
    --border: #e8e3d9;
    --text: #201e1a;
    --text-2: #8b8477;
    --off: #cec8ba;

    --accent: #f2611d;
    --accent-2: #6d75e0;
    --ok: #1caa82;
    --warn: #dfa100;
    --crit: #e0483f;

    --wash-accent: rgba(242, 97, 29, .14);
    --wash-accent-soft: rgba(242, 97, 29, .07);
    --wash-crit: rgba(224, 72, 63, .14);
    --wash-warn: rgba(223, 161, 0, .14);
    --border-crit: rgba(224, 72, 63, .4);

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(30, 24, 10, .04), 0 10px 24px -10px rgba(30, 24, 10, .12);
}

:root[data-theme="dark"] {
    --bg: #171614;
    --surface: #201e1a;
    --surface-2: #292620;
    --rail: #1b1917;
    --border: #363228;
    --text: #f3efe6;
    --text-2: #a49a89;
    --off: #4c473c;

    --accent: #ff7a3d;
    --accent-2: #8990f5;
    --ok: #2fd39d;
    --warn: #f2b93d;
    --crit: #ff6259;

    --wash-accent: rgba(255, 122, 61, .16);
    --wash-accent-soft: rgba(255, 122, 61, .09);
    --wash-crit: rgba(255, 98, 89, .16);
    --wash-warn: rgba(242, 185, 61, .16);
    --border-crit: rgba(255, 98, 89, .4);

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 24px -10px rgba(0, 0, 0, .45);
}
:root[data-theme="light"] .only-dark { display: none; }
:root:not([data-theme="light"]) .only-light { display: none; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 13.5px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 21px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
h2 { font-size: 14.5px; margin: 26px 0 10px; font-weight: 700; color: var(--text-2); }
.muted { color: var(--text-2); font-size: 12px; }

/* ------- rozvržení: boční rail + obsah ------- */
.app { display: flex; min-height: 100vh; }
.rail {
    width: 220px; flex-shrink: 0;
    background: var(--rail);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 18px 14px;
    position: sticky; top: 0; height: 100vh;
}
.rail-logo {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 6px 18px; text-decoration: none !important;
}
.rail-logo-mark {
    font-size: 19px; width: 36px; height: 36px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); background: var(--surface-2);
}
.rail-logo-name { display: block; font-size: 13.5px; font-weight: 700; color: var(--text); line-height: 1.25; }
.rail-logo-sub { display: block; font-size: 11px; color: var(--text-2); line-height: 1.25; }
.rail-section-label {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-2); padding: 12px 10px 6px;
}
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-item {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 9px 10px; border-radius: var(--radius-sm);
    color: var(--text-2); font-size: 13.5px; font-weight: 500; background: none; border: none;
    font-family: inherit; cursor: pointer; text-align: left;
}
.rail-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.rail-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.rail-item.active { background: var(--surface-2); color: var(--text); font-weight: 700; }
.rail-item.active svg { color: var(--accent); }
.rail-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }

.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 22px 28px 6px;
    background: var(--bg);
    position: sticky; top: 0;
}
.tb-brand { line-height: 1.25; }
.tb-name { font-size: 13.5px; font-weight: 700; }
.tb-sub { font-size: 11px; color: var(--text-2); }
.tb-divider { width: 1px; height: 26px; background: var(--border); }
.topbar-status { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
    border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--text-2);
}
.pill-ok { color: var(--ok); }
.pill-bad { color: var(--crit); border-color: var(--border-crit); }
.icon-btn {
    width: 34px; height: 34px; padding: 0; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-2); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.content { padding: 10px 28px 40px; max-width: 1100px; width: 100%; }

/* ------- karty ------- */
.card {
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
    border-radius: var(--radius); padding: 16px 18px;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--text-2); }
.dot-on { background: var(--ok); box-shadow: 0 0 5px rgba(28, 170, 130, .5); }
.dot-off { background: var(--off); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 6px; }

.proj-card { display: flex; flex-direction: column; gap: 8px; }
.proj-name { font-weight: 700; font-size: 13.5px; }
.proj-desc { color: var(--text-2); font-size: 12.5px; line-height: 1.4; min-height: 34px; }
.proj-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; margin-top: 2px; }
.proj-status { color: var(--text-2); display: flex; align-items: center; min-width: 0; }
.proj-note { color: var(--text-2); font-size: 11.5px; margin-top: -2px; }

.ext-link {
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
    border-radius: var(--radius); padding: 14px 16px; display: block; font-weight: 700; font-size: 13.5px;
}
.ext-link:hover { color: var(--accent); text-decoration: none; }

/* ------- přihlášení ------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 36px 40px; width: 320px; text-align: center;
    display: flex; flex-direction: column; gap: 12px;
}
.login-logo {
    font-size: 26px; width: 52px; height: 52px; margin: 0 auto;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); background: var(--surface-2);
}
.login-box h1 { font-size: 19px; }
.login-box p { margin: 0; }
.login-box button { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.login-box button:hover { background: var(--accent); filter: brightness(1.08); }
.login-error { background: var(--wash-crit); color: var(--crit); border-radius: var(--radius-sm); padding: 8px; font-size: 13px; }

/* ------- formuláře ------- */
input, select, button {
    font: inherit; color: var(--text);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 7px 12px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }

/* ------- editor .env ------- */
.env-section { margin-bottom: 18px; }
.kv-row {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 10px;
    align-items: center;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: none; }
.kv-key { font-weight: 600; font-size: 12.5px; word-break: break-all; }
.kv-key .badge { display: block; font-weight: 400; font-size: 10.5px; color: var(--text-2); margin-top: 2px; }
.kv-row input[type="text"], .kv-row input[type="password"] { width: 100%; font-size: 12.5px; }
.kv-readonly { color: var(--text-2); font-size: 12.5px; }

.save-bar {
    position: sticky; bottom: 0;
    background: var(--bg);
    padding: 14px 0; margin-top: 10px;
    display: flex; justify-content: flex-end;
}
.save-bar button {
    padding: 10px 22px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
    border-radius: var(--radius-sm);
}
.save-bar button:hover { filter: brightness(1.08); }

.flash-ok {
    background: var(--wash-accent); border: 1px solid var(--accent); color: var(--accent);
    padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px;
}

@media (max-width: 760px) {
    .app { flex-direction: column; }
    .rail {
        width: 100%; height: auto; position: static;
        flex-direction: row; align-items: center; padding: 8px 10px;
    }
    .rail-logo-name, .rail-logo-sub, .rail-section-label { display: none; }
    .rail-logo { padding: 4px; }
    .rail-nav { flex-direction: row; }
    .rail-item { width: 40px; height: 40px; padding: 0; justify-content: center; }
    .rail-item span:not(.rail-badge) { display: none; }
    .rail-foot { margin: 0 0 0 auto; padding-top: 0; border-top: 0; }
    .tb-brand, .tb-divider { display: none; }
    .content { padding: 12px; }
    .kv-row { grid-template-columns: 1fr; }
}
