:root {
    --bg: #000;
    --panel: #111;
    --line: #2a2a2a;
    --text: #fff;
    --muted: #8a8a8a;
    --good: #16a34a;
    --warn: #c9a227;
    --danger: #d11a2a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body, .app-body, .app-main, .page, .card, .panel, .auth-body {
    margin: 0;
    min-height: auto;
    color: #fff;
    background: #000 !important;
}

html, body {
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: #fff; text-decoration: none; }
h1, h2, h3 { margin: 0; }

.hint { color: var(--muted); font-size: 13px; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background: #000;
}

.auth-card { width: min(400px, 100%); }
.auth-card h1 { margin: 0 0 28px; font-size: 28px; }

.stack, form { display: grid; gap: 14px; }

label {
    display: grid;
    gap: 7px;
    font-size: 13px;
    color: var(--muted);
}

label.inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.robot-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #111;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.robot-box input {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: #fff;
    cursor: pointer;
}

.captcha-box {
    display: none;
    gap: 8px;
}
.captcha-box.is-open { display: grid; }
.captcha-q {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #111;
    border-radius: 10px;
    padding: 12px 13px;
}

input:focus, select:focus, textarea:focus {
    outline: 1px solid #fff;
    border-color: #fff;
}

textarea { resize: vertical; min-height: 160px; }

.btn {
    border: 0;
    border-radius: 10px;
    padding: 12px 16px;
    cursor: pointer;
    background: #1a1a1a;
}

.btn.primary { background: #fff; color: #000; font-weight: 700; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; }

.form-error, .form-msg { margin: 0; }
.form-error, .form-msg.bad { color: #ff8a8a; }
.form-msg.ok { color: #7dcc8f; }

.app-body {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
    background: #000;
}

.sidebar {
    padding: 22px 14px;
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.side-title { font-size: 18px; padding: 0 8px 18px; }

.sidebar nav { display: grid; gap: 8px; }

.sidebar nav a {
    display: block;
    text-align: left;
    background: #111;
    border: 1px solid #333;
    color: #fff;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
}

.sidebar nav a.on {
    background: #fff;
    color: #000;
    border-color: #fff;
}

.sidebar nav a:hover { border-color: #fff; }

.fab {
    position: fixed;
    right: 18px;
    bottom: 22px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #fff;
    color: #000;
    display: grid;
    place-items: center;
    z-index: 40;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.fab svg {
    width: 28px;
    height: 28px;
    display: block;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 28px 8px;
}

.topbar h1 { font-size: 26px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
    color: var(--muted);
    font-size: 13px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
}

.page {
    width: min(1120px, calc(100% - 40px));
    margin: 10px auto 88px;
    display: grid;
    gap: 16px;
}

.panel { display: none; gap: 16px; }
.panel.on { display: grid; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
}

.stat span { color: var(--muted); font-size: 12px; }
.stat b { display: block; margin-top: 8px; font-size: 24px; }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px;
}

.card.slim { width: min(460px, 100%); }
.card h2 { font-size: 18px; margin-bottom: 14px; }

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.card-head h2 { margin: 0; }

.table-wrap { overflow: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    text-align: left;
    padding: 11px 8px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th { color: var(--muted); font-weight: 500; }

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--line);
}

.badge.working, .badge.good { color: #7dcc8f; border-color: #16a34a; }
.badge.afk, .badge.warn { color: #e6c86a; border-color: #c9a227; }
.badge.idle { color: #aaa; }
.badge.offline, .badge.bad { color: #ff8a8a; border-color: #d11a2a; }

tr.suspicious { background: rgba(209, 26, 42, 0.08); }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
    border: 2px solid #fff !important;
    background: #000 !important;
    color: #fff !important;
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.chip.on {
    background: #fff !important;
    color: #000 !important;
}

.roster {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
}

.person {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #0a0a0a;
}

.person.slacking { border-color: #c9a227; }
.person.fake, .person.break_over { border-color: #d11a2a; background: #2a0000; }
.person.good { border-color: #16a34a; }
.person.break { border-color: #fff; }
.person.has-alert, .person.not_calling { border-color: #d11a2a; }

.alerts { display: grid; gap: 8px; }
.alert {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #333;
    background: #111;
}
.alert.red { border-color: #d11a2a; background: #2a0000; }
.alert.orange { border-color: #c9a227; background: #1a1400; }
.alert.ok { border-color: #16a34a; color: #9be7c2; }
.alert small { color: #bbb; }

.person-body { display: grid; gap: 3px; }
.person-body span, .person-body small { color: var(--muted); font-size: 12px; }
.person em { font-style: normal; font-size: 12px; color: #fff; }

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #1a1a1a;
    position: relative;
    font-weight: 700;
}

.dot {
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid #0a0a0a;
    background: #666;
}

.dot.live { background: #16a34a; }
.dot.afk { background: #c9a227; }
.dot.off { background: #666; }

.now-box {
    margin: 10px 0 14px;
    padding: 16px;
    border: 1px solid #fff;
    border-radius: 12px;
    font-size: 20px;
    font-weight: 700;
}

.timeline { display: grid; }
.tl {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid #222;
}
.tl-time { color: #fff; font-weight: 600; }
.tl p { margin: 4px 0 0; color: #9a9a9a; }
.tl.start, .tl.finish { border-left: 3px solid #fff; padding-left: 12px; }
.tl.call_ok { border-left: 3px solid #16a34a; padding-left: 12px; }
.tl.call_no { border-left: 3px solid #d11a2a; padding-left: 12px; }
.tl.break_start, .tl.break_end { border-left: 3px solid #c9a227; padding-left: 12px; }
.tl.break_over { border-left: 3px solid #d11a2a; padding-left: 12px; background: #1a0000; }

.agent-app {
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    background: #000 !important;
}

.agent-shell {
    width: min(440px, 100%);
    min-height: 100dvh;
    max-height: 100dvh;
    margin: 0 auto;
    background: #000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.agent-top,
.agent-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    padding: 14px 18px;
    border-bottom: 1px solid #222;
}

.agent-top {
    padding-top: calc(14px + env(safe-area-inset-top));
}

.agent-top strong,
.agent-toolbar strong {
    display: block;
    font-size: 15px;
}

.app-work-actions {
    display: flex;
    gap: 14px;
    flex-shrink: 0;
}

.app-kicker,
.agent-top p {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #888;
}

.app-link {
    border: 0;
    background: transparent;
    color: #fff;
    font-weight: 600;
    padding: 8px 0;
}

.app-link.danger { color: #ff8a8a; }

.agent-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    flex-shrink: 0;
    border-bottom: 1px solid #222;
}

.agent-stats div { padding: 10px 6px; text-align: center; }
.agent-stats span { display: block; color: #777; font-size: 10px; line-height: 1.2; }
.agent-stats b { display: block; margin-top: 4px; font-size: 16px; }

.agent-main {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 22px 18px 16px;
}

.agent-main h1 { font-size: 28px; margin: 8px 0 12px; }
.agent-main h2 { font-size: 18px; margin: 8px 0 0; }
.app-copy { color: #9a9a9a; line-height: 1.5; }

.agent-dock {
    display: grid;
    gap: 10px;
    flex-shrink: 0;
    padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid #222;
    background: #000;
}

.agent-dock[hidden] { display: none !important; }

.app-btn {
    width: 100%;
    border: 0;
    border-radius: 16px;
    min-height: 56px;
    font-size: 18px;
    font-weight: 700;
}

.app-btn.start { margin-top: 18px; }
.app-btn.start, .app-btn.call { background: #16a34a; color: #fff; }
.app-btn.yes { background: #fff; color: #000; }
.app-btn.no { background: transparent; color: #fff; border: 2px solid #fff; }

.app-contact { margin-top: 4px; }
.contact-phone {
    margin: 10px 0 0;
    font-size: clamp(26px, 8vw, 36px);
    font-weight: 700;
    line-height: 1.2;
    word-break: break-all;
}

.app-summary, .app-empty {
    margin-top: 22px;
    padding: 16px;
    background: #111;
    border: 1px solid #222;
    border-radius: 14px;
    color: #bbb;
}

.app-error { color: #ff8a8a; margin-top: 16px; }

@media (min-width: 860px) {
    .agent-app {
        padding: 24px;
        align-items: center;
    }
    .agent-shell {
        min-height: min(820px, calc(100dvh - 48px));
        max-height: calc(100dvh - 48px);
        border: 1px solid #2a2a2a;
        border-radius: 24px;
    }
    .agent-top { padding-top: 18px; }
    .agent-dock { padding-bottom: 18px; }
}

@media (max-width: 380px) {
    .agent-stats { grid-template-columns: repeat(2, 1fr); }
    .agent-toolbar { align-items: flex-start; }
}

@media (max-width: 860px) {
    .app-body {
        grid-template-columns: 1fr;
        padding-bottom: calc(72px + env(safe-area-inset-bottom));
    }
    .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        height: auto;
        z-index: 20;
        flex-direction: row;
        border-right: 0;
        border-top: 1px solid #222;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        background: #000;
    }
    .side-title { display: none; }
    .sidebar nav {
        display: flex;
        width: 100%;
        gap: 6px;
        overflow-x: auto;
    }
    .sidebar nav a {
        flex: 1;
        text-align: center;
        font-size: 12px;
        padding: 10px 6px;
        white-space: nowrap;
    }
    .topbar {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
        background: #000;
        border-bottom: 1px solid #222;
    }
    .topbar h1 { font-size: 20px; }
    .page { width: calc(100% - 24px); margin: 12px auto 24px; }
    .card { padding: 16px; }
    .card.slim { width: 100%; }
    .card-head { display: grid; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .roster { grid-template-columns: 1fr; }
    .tl { grid-template-columns: 1fr; gap: 4px; }
    .now-box { font-size: 17px; }
    .user-chip { display: none; }
    .fab {
        right: 14px;
        bottom: calc(78px + env(safe-area-inset-bottom));
    }
    table { font-size: 12px; }
}
