/* ===== RESET & BASE ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #202020;
    background: #f4f4f4;
}

/* ===== HEADER ===== */
header {
    height: 48px;
    padding: 0 18px;
    background: #252525;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

header a {
    color: #ddd;
    text-decoration: none;
}

/* ===== LAYOUT ===== */
.layout {
    display: grid;
    grid-template-columns: 380px minmax(520px, 1fr);
    min-height: calc(100vh - 48px);
}

.controls {
    background: #fff;
    border-right: 1px solid #cfcfcf;
    padding: 16px;
    overflow: auto;
}

.agents-area {
    padding: 16px;
    overflow: auto;
}

/* ===== TYPOGRAPHY ===== */
h2 {
    font-size: 18px;
    margin: 0 0 12px 0;
}

h3 {
    font-size: 15px;
    margin: 0 0 12px 0;
}

h4 {
    font-size: 14px;
    margin: 16px 0 12px 0;
}

.muted {
    color: #777;
    font-size: 12px;
}

/* ===== SELECTED AGENT ===== */
.selected {
    padding: 10px;
    margin-bottom: 12px;
    background: #f1f1f1;
    border: 1px solid #ccc;
}

.selected-name {
    font-weight: 700;
}

.selected-status {
    margin-top: 4px;
    font-size: 12px;
    color: #666;
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 12px;
}

.tabs button {
    padding: 6px 10px;
    background: #e9e9e9;
    border: 1px solid #aaa;
    border-radius: 2px;
    cursor: pointer;
    font-size: 12px;
    flex: 1 0 auto;
}

.tabs button:hover {
    background: #ddd;
}

.tabs button.primary {
    background: #333;
    color: #fff;
    border-color: #333;
}

.tabs button.primary:hover {
    background: #111;
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== BADGES ===== */
.watchdog-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 6px;
    border: 1px solid #2563eb;
    color: #1d4ed8;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    vertical-align: middle;
}

.usb-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 6px;
    border: 1px solid #059669;
    color: #059669;
    background: #ecfdf5;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    vertical-align: middle;
    border-radius: 2px;
}

.search-report-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 6px;
    border: 1px solid #7c3aed;
    color: #5b21b6;
    background: #ede9fe;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    vertical-align: middle;
    border-radius: 2px;
    cursor: pointer;
}

.screenshot-report-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 6px;
    border: 1px solid #dc2626;
    color: #991b1b;
    background: #fee2e2;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    vertical-align: middle;
    border-radius: 2px;
    cursor: pointer;
}

.usb-report-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 6px;
    border: 1px solid #d97706;
    color: #92400e;
    background: #fef3c7;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    vertical-align: middle;
    border-radius: 2px;
}

/* ===== AGENT LIST ===== */
.agents-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.summary {
    color: #666;
    font-size: 13px;
}

.agent-list {
    background: #fff;
    border: 1px solid #bbb;
}

.agent-row {
    display: grid;
    grid-template-columns: 28px minmax(180px, 1fr) 90px minmax(150px, 0.9fr) minmax(170px, 1fr) 92px 82px;
    align-items: center;
    min-height: 46px;
    padding: 7px 10px;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
}

.agent-row:last-child {
    border-bottom: 0;
}

.agent-row:hover {
    background: #f3f3f3;
}

.agent-row.active {
    outline: 2px solid #444;
    outline-offset: -2px;
    background: #ececec;
}

.agent-row.offline {
    color: #888;
    background: #fafafa;
}

.agent-row.offline:hover {
    background: #f1f1f1;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #aaa;
}

.online .dot {
    background: #18a34a;
}

.agent-name {
    font-weight: 600;
}

.agent-status {
    font-size: 12px;
    text-transform: uppercase;
}

.online .agent-status {
    color: #14813b;
    font-weight: 700;
}

.agent-id {
    color: #777;
    font-family: Consolas, monospace;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-network {
    color: #555;
    font-size: 12px;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-country {
    color: #777;
}

.empty {
    padding: 20px;
    color: #777;
}

/* ===== FORMS ===== */
input, textarea, button {
    font: inherit;
    border: 1px solid #aaa;
    border-radius: 2px;
}

input, textarea {
    width: 100%;
    padding: 8px;
    background: #fff;
    color: #111;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

button {
    padding: 8px 10px;
    background: #e9e9e9;
    color: #202020;
    cursor: pointer;
}

button:hover {
    background: #ddd;
}

button.btn-primary {
    background: #333;
    color: #fff;
    border-color: #333;
}

button.btn-primary:hover {
    background: #111;
}

button.danger {
    background: #fff;
    border-color: #c44;
    color: #a11;
}

button.danger:hover {
    background: #fee;
}

button.inventory-btn {
    padding: 4px 7px;
    background: #fff;
    border-color: #4b5563;
    color: #222;
}

button.inventory-btn:hover {
    background: #eee;
}

.row {
    display: flex;
    gap: 6px;
}

.row input {
    flex: 1;
}

/* ===== FILE LIST ===== */
.file {
    padding: 7px 4px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.file:hover {
    background: #f3f3f3;
}

.dir {
    cursor: pointer;
    font-weight: 600;
}

.file button {
    padding: 5px 7px;
}

/* ===== PRE ===== */
pre {
    min-height: 120px;
    margin: 10px 0 0;
    padding: 10px;
    background: #f7f7f7;
    border: 1px solid #ccc;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ===== MODAL ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-backdrop.hidden {
    display: none;
}

.inventory-modal {
    width: min(1100px, 96vw);
    max-height: 92vh;
    overflow: auto;
    background: #fff;
    border: 1px solid #777;
}

.inventory-modal-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #252525;
    color: #fff;
}

.inventory-modal-head h2 {
    margin: 0;
    font-size: 17px;
}

.inventory-modal-head button {
    margin: 0;
    padding: 5px 10px;
}

.inventory-modal-body {
    padding: 16px;
}

/* ===== INVENTORY ===== */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 12px;
}

.inventory-section {
    border: 1px solid #ccc;
    background: #fafafa;
    padding: 12px;
}

.inventory-section.full {
    grid-column: 1 / -1;
}

.inventory-section h3 {
    margin: 0 0 10px;
}

.kv {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 6px 10px;
}

.kv .key {
    color: #666;
}

.inventory-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.inventory-table th,
.inventory-table td {
    padding: 6px;
    border: 1px solid #ddd;
    text-align: left;
    vertical-align: top;
}

.inventory-table th {
    background: #eee;
}

.inventory-search {
    margin-bottom: 8px;
}

.security-ok {
    color: #087a36;
    font-weight: 700;
}

.security-bad {
    color: #b42318;
    font-weight: 700;
}

/* ===== USB TREE ===== */
.tree-children {
    padding-left: 0;
}

.file-item:hover {
    background: #f0f0f0;
}

.tree-toggle {
    cursor: pointer;
    user-select: none;
    width: 14px;
    display: inline-block;
}

.tree-toggle:hover {
    color: #2563eb;
}

#usbSnapshotTree ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

#usbSnapshotTree li {
    margin: 2px 0;
}

/* ===== CONTEXT MENU ===== */
.context-menu-item {
    padding: 6px 16px;
    cursor: pointer;
    font-size: 13px;
    color: #1f2937;
}

.context-menu-item:hover {
    background: #f3f4f6;
}

.context-menu-item:active {
    background: #e5e7eb;
}

/* ===== LOGIN ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f3f4f6;
}

.login-container {
    width: 320px;
    padding: 24px;
    background: #fff;
    border: 1px solid #d1d5db;
}

.login-container h1 {
    margin: 0 0 18px;
    font-size: 20px;
}

.login-form .form-group {
    margin-bottom: 12px;
}

.login-form input {
    padding: 10px;
}

.login-form .btn-primary {
    width: 100%;
    padding: 10px;
    margin-top: 8px;
}

.error-message {
    margin-top: 12px;
    color: #b42318;
    font-size: 14px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .controls {
        border-right: 0;
        border-bottom: 1px solid #ccc;
    }
    .agent-row {
        grid-template-columns: 24px 1fr 80px;
    }
    .agent-id {
        display: none;
    }
}

@media (max-width: 760px) {
    .inventory-grid {
        grid-template-columns: 1fr;
    }
    .kv {
        grid-template-columns: 130px 1fr;
    }
}

.hidden {
    display: none !important;
}

hr {
    border: 0;
    border-top: 1px solid #ccc;
    margin: 18px 0;
}