:root {
    --border: #d0d4da;
    --text: #1c1f24;
    --muted: #5b6270;
    --accent: #2456c7;
    --bg-alt: #f4f6f9;
    --error: #b3261e;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: #fff;
    margin: 0;
    line-height: 1.4;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.site-header {
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.site-header h1 { font-size: 1.15rem; margin: 0; }
.site-header a { color: var(--text); text-decoration: none; }
.site-header nav a {
    margin-left: 1rem;
    color: var(--accent);
    font-weight: 600;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--muted);
}
.user-bar a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-alt);
}
.login-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.login-card h1 {
    font-size: 1.1rem;
    margin: 0 0 1rem;
}
.login-card h2 {
    margin-top: 0;
}
.login-card .patch-form {
    max-width: none;
}

.site-footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 1.5rem;
}

h2 { margin-top: 0; }

.flash {
    background: #e6f4ea;
    border: 1px solid #34a853;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    display: inline-block;
}
.flash-error {
    background: #fdeceb;
    border-color: var(--error);
    color: var(--error);
    display: block;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1.5rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.filter-form { margin: 0; }
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-group label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.filter-group select, .filter-group input[type="search"] {
    min-width: 220px;
    padding: 0.4rem 0.5rem;
}

.clear-filter, .print-link {
    align-self: center;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.patch-table {
    width: 100%;
    border-collapse: collapse;
}

.patch-table th, .patch-table td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.6rem;
    text-align: left;
    vertical-align: top;
    font-size: 0.9rem;
}

.patch-table th {
    background: var(--bg-alt);
}

.patch-table tr:nth-child(even) td {
    background: #fbfbfc;
}

.notes-cell { max-width: 240px; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem; }

.actions-cell { white-space: nowrap; }
.actions-cell a { margin-right: 0.6rem; }

.inline-form { display: inline; }
.link-button {
    background: none;
    border: none;
    padding: 0;
    color: var(--error);
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
}

/* Forms */
.patch-form { max-width: 640px; }
.patch-form fieldset {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 1rem;
}
.patch-form legend { font-weight: 600; padding: 0 0.4rem; }
.form-row { margin-bottom: 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }
.form-row label { font-weight: 600; font-size: 0.9rem; }
.req { color: var(--error); }
.form-row input, .form-row textarea, .form-row select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
}
.form-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
button, .button-secondary {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font: inherit;
    text-decoration: none;
    display: inline-block;
}
.button-secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

/* Manage page (devices, ports, cable types) */
.muted { color: var(--muted); }

.manage-section {
    margin-bottom: 2rem;
}

.add-form {
    margin: 0.75rem 0 1.25rem;
}
.add-form input[type="text"] {
    min-width: 260px;
}

.device-picker-form {
    margin: 0 0 1.25rem;
}

.device-block {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-alt);
}

.device-block-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}
.device-block-header input[type="text"] {
    font-weight: 600;
}

.port-list {
    list-style: none;
    margin: 0.6rem 0 0;
    padding: 0 0 0 1rem;
    border-left: 2px solid var(--border);
}
.port-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.3rem 0;
}
.inline-form input[type="text"] {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
}
.inline-form button {
    padding: 0.35rem 0.7rem;
}

.inline-field-label {
    display: inline-flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
}

.location-tag {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    text-decoration: none;
}
a.location-tag:hover {
    text-decoration: underline;
}

.link-button-danger {
    background: none;
    border: 1px solid var(--error);
    color: var(--error);
    cursor: pointer;
    font: inherit;
    padding: 0.35rem 0.7rem;
    border-radius: 4px;
}

.user-row {
    flex-wrap: wrap;
}
.user-row-name {
    font-weight: 600;
    min-width: 160px;
}
.role-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    margin-left: 0.4rem;
}
.role-admin {
    background: #e6f4ea;
    color: #1e7b34;
}
.role-guest {
    background: var(--bg-alt);
    color: var(--muted);
}

/* Print view */
.print-toolbar {
    background: var(--bg-alt);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.print-toolbar span { color: var(--muted); font-size: 0.85rem; }
.print-page h1, .print-page h2, .print-page .print-meta, .print-page table {
    margin-left: 1.5rem;
    margin-right: 1.5rem;
}
.print-meta { color: var(--muted); font-size: 0.85rem; }
.print-table { width: calc(100% - 3rem); margin-top: 1rem; margin-bottom: 2rem; }

@media print {
    .print-toolbar { display: none; }
    body { font-size: 11pt; }
    .print-page h1, .print-page h2, .print-page .print-meta, .print-page table {
        margin-left: 0;
        margin-right: 0;
    }
    .print-table { width: 100%; }
    .patch-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .patch-table tr { break-inside: avoid; }
    a { color: inherit; text-decoration: none; }
}
