:root {
    --bg: #0f172a;
    --bg-soft: #111827;
    --card: #1f2937;
    --card-border: #374151;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --ok: #065f46;
    --ok-border: #10b981;
    --error: #7f1d1d;
    --error-border: #ef4444;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, Segoe UI, Arial, sans-serif;
    background: linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
    color: var(--text);
}

.layout {
    max-width: 1480px;
    margin: 0 auto;
    padding: 24px;
}

.card {
    background: rgba(31, 41, 55, 0.95);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.hero h1 {
    margin: 0 0 6px;
    font-size: 1.9rem;
}

.hero p {
    margin: 0;
    color: var(--muted);
}

.stats {
    display: flex;
    gap: 14px;
}

.stat {
    min-width: 124px;
    background: #111827;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 10px;
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
}

.stat-label {
    color: var(--muted);
    font-size: 0.82rem;
}

.grid-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

h2, h3 {
    margin-top: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.form-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--muted);
}

label.full {
    grid-column: 1 / -1;
}

input,
textarea,
select,
button {
    border-radius: 8px;
    border: 1px solid #4b5563;
    background: #111827;
    color: var(--text);
    padding: 10px;
    font-size: 0.92rem;
}

textarea {
    resize: vertical;
}

.btn {
    cursor: pointer;
    border-color: #6b7280;
    background: #374151;
    color: #fff;
    font-weight: 600;
}

.btn:hover {
    filter: brightness(1.08);
}

.btn.primary {
    background: var(--accent);
    border-color: var(--accent-hover);
}

.btn.danger {
    background: #991b1b;
    border-color: #ef4444;
}

.btn.small {
    padding: 8px 10px;
    font-size: 0.85rem;
}

.flash {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    border: 1px solid;
}

.flash.ok {
    background: var(--ok);
    border-color: var(--ok-border);
}

.flash.error,
.inline-error {
    background: var(--error);
    border-color: var(--error-border);
}

.converter-result {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    background: #0b1325;
}

.rates {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.rates label span {
    color: var(--text);
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    color: var(--muted);
    font-weight: 600;
    padding: 10px 8px;
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}

tbody td {
    padding: 8px;
    border-bottom: 1px solid rgba(75, 85, 99, 0.35);
    vertical-align: middle;
}

tbody tr:hover {
    background: rgba(17, 24, 39, 0.55);
}

.priority-row-high td:first-child {
    border-left: 4px solid #ef4444;
}

.priority-row-medium td:first-child {
    border-left: 4px solid #f59e0b;
}

.priority-row-low td:first-child {
    border-left: 4px solid #10b981;
}

.priority-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.priority-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    width: fit-content;
}

.priority-high {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.5);
}

.priority-medium {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.5);
}

.priority-low {
    background: rgba(16, 185, 129, 0.2);
    color: #86efac;
    border: 1px solid rgba(16, 185, 129, 0.5);
}

.row-form {
    display: contents;
}

td input,
td select {
    width: 100%;
    min-width: 90px;
    padding: 8px;
    font-size: 0.85rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.top-links {
    display: flex;
    gap: 10px;
}

.quick-nav p {
    color: var(--muted);
    margin-bottom: 12px;
}

/* Equipment table styles */
.equipment-table tbody tr {
    transition: background 0.2s ease;
}

.equipment-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.08);
}

.equipment-table tbody tr.has-hits {
    background: rgba(16, 185, 129, 0.06);
}

.equipment-table tbody tr.has-hits:hover {
    background: rgba(16, 185, 129, 0.12);
}

.equipment-table tbody tr.no-hits {
    opacity: 0.6;
}

.equipment-table tbody tr.no-hits:hover {
    opacity: 0.8;
}

.equipment-table th:nth-child(1) {
    width: 50px;
    text-align: center;
}

.equipment-table th:nth-child(2) {
    width: 220px;
}

.equipment-table th:nth-child(3) {
    min-width: 280px;
}

.equipment-table th:nth-child(4) {
    display: none;
}

.equipment-table th:nth-child(5) {
    width: 120px;
    text-align: center;
}

.equipment-table th:nth-child(6) {
    width: 180px;
}

.equipment-table td:nth-child(1) {
    text-align: center;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
}

.equipment-table td:nth-child(4) {
    display: none;
}

.equipment-table td:nth-child(5) {
    text-align: center;
}

.brand-cell {
    font-weight: 600;
    color: #60a5fa;
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.model-cell {
    font-size: 0.92rem;
    line-height: 1.4;
}

.hits-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1rem;
    min-width: 60px;
    justify-content: center;
}

.hits-badge.has-results {
    background: rgba(16, 185, 129, 0.25);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.5);
}

.hits-badge.no-results {
    background: rgba(107, 114, 128, 0.2);
    color: var(--muted);
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.hits-badge .emoji {
    font-size: 1.1rem;
}

.links-cell-empty {
    color: var(--muted);
    font-style: italic;
    font-size: 0.88rem;
}

.pln-range {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #d1d5db;
    font-size: 0.88rem;
    white-space: nowrap;
}

.menu {
    margin-bottom: 24px;
    border-left: 5px solid var(--accent);
}

.menu h2 {
    margin-top: 0;
    color: var(--accent);
    font-size: 1.25rem;
}

.menu-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.menu-link {
    display: inline-block;
    padding: 10px 16px;
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid var(--accent);
    border-radius: 8px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.menu-link:hover {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.report-stats {
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.meta-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
}

.meta-list li {
    margin-bottom: 4px;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.portal-card {
    background: #111827;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 12px;
}

.portal-card h3 {
    margin: 0 0 8px;
    text-transform: capitalize;
}

.portal-details {
    margin-top: 4px;
}

.portal-details summary {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(37, 99, 235, 0.15);
    border: 1px solid rgba(37, 99, 235, 0.4);
    border-radius: 6px;
    color: #60a5fa;
    font-weight: 600;
    font-size: 0.88rem;
    user-select: none;
    transition: all 0.2s ease;
}

.portal-details summary:hover {
    background: rgba(37, 99, 235, 0.25);
    border-color: rgba(37, 99, 235, 0.6);
    color: #93c5fd;
}

.portal-details[open] summary {
    margin-bottom: 12px;
    background: rgba(37, 99, 235, 0.2);
    border-color: var(--accent);
}

.portal-count {
    color: var(--muted);
    font-weight: 500;
    font-size: 0.9rem;
}

.portal-links {
    margin: 0;
    padding-left: 0;
    max-height: 320px;
    overflow: auto;
    list-style: none;
}

.portal-links li {
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    border: 1px solid rgba(75, 85, 99, 0.3);
    transition: all 0.2s ease;
}

.portal-links li:hover {
    background: rgba(17, 24, 39, 0.6);
    border-color: rgba(75, 85, 99, 0.5);
}

.portal-links a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.portal-links a:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.link-meta {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 4px;
    border-left: 2px solid rgba(75, 85, 99, 0.4);
}

.link-title {
    color: #cbd5e1;
    font-size: 0.84rem;
    line-height: 1.4;
}

.link-price {
    color: #34d399;
    font-size: 0.86rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.portal-links a {
    color: #93c5fd;
    text-decoration: none;
}

.portal-links a:hover {
    text-decoration: underline;
}

.muted {
    color: var(--muted);
}

.report-table th:last-child,
.report-table td:last-child {
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 1200px) {
    .grid-two {
        grid-template-columns: 1fr;
    }

    .hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats {
        width: 100%;
    }

    .menu-items {
        flex-direction: column;
    }

    .menu-link {
        width: 100%;
    }

    .report-grid {
        grid-template-columns: 1fr;
    }
}
