:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #d9dde3;
    --text: #1f2933;
    --muted: #6b7280;
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --danger: #b91c1c;
    --warning: #b45309;
    --success: #047857;
    --radius: 8px;
    font-family: "Segoe UI", Tahoma, Vazirmatn, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

h1 {
    font-size: 1.6rem;
    margin: 0 0 1rem;
}

h2 {
    font-size: 1.1rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--muted);
    font-weight: 600;
}

a {
    color: var(--primary);
    text-decoration: none;
}

code {
    background: #eef0f3;
    padding: 0 0.3em;
    border-radius: 4px;
    font-size: 0.9em;
}

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

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar nav a {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text);
}

.sidebar nav a:hover {
    background: var(--bg);
}

.sidebar nav a.active {
    background: var(--primary);
    color: #fff;
}

.sign-out {
    margin-top: auto;
}

.content {
    flex: 1;
    padding: 2rem;
    max-width: 1100px;
}

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

.page-header h1 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.25rem;
}

.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.toolbar input[type="search"] {
    flex: 1;
    min-width: 220px;
}

button, .button {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

button:disabled {
    opacity: 0.6;
    cursor: default;
}

.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.secondary:hover:not(:disabled) {
    background: var(--bg);
}

.danger {
    color: var(--danger);
    border-color: var(--danger);
}

.warning {
    color: var(--warning);
    border-color: var(--warning);
}

button.link {
    border: 0;
    background: none;
    color: var(--muted);
    padding: 0.25rem 0;
}

button.link:hover {
    color: var(--text);
}

input, select, textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font: inherit;
    color: var(--text);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    border-color: var(--primary);
}

input:disabled, select:disabled, textarea:disabled {
    background: var(--bg);
    color: var(--muted);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

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

.field label, .field legend {
    font-weight: 600;
    font-size: 0.9rem;
}

fieldset.field {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 1rem 0 0;
}

.check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400 !important;
}

.check input {
    width: auto;
}

.validation-message {
    color: var(--danger);
    font-size: 0.85rem;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

th, td {
    padding: 0.65rem 0.85rem;
    text-align: start;
    border-bottom: 1px solid var(--border);
}

th {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
    background: #fafbfc;
}

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

tr.clickable {
    cursor: pointer;
}

tr.clickable:hover td {
    background: #f7f9fc;
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #e5e7eb;
    color: var(--text);
}

.badge.active {
    background: #d1fae5;
    color: var(--success);
}

.badge.pending {
    background: #fef3c7;
    color: var(--warning);
}

.badge.suspended {
    background: #fee2e2;
    color: var(--danger);
}

.badge.deactivated {
    background: #e5e7eb;
    color: var(--muted);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    color: var(--muted);
    font-size: 0.85rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.4rem 1.5rem;
    margin: 0;
}

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

dd {
    margin: 0;
}

ul {
    margin: 0;
    padding-inline-start: 1.25rem;
}

.alert {
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius);
    border: 1px solid;
    margin-bottom: 1rem;
}

.alert.error {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--danger);
}

.alert.success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: var(--success);
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.sign-in-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.sign-in, .notice {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.sign-in form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    text-align: start;
}

.sign-in label {
    font-weight: 600;
    font-size: 0.9rem;
}

#blazor-error-ui {
    color: var(--text);
    background: #fef3c7;
    bottom: 0;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
    display: none;
    inset-inline-start: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    inset-inline-end: 0.75rem;
    top: 0.5rem;
}

#components-reconnect-modal {
    border: 0;
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    max-width: 360px;
}

#components-reconnect-modal::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.components-reconnect-container > * {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible {
    display: block;
}
