:root {
    --bg: #f4f5f7;
    --panel: #fff;
    --text: #1c1e24;
    --muted: #6b6f7a;
    --line: #e3e6ec;
    --accent: #58ab48;
    --accent-dark: #448c37;
    --danger: #c44848;
    --warn: #c9a227;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}
a { color: var(--accent-dark); text-decoration: none; }
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #141518;
}
.login-card {
    width: 380px;
    background: #fff;
    border-radius: 10px;
    padding: 28px 28px 22px;
    box-shadow: 0 16px 40px rgba(0,0,0,.28);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
label { display: block; font-size: 13px; margin: 0 0 6px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    background: #fff;
}
textarea { min-height: 72px; resize: vertical; }
.field { margin-bottom: 12px; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    padding: 9px 14px;
    font: inherit;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}
.btn:hover { background: var(--accent-dark); }
.btn-block { width: 100%; height: 42px; }
.btn-ghost { background: #eef0f4; color: var(--text); }
.btn-ghost:hover { background: #e2e5eb; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a33a3a; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.err { color: var(--danger); font-size: 13px; margin: 0 0 10px; }
.ok {
    background: #e8f6e4;
    color: #2f6b28;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 14px;
}
.hint { font-size: 12px; color: var(--muted); margin-top: 12px; }
.top {
    background: #202228;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
}
.top strong { color: var(--accent); }
.top .who { color: #c5c7ce; font-size: 13px; display: flex; gap: 12px; align-items: center; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 18px; }
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
}
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; font-size: 18px; flex: 1; }
.toolbar form.search { display: flex; gap: 8px; }
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 9px 8px; text-align: left; vertical-align: top; }
table.data th { font-size: 12px; color: var(--muted); font-weight: 600; }
.mono { font-family: Consolas, monospace; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge-on { background: #e8f6e4; color: #2f6b28; }
.badge-off { background: #f8e8e8; color: #8a2f2f; }
.badge-warn { background: #f7efd0; color: #7a6414; }
.badge-muted { background: #eef0f4; color: #555; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions form { display: inline-flex; margin: 0; }
.btn-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
}
.btn-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}
.sub { color: var(--muted); font-size: 12px; }
.code-cell { display: flex; align-items: center; gap: 8px; }
.code-mask { letter-spacing: 0.02em; }
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
}
.icon-btn:hover { background: #eef0f4; color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; }
.modal-close {
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    color: var(--muted);
}
.modal-close:hover { background: #eef0f4; color: var(--text); }
body.modal-open { overflow: hidden; }
.modal[hidden] { display: none !important; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 21, 24, 0.55);
}
.modal-card {
    position: relative;
    width: min(760px, 100%);
    max-height: calc(100vh - 36px);
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--line);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}
.modal-head, .modal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}
.modal-foot {
    border-bottom: 0;
    border-top: 1px solid var(--line);
    justify-content: flex-end;
}
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 16px; }
.detail-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid #f0f2f6;
}
.detail-label { color: var(--muted); font-size: 13px; }
.detail-value { font-size: 14px; word-break: break-word; }
.detail-code { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-section {
    margin: 16px 0 8px;
    font-size: 14px;
    font-weight: 600;
}
.detail-devices { margin-top: 4px; }
.detail-empty {
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
}
.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1100;
    background: #202228;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.toast[hidden] { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.empty { color: var(--muted); padding: 24px 8px; text-align: center; }
.pager { margin-top: 14px; }
.pager nav { display: flex; gap: 6px; flex-wrap: wrap; }
.pager a, .pager span { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
@media (max-width: 800px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .login-card { width: 92%; }
    .detail-row { grid-template-columns: 1fr; gap: 4px; }
}
