:root {
    --text: #212529;
    --muted: #6c757d;
    --line: #ced4da;
    --link: #41b956;
    --accent: #28a745;
    --accent-border: #3e8f3e;
    --danger: #dc3545;
    --card: #fff;
    --radius: 4px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: #e9ecef;
}

.bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: #c5d0c8 url("/img/city.jpg") center / cover no-repeat;
}

.mainmenu {
    padding: 0;
}

.navbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
    padding: 8px 16px;
}

.navbar-brand {
    color: rgba(0, 0, 0, 0.9);
    text-decoration: none;
    font-size: 20px;
}

.navbar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
}

.nav-link {
    color: rgba(0, 0, 0, 0.7);
    text-decoration: none;
}

.nav-link:hover,
.nav-link.is-active {
    color: rgba(0, 0, 0, 0.95);
}

.navbar-out {
    margin-left: auto;
}

.navbar-out button {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: inherit;
    border-radius: var(--radius);
    padding: 4px 10px;
    cursor: pointer;
    font: inherit;
}

.container {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto 16px;
    padding: 0 15px 16px;
    background: #fff;
    border-radius: 0 0 10px 10px;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 8px 0 0;
    font-size: 16px;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    padding-right: 6px;
    color: #6c757d;
}

.breadcrumb a {
    color: var(--link);
    text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

.icon-home {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.1em;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1 1 7h2v8h4V9h2v6h4V7h2L8 1z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.display-4 {
    font-size: 40px;
    font-weight: 300;
    line-height: 1.2;
    margin: 0 0 8px;
}

h1 { font-size: 40px; font-weight: 300; line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 1.5rem; font-weight: 500; margin: 16px 0 8px; }
h3 { font-size: 28px; font-weight: 500; line-height: 1.2; margin: 16px 0 8px; }

p { margin: 0 0 16px; }

a { color: var(--link); }
a:hover { color: #2f9a46; }

.lead-row {
    overflow: hidden;
}

.alice-badge {
    float: right;
    margin: 0 0 12px 16px;
}

.alice-badge img {
    display: block;
    height: 40px;
}

.card {
    background: var(--card);
    border: 0;
    border-radius: 0;
    padding: 0;
    margin: 0 0 16px;
}

.card--narrow { max-width: 100%; }

.muted, .hint, .form-text { color: var(--muted); }
.hint, .form-text { font-size: 0.875rem; margin: 0 0 16px; }
.code { font-size: 1.4rem; letter-spacing: 0.08em; }

.stack { display: grid; gap: 10px; margin-bottom: 16px; }
.stack > .btn,
.stack > button,
.rule-form > .btn,
.rule-form > button {
    justify-self: start;
    width: auto;
}
.grid-2 {
    display: grid;
    gap: 10px;
}
@media (min-width: 720px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
}

.form-group { margin: 0 0 16px; }
.form-group label,
label { display: block; margin: 0 0 8px; font-size: 16px; }
label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
.form-control {
    display: block;
    width: 100%;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    color: #495057;
    background: #fff;
    line-height: 1.5;
}

.btn {
    display: inline-block;
    border: 1px solid var(--line);
    background: #fff;
    padding: 6px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font: inherit;
    line-height: 1.5;
    text-decoration: none;
    color: var(--text);
}

.btn:hover { text-decoration: none; }

.btn--primary,
.btn-success {
    background: var(--accent);
    border-color: var(--accent-border);
    color: #fff;
}

.btn--primary:hover,
.btn-success:hover {
    background: #218838;
    border-color: #1e7e34;
    color: #fff;
}

.btn--danger {
    color: var(--danger);
    border-color: #f1b0b7;
    background: #fff;
}

.btn--small { padding: 4px 8px; font-size: 0.9rem; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
}

.toolbar form { margin: 0; }

.alert {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 10px 12px;
    border-radius: var(--radius);
    margin: 0 0 16px;
}

.alert--error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.rule {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: var(--radius);
    padding: 8px 14px 14px;
    margin: 0 0 10px;
}

.rule summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
    font-weight: 600;
}

.rule__n {
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    min-width: 1.5rem;
    height: 1.5rem;
    display: inline-grid;
    place-items: center;
    font-size: 0.8rem;
}

.rule__links { margin: 0 0 8px; }

.tag {
    font-size: 0.75rem;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 999px;
    font-weight: 400;
}

.devices { list-style: none; padding: 0; margin: 0; }
.devices li {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.device-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    flex: 1;
}

.device-actions {
    display: flex;
    gap: 8px;
    margin: 0 0 12px;
}

.steps { margin: 8px 0 16px; padding-left: 20px; }
.steps li { margin-bottom: 6px; }

.type-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
}

.type-btn {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    text-decoration: none;
}

.type-btn:hover { color: var(--text); }

.type-btn.is-active {
    background: var(--accent);
    border-color: var(--accent-border);
    color: #fff;
}

.log {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    margin-bottom: 16px;
}

.log th, .log td {
    border: 1px solid #dee2e6;
    padding: 6px 8px;
    text-align: left;
    font-size: 0.9rem;
    vertical-align: top;
}

.about h2 { font-size: 1.25rem; }
.about ol { margin: 0 0 16px; padding-left: 20px; }

@media (max-width: 767px) {
    .display-4, h1 { font-size: 28px; }
    h3 { font-size: 22px; }
    .alice-badge { float: none; margin: 0 0 12px; }
}

body.modal-open { overflow: hidden; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 12px;
    background: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal.is-open {
    display: flex;
}

.modal-dialog {
    width: 100%;
    max-width: 500px;
    margin: 30px auto;
}

.modal-dialog--wide { max-width: 760px; }

.modal-content {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.modal-header,
.modal-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
}

.modal-header {
    border-bottom: 1px solid #dee2e6;
    justify-content: space-between;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.modal-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 500;
}

.modal-close {
    border: 0;
    background: transparent;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: #000;
    opacity: 0.5;
    padding: 0 4px;
}

.modal-close:hover { opacity: 0.85; }

.modal-body { padding: 16px; }

.modal-subtitle {
    margin: 16px 0 8px;
    font-size: 1rem;
}

.modal-table { margin: 0; }

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