* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0f1117;
    color: #e2e8f0;
    min-height: 100vh;
}

header {
    background: #1a1d27;
    border-bottom: 1px solid #2d3148;
    padding: 18px 32px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #a78bfa;
    white-space: nowrap;
}

header h1 span { color: #64748b; font-weight: 400; font-size: 0.85rem; margin-left: 8px; }

#search {
    flex: 1;
    min-width: 200px;
    max-width: 340px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #2d3148;
    background: #0f1117;
    color: #e2e8f0;
    font-size: 0.9rem;
    outline: none;
    transition: border-color .2s;
}
#search:focus { border-color: #7c3aed; }

.filters {
    padding: 14px 32px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: #13151f;
    border-bottom: 1px solid #1e2133;
}

.filter-btn {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid #2d3148;
    background: transparent;
    color: #94a3b8;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all .2s;
}
.filter-btn:hover { border-color: #7c3aed; color: #a78bfa; }
.filter-btn.active { background: #7c3aed; border-color: #7c3aed; color: #fff; }

main {
    padding: 24px 32px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.app-card {
    background: #1a1d27;
    border: 1px solid #2d3148;
    border-radius: 12px;
    padding: 20px;
    transition: border-color .2s, transform .15s;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.app-card:hover { border-color: #4c1d95; transform: translateY(-2px); }
.app-card.hidden { display: none; }

.card-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.drag-handle {
    color: #2d3148;
    font-size: 1.1rem;
    line-height: 1;
    cursor: grab;
    padding: 2px 0;
    flex-shrink: 0;
    transition: color .15s;
    user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.app-card:hover .drag-handle { color: #475569; }

.app-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #f1f5f9;
}

.criticality {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}
.criticality.high   { background: #450a0a; color: #fca5a5; }
.criticality.medium { background: #422006; color: #fed7aa; }
.criticality.low    { background: #052e16; color: #86efac; }

.category-badge {
    font-size: 0.75rem;
    color: #7c3aed;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.description {
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.5;
    flex: 1;
}


.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid #1e2133;
    gap: 10px;
}

.status-badge {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}
.status-badge::before { content: '●'; font-size: 0.6rem; }
.status-RUNNING  { background: #052e16; color: #4ade80; }
.status-STARTS   { background: #422006; color: #fb923c; }
.status-BROKEN   { background: #450a0a; color: #f87171; }
.status-UNKNOWN  { background: #1e2133; color: #64748b; }

.db-info {
    font-size: 0.7rem;
    color: #475569;
    font-family: monospace;
}

.open-btn {
    display: inline-block;
    padding: 6px 16px;
    background: #4c1d95;
    color: #e9d5ff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    transition: background .2s;
    white-space: nowrap;
}
.open-btn:hover { background: #6d28d9; color: #fff; }

#no-results {
    grid-column: 1/-1;
    text-align: center;
    padding: 60px;
    color: #475569;
    font-size: 1rem;
    display: none;
}

/* ── Drag & Drop ──────────────────────────────────── */
.drag-ghost {
    opacity: 0.4;
    border: 1px dashed #7c3aed !important;
}

#save-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #052e16;
    color: #4ade80;
    border: 1px solid #166534;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 0.82rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s, transform .25s;
    pointer-events: none;
    z-index: 999;
}
#save-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Tools section ────────────────────────────────── */
.tools-section {
    margin-top: 6px;
    border-top: 1px solid #1e2233;
    padding-top: 8px;
}

.tools-header {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: #334155;
    margin-bottom: 6px;
}

.tool-row {
    display: grid;
    grid-template-columns: 10px 1fr auto;
    align-items: start;
    gap: 8px;
    padding: 5px 4px;
    border-radius: 4px;
    transition: background .12s;
}
.tool-row:hover { background: #13151f; }

.tool-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
    cursor: grab;
}
.tool-dot:active { cursor: grabbing; }
.tool-web  .tool-dot { background: #3b82f6; }
.tool-cron .tool-dot { background: #f97316; }

.tool-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tool-link {
    color: #93c5fd;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tool-link:hover { color: #dbeafe; text-decoration: underline; }

.tool-label {
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 500;
    font-style: italic;
    line-height: 1.3;
}

.tool-desc {
    color: #475569;
    font-size: 0.72rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-solo {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: .4px;
    color: #22d3ee;
    border: 1px solid #0e7490;
    border-radius: 3px;
    padding: 1px 4px;
    margin-top: 4px;
    white-space: nowrap;
    cursor: default;
    flex-shrink: 0;
}
