@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #0b141a;
    --panel: #111b21;
    --panel-2: #1f2c33;
    --line: rgba(174, 186, 193, 0.16);
    --text: #e9edef;
    --muted: #aebac1;
    --green: #00a884;
    --blue: #4aa3ff;
    --red: #ff5b5b;
    --amber: #f6b94b;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

.admin-shell {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

.login-panel {
    width: min(420px, calc(100vw - 32px));
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
}

.brand-mark {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--green);
    color: white;
    font-weight: 700;
}

.login-panel h1,
.admin-header h1,
.table-section h2 {
    margin: 0;
    letter-spacing: 0;
}

.login-panel form {
    display: grid;
    gap: 14px;
    padding: 22px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
}

input,
select {
    width: 100%;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
}

.login-panel button,
.action-btn,
.icon-btn {
    border: 0;
    cursor: pointer;
    color: var(--text);
}

.login-panel button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--green);
    font-weight: 700;
}

.message {
    min-height: 20px;
    color: var(--red);
}

.dashboard-panel {
    width: min(1440px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 28px 0 48px;
}

.admin-header,
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.eyebrow {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--line);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin: 24px 0;
}

.metric {
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.metric strong {
    display: block;
    font-size: 26px;
    line-height: 1.1;
}

.metric span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.table-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.section-header {
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.legend {
    display: flex;
    gap: 14px;
    color: var(--muted);
    font-size: 13px;
}

.dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 999px;
    margin-right: 6px;
}

.dot.active {
    background: var(--green);
}

.dot.inactive {
    background: var(--red);
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
}

th {
    color: var(--muted);
    font-weight: 600;
}

tr:last-child td {
    border-bottom: 0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 86px;
    justify-content: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
}

.status-pill.active {
    background: rgba(0, 168, 132, 0.18);
    color: #77e0c8;
}

.status-pill.inactive {
    background: rgba(255, 91, 91, 0.16);
    color: #ff9a9a;
}

.status-pill.warning {
    background: rgba(255, 193, 7, 0.16);
    color: #ffd76d;
}

.dot.warning {
    background: #ffc107;
}

.slot-runtime {
    display: inline-flex;
    align-items: center;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 700;
}

.slot-runtime-ok {
    color: #77e0c8;
}

.slot-runtime-warning {
    color: #ffd76d;
}

.slot-runtime-error {
    color: #ff9a9a;
}

.slot-main-row.expanded td {
    background: rgba(24, 68, 96, 0.2);
}

.slot-title-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slot-title-cell > div {
    display: grid;
    gap: 3px;
}

.slot-expand-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    display: inline-grid;
    place-items: center;
}

.slot-expand-btn .material-icons-round {
    font-size: 20px;
}

.slot-detail-row.hidden {
    display: none;
}

.slot-detail-row > td {
    padding-top: 0;
    background: rgba(17, 27, 33, 0.72);
}

.slot-detail-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: rgba(32, 44, 51, 0.74);
}

.slot-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.slot-detail-block {
    display: grid;
    align-content: start;
    gap: 6px;
    min-width: 0;
}

.slot-detail-block h3 {
    margin: 0 0 3px;
    font-size: 13px;
    color: var(--muted);
}

.slot-detail-block p {
    margin: 0;
}

.slot-actions-detail {
    margin-top: 14px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 34px;
    padding: 7px 9px;
    border-radius: var(--radius);
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 12px;
}

.action-btn .material-icons-round {
    font-size: 17px;
}

.action-btn.danger {
    color: #ffc4c4;
    border-color: rgba(255, 91, 91, 0.35);
}

.action-btn.primary {
    color: #c5fff0;
    border-color: rgba(0, 168, 132, 0.45);
}

.action-btn:disabled,
.action-btn.loading {
    opacity: 0.62;
    cursor: wait;
}

.muted {
    color: var(--muted);
}

.ai-summary {
    display: grid;
    gap: 4px;
    min-width: 180px;
}

.ai-summary strong {
    font-size: 13px;
}

.ai-summary span {
    color: var(--muted);
    font-size: 12px;
}

.admin-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
}

.admin-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
}

.admin-modal-panel {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    max-height: min(760px, calc(100vh - 40px));
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.admin-modal-header h2 {
    margin: 0;
    letter-spacing: 0;
}

.ai-config-form {
    display: grid;
    gap: 16px;
    padding: 18px;
}

.ai-model-chain {
    display: grid;
    gap: 12px;
}

.ai-native-tools-section {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02);
}

.ai-native-tools-section h3 {
    margin: 0 0 4px;
    font-size: 15px;
    letter-spacing: 0;
}

.ai-native-tools-section p {
    margin: 0;
    font-size: 13px;
}

.ai-native-tools {
    display: grid;
    gap: 10px;
}

.native-tool-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-2);
}

.native-tool-toggle span {
    display: grid;
    gap: 4px;
}

.native-tool-toggle strong {
    color: var(--text);
    font-size: 14px;
}

.native-tool-toggle small {
    color: var(--muted);
    font-size: 12px;
}

.native-tool-toggle input {
    width: 20px;
    height: 20px;
    accent-color: var(--green);
    flex: 0 0 auto;
}

.ai-model-row {
    display: grid;
    grid-template-columns: 1.35fr 0.85fr;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02);
}

.ai-model-row-title {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    max-width: min(560px, calc(100vw - 48px));
    padding: 14px 16px;
    background: #24353d;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.32);
    color: var(--text);
    word-break: break-word;
}

@media (max-width: 980px) {
    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ai-model-row {
        grid-template-columns: 1fr;
    }
}
