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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #10b981;
    --error-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Loading Screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--background);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-screen p {
    margin-top: 1rem;
    color: var(--text-secondary);
}

/* Login gateway */
.login-gateway-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-secondary);
    padding: 1rem;
}

.login-gateway-card {
    background: var(--surface);
    border-radius: 0.75rem;
    padding: 3rem 2.5rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 360px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.login-gateway-logo {
    height: 72px;
    width: auto;
    margin-bottom: 0.5rem;
}

.login-gateway-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.login-gateway-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0 0 1rem;
    line-height: 1.5;
}

.login-gateway-btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

/* Access Denied */
.access-denied-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--background);
    padding: 1rem;
}

.access-denied-card {
    background: var(--surface);
    border-radius: 0.75rem;
    padding: 3rem 2rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 420px;
    width: 100%;
}

.access-denied-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    line-height: 1;
}

.access-denied-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.access-denied-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Navbar */
.navbar {
    background-color: var(--surface);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
}

.nav-brand-logo {
    height: 40px;
    width: auto;
    display: block;
}

.nav-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.nav-brand-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.webapp-version-badge {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 0.5rem;
}

.nav-link {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.nav-link:hover {
    background-color: var(--background);
    color: var(--text-primary);
}

.nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.username {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.container {
    width: 100%;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Cards */
.card {
    background-color: var(--surface);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Clickable cards — adapter cards and internal nav cards on the home page */
.adapter-card,
.card-nav {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.adapter-card:hover,
.card-nav:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.adapter-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.adapter-card-title-block {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.adapter-card-title-block h3 {
    margin-bottom: 0;
}

.adapter-icon-large {
    font-size: 3rem;
    line-height: 1;
}

.piece-version-badge {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.2;
    white-space: nowrap;
}

.piece-version-badge:empty {
    display: none;
}

/* ── Expandable multi-instance piece cards ───────────────────────────────── */

/* The whole card is the click target for expand/collapse */
.adapter-card-multi {
    cursor: pointer;
    user-select: none;
}

/* Instance rows are independently clickable — restore default cursor inside them */
.adapter-card-multi .piece-instance-row {
    cursor: pointer;   /* already interactive, keep pointer */
    user-select: none;
}

/* The +/− button is interactive — restore text cursor would be wrong, keep pointer */

/* +/− toggle button */
.piece-toggle-btn {
    margin-left: auto;
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 1.75rem;
    height: 1.75rem;
    font-size: 1.2rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.piece-toggle-btn:hover {
    background: var(--background);
    color: var(--text-primary);
    border-color: var(--secondary-color);
}

/* Instance rows panel (hidden when card is collapsed) */
.piece-instances-panel {
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 0.25rem;
}

.piece-instance-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background 0.1s;
}

.piece-instance-row:hover {
    background: var(--background);
}

/* Piece name label (small uppercase, left column inside an instance row) */
.piece-instance-piece-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    min-width: 5rem;
}

/* Instance display name (main text) */
.piece-instance-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

/* Per-instance version badge inside an instance row */
.piece-instance-version {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ── Status page table ───────────────────────────────────────────────────── */

.status-table {
    width: 100%;
    border-collapse: collapse;
    /* Fixed layout: column widths are determined by the header row and never
       recalculated when rows expand or collapse. */
    table-layout: fixed;
}

.status-table th:nth-child(1) { width: 55%; }
.status-table th:nth-child(2) { width: 25%; }
/* Status column gets the remaining 20% */

.status-table th,
.status-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    /* Prevent long check names or instance ids from overflowing their cell */
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-table th {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--background);
}

.status-table tbody tr:last-child td {
    border-bottom: none;
}

.status-table tbody tr:hover td {
    background: var(--background);
}

/* Rows with expandable check details get a pointer cursor on the whole row. */
.status-table tbody tr.hc-row-expandable {
    cursor: pointer;
}

.status-cell-piece {
    font-weight: 500;
    vertical-align: top;
}

.status-cell-instance {
    color: var(--text-secondary);
    vertical-align: top;
}

.status-table-loading {
    text-align: center;
    padding: 2.5rem;
}

.status-table-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.status-no-checks {
    color: var(--text-secondary);
}

/* ── Health Checks page — expandable status rows ────────────────────────── */

/* Spinner-only placeholder while a row's status is loading */
.hc-loading {
    display: flex;
    align-items: center;
}

/* Wraps a status-dot and gives it the correct state colour via status-{state} */
.hc-dot {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

/* Summary area: aggregate dot + optional expand chevron */
.hc-summary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* +/− expand button — same visual style as the Pieces card toggle */
.hc-expand-btn {
    margin-right: 0.5rem;
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.hc-expand-btn:hover {
    background: var(--background);
    color: var(--text-primary);
    border-color: var(--secondary-color);
}

/* Invisible placeholder — same size as .hc-expand-btn — keeps piece names aligned
   for rows that have no expandable checks */
.hc-expand-spacer {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

/* Per-check detail panel — shown below the summary when expanded */
.hc-detail-panel {
    padding-top: 0.4rem;
    padding-left: 1.35rem;   /* indent relative to the aggregate dot */
}

/* One individual check row: dot + label */
.hc-check-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0;
}

.hc-check-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Piece-name cell: flex so the [+] button sits inline before the name */
.status-cell-piece {
    display: flex;
    align-items: center;
}

.hc-piece-name {
    white-space: nowrap;
}

/* Meta row shown below the Health Checks page title (last-updated + countdown) */
.hc-page-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0;
}

.hc-page-meta-item {
    min-height: 1.1em;   /* reserve space so layout doesn't jump while loading */
}

.adapter-card-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    min-height: 3rem;
}

/* Status Indicators */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.4rem 0;
    margin-bottom: 0.75rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-ok { color: #065f46; }
.status-ok .status-dot {
    background-color: var(--success-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
    animation: pulse 2.5s ease-in-out infinite;
}

.status-warning { color: #92400e; }
.status-warning .status-dot {
    background-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.status-error { color: #991b1b; }
.status-error .status-dot {
    background-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.status-unconfigured { color: var(--text-secondary); }
.status-unconfigured .status-dot { background-color: var(--secondary-color); }

.status-unknown { color: var(--text-secondary); }
.status-unknown .status-dot { background-color: var(--border-color); }

.status-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.4rem 0;
    margin-bottom: 0.75rem;
}

.status-spinner {
    width: 10px;
    height: 10px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Plugin Config Page */
.plugin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.plugin-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.plugin-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.plugin-icon-large {
    font-size: 3.5rem;
    line-height: 1;
}

.plugin-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.plugin-loading {
    display: flex;
    justify-content: center;
    padding: 3rem;
}

/* Forms */
.form-section {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background-color: var(--background);
    border-radius: 0.375rem;
}

.form-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.2s;
    background-color: var(--surface);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
    background-color: var(--background);
    cursor: not-allowed;
}

.form-group .hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Messages */
.info-message {
    padding: 1rem;
    background-color: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    color: #92400e;
    font-size: 0.875rem;
}

.lambda-version-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background-color: var(--primary-color);
    color: #fff;
    vertical-align: middle;
    letter-spacing: 0.02em;
}

.env-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.env-table td {
    padding: 0.375rem 0.5rem;
    vertical-align: middle;
}

.env-key {
    width: 40%;
    font-family: monospace;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
}

.env-value {
    font-family: monospace;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.checkbox-inline-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: var(--surface);
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-input:disabled {
    background-color: var(--background);
    cursor: not-allowed;
}

.field-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.field-hint-set   { color: var(--success-color); }
.field-hint-unset { color: var(--text-secondary); }

.form-input-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.875rem;
    width: 100%;
}

.list-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.list-items {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.list-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.list-item .form-input {
    flex: 1;
}

.btn-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 0.375rem;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.btn-icon:hover {
    background-color: #fef2f2;
    border-color: var(--error-color, #ef4444);
    color: var(--error-color, #ef4444);
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    align-self: flex-start;
}

.alert {
    padding: 0.875rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.alert-warning {
    background-color: #fffbeb;
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

.alert-info {
    background-color: #eff6ff;
    border-left: 4px solid #3b82f6;
    color: #1e40af;
}

.error-message {
    padding: 1rem;
    background-color: #fef2f2;
    border-left: 4px solid var(--error-color);
    border-radius: 0.375rem;
    color: #991b1b;
    font-size: 0.875rem;
}

/* Documentation page */
.doc-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
    gap: 1.5rem;
    align-items: start;
}

/* Ubiquitous Language — language toggle */
.lang-toggle {
    display: flex;
    gap: 0.2rem;
    margin-left: auto;
    align-items: center;
}

.lang-toggle-btn {
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: none;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
}

.lang-toggle-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Default: Swedish shown, English hidden */
#ubiq-lang-card .lang-en { display: none; }

/* English active */
#ubiq-lang-card.lang-active-en .lang-en { display: block; }
#ubiq-lang-card.lang-active-en .lang-se { display: none; }

/* Nested term groups inside a doc-section (e.g. auth methods under Authentication) */
.doc-section-nested-group {
    margin: 0.25rem 0 0.5rem 1rem;
    border-left: 2px solid var(--border-color);
    padding-left: 0.5rem;
}

.doc-section-nested-group .doc-section:first-child {
    border-top: none;
}

.doc-section-nested-group .doc-section > summary {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.doc-section-nested-group .doc-section[open] > summary {
    color: var(--text-primary);
}

/* Plugin developer guide card */
.doc-card {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.doc-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.doc-card-header h3 {
    margin: 0 0 0.1rem;
}

.doc-card-header .subtitle {
    margin: 0;
}

.doc-section {
    border-top: 1px solid var(--border-color);
}

.doc-section summary {
    padding: 0.65rem 0.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    color: var(--text-primary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.doc-section summary::before {
    content: '▶';
    font-size: 0.6rem;
    color: var(--text-secondary);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.doc-section[open] > summary::before {
    transform: rotate(90deg);
}

.doc-section summary::-webkit-details-marker { display: none; }

.doc-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 0.75rem;
    line-height: 1.55;
    padding: 0 0.25rem;
}

.doc-text code {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    padding: 0.05rem 0.3rem;
    font-size: 0.8rem;
    font-family: 'Courier New', Courier, monospace;
    color: var(--text-primary);
}

.doc-code {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    font-size: 0.78rem;
    font-family: 'Courier New', Courier, monospace;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
}

/* Home quick-link cards */
.home-link-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.home-link-loading {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
}

.home-link-icon {
    font-size: 2rem;
    line-height: 1;
}

.home-link-unconfigured {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.btn-inline {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary-color);
    font-size: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.btn-inline:hover {
    color: var(--primary-hover);
}

/* Issue Events */
.events-loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.events-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 1rem 0;
}

.events-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.events-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.events-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.events-table tbody tr:last-child td {
    border-bottom: none;
}

.events-table tbody tr:hover {
    background-color: var(--background);
}

.event-time {
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.event-piece {
    font-weight: 500;
    white-space: nowrap;
}

.event-severity {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
    text-transform: capitalize;
}

.severity-error   { background-color: #fef2f2; color: #991b1b; }
.severity-warning { background-color: #fffbeb; color: #92400e; }
.severity-info    { background-color: #eff6ff; color: #1e40af; }

.event-message {
    color: var(--text-primary);
    word-break: break-word;
}

/* Control Panel — tab navigation */
.cp-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.cp-tab {
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    border-radius: 0.375rem 0.375rem 0 0;
    transition: color 0.15s, border-color 0.15s;
}

.cp-tab:hover {
    color: var(--text-primary);
    background-color: var(--background);
}

.cp-tab-active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.cp-tab-panel {
    display: none;
}

.cp-panel-active {
    display: block;
}

/* Control Panel — users table */
.users-loading {
    display: flex;
    justify-content: center;
    padding: 2.5rem;
}

.users-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.users-toolbar .field-hint {
    flex: 1;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.users-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.users-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.users-table tbody tr:last-child td {
    border-bottom: none;
}

.users-table tbody tr:hover {
    background-color: var(--background);
}

.group-col {
    width: 9rem;
    text-align: center;
}

.user-cell {
    min-width: 12rem;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.user-status-cell {
    width: 6rem;
    text-align: right;
    white-space: nowrap;
}

.group-checkbox {
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.group-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.users-error {
    font-size: 0.75rem;
    color: var(--error-color);
    font-weight: 500;
}

/* Notifications */
.notification {
    position: fixed;
    top: 80px;
    right: 1rem;
    padding: 1rem 1.5rem;
    background-color: var(--surface);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1000;
    max-width: 400px;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    border-left: 4px solid var(--success-color);
}

.notification-error {
    border-left: 4px solid var(--error-color);
}

.notification-info {
    border-left: 4px solid var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-wrap: wrap;
        height: auto;
        padding: 1rem;
    }

    .nav-menu {
        width: 100%;
        flex-direction: column;
        margin: 1rem 0;
    }

    .nav-user {
        width: 100%;
        justify-content: space-between;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .plugin-header {
        flex-direction: column;
        gap: 1rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}

/* ==========================================================================
   Products admin (products.js)
   ========================================================================== */

/* Loading placeholder inside the products container */
.products-loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

/* Create button above the All Products table */
.products-create-btn {
    margin-bottom: 1rem;
}

/* Read-only product ID field shown in the Create Product dialog */
.products-id-readonly {
    font-family: monospace;
    font-size:   0.8rem;
    color:       var(--text-secondary);
    background:  var(--background);
    cursor:      default;
}

/* Products table — reuses .status-table; these add product-specific tweaks */

/* The ID column must show the full product ID — cancel the ellipsis clipping
   that .status-table td applies globally. */
.products-table td:first-child {
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
}

.products-table code.products-id {
    font-size: 0.8rem;
    background: var(--background);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.products-table .products-comment {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.products-table .products-actions {
    white-space: nowrap;
}

.products-table .products-actions .btn + .btn {
    margin-left: 0.4rem;
}

.products-table .products-timestamp {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Required field marker */
.products-required {
    color: var(--error-color);
}

/* Inline error message inside forms */
.products-form-error {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Error message when a view fails to load */
.products-error {
    color: var(--error-color);
    margin-top: 1rem;
}

/* Modal backdrop — full-viewport overlay */
.products-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
}

/* Modal card */
.products-modal-card {
    background: var(--surface);
    border-radius: 0.75rem;
    padding: 2rem;
    min-width: 360px;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.products-modal-card h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

.products-modal-card .hint {
    margin-bottom: 1rem;
}

/* Form labels inside the modal are block-level with spacing */
.products-modal-card .form-label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

/* Action buttons row at the bottom of modal forms */
.products-modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* Price badge in the All Products table */
.products-price-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}
.products-price-badge.has-price {
    background: #d1fae5;
    color: #065f46;
}
.products-price-badge.no-price {
    background: #f1f5f9;
    color: var(--text-secondary);
}

/* Price Tracking filter radio buttons */
.products-tracking-filter {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.products-tracking-radio {
    padding: 0.3rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.products-tracking-radio.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}
.products-tracking-radio:hover:not(.active) {
    background: var(--background);
    color: var(--text-primary);
    border-color: var(--secondary-color);
}

/* Price model type selector row inside the price modal */
.products-price-type-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}
.products-price-type-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Fixed price: row 1 = Currency + Amount, row 2 = VAT (optional) */
.products-fixed-price-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.products-price-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.products-price-field-currency { flex: 0 0 130px; }
.products-price-field-amount   { flex: 1; }

/* Legacy aliases kept for any other uses */
.products-price-field-sm { flex: 0 0 90px; }
.products-price-field-md { flex: 1 1 120px; }

/* Tier table inside the price modal */
.products-tier-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.products-tier-table th,
.products-tier-table td {
    padding: 0.3rem 0.4rem;
    text-align: left;
}
.products-tier-table th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.products-add-tier-btn {
    margin-top: 0.25rem;
}

/* Smaller form inputs inside tier rows */
.form-input-sm {
    padding: 0.25rem 0.4rem;
    font-size: 0.82rem;
    width: 100%;
}

/* Read-only computed gross amount field */
.products-gross-readonly {
    background: var(--background);
    color: var(--text-primary);
    font-weight: 600;
    cursor: default;
}

/* Wider modal for the price form (tiers need more room) */
.products-modal-card.products-modal-wide {
    max-width: 680px;
}

@media (max-width: 600px) {
    .products-modal-card {
        padding: 1.5rem;
        min-width: unset;
    }

    .products-modal-actions {
        flex-direction: column;
    }

    .products-modal-actions .btn {
        width: 100%;
    }

    .products-price-type-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .products-price-row {
        flex-direction: column;
    }
}
