/* REG admin pages — dense operations UI over Midone */

:root {
    --reg-primary: #1e293b;
    --reg-on-primary: #ffffff;
    --reg-accent: #16a34a;
    --reg-on-accent: #052e16;
    --reg-danger: #dc2626;
    --reg-warning: #d97706;
    --reg-info: #2563eb;
    --reg-bg: #f1f5f9;
    --reg-surface: #ffffff;
    --reg-muted: #64748b;
    --reg-fg: #0f172a;
    --reg-border: #e2e8f0;
    --reg-ticket: #1d4ed8;
    --reg-reply: #7c3aed;
    --reg-docs: #0f766e;
    --reg-radius: 12px;
    --reg-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
}

.dark {
    --reg-bg: #0f172a;
    --reg-surface: #1b2336;
    --reg-fg: #f8fafc;
    --reg-muted: #94a3b8;
    --reg-border: #334155;
    --reg-primary: #e2e8f0;
    --reg-on-primary: #0f172a;
    --reg-shadow: 0 1px 2px rgba(0, 0, 0, 0.24), 0 8px 24px rgba(0, 0, 0, 0.28);
}

.reg-page {
    color: var(--reg-fg);
    padding-bottom: 24px;
    scroll-padding-bottom: 96px;
}

.reg-page a.reg-link {
    color: var(--reg-info);
    text-decoration: none;
    cursor: pointer;
}

.reg-page a.reg-link:hover {
    text-decoration: underline;
}

.reg-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.reg-head h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
}

.reg-head__meta {
    color: var(--reg-muted);
    font-size: 0.875rem;
    margin-top: 4px;
}

.reg-head__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.reg-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

@media (min-width: 768px) {
    .reg-stats {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.reg-stat {
    background: var(--reg-surface);
    border: 1px solid var(--reg-border);
    border-radius: var(--reg-radius);
    box-shadow: var(--reg-shadow);
    padding: 14px 16px;
    min-width: 0;
}

.reg-stat__label {
    color: var(--reg-muted);
    font-size: 0.8125rem;
    margin: 0 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reg-stat__value {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.reg-card {
    background: var(--reg-surface);
    border: 1px solid var(--reg-border);
    border-radius: var(--reg-radius);
    box-shadow: var(--reg-shadow);
}

.reg-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--reg-border);
}

.reg-card__head h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.reg-card__body {
    padding: 16px;
}

.reg-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    max-width: 100%;
}

.reg-badge svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.reg-badge--ok {
    background: #dcfce7;
    color: #166534;
}

.reg-badge--danger {
    background: #fee2e2;
    color: #991b1b;
}

.reg-badge--muted {
    background: #e2e8f0;
    color: #334155;
}

.reg-badge--ticket {
    background: #dbeafe;
    color: #1e40af;
}

.reg-badge--reply {
    background: #ede9fe;
    color: #5b21b6;
}

.reg-badge--docs {
    background: #ccfbf1;
    color: #115e59;
}

.reg-badge--wait {
    background: #ffedd5;
    color: #9a3412;
}

.dark .reg-badge--ok { background: #14532d; color: #bbf7d0; }
.dark .reg-badge--danger { background: #7f1d1d; color: #fecaca; }
.dark .reg-badge--muted { background: #334155; color: #e2e8f0; }
.dark .reg-badge--ticket { background: #1e3a8a; color: #bfdbfe; }
.dark .reg-badge--reply { background: #4c1d95; color: #ddd6fe; }
.dark .reg-badge--docs { background: #134e4a; color: #99f6e4; }
.dark .reg-badge--wait { background: #7c2d12; color: #fed7aa; }

.reg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.reg-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.reg-btn--primary {
    background: var(--reg-info);
    color: #fff;
}

.reg-btn--primary:hover {
    background: #1d4ed8;
    color: #fff;
}

.reg-btn--ok {
    background: var(--reg-accent);
    color: #fff;
}

.reg-btn--ok:hover {
    background: #15803d;
    color: #fff;
}

.reg-btn--danger {
    background: var(--reg-danger);
    color: #fff;
}

.reg-btn--danger:hover {
    background: #b91c1c;
    color: #fff;
}

.reg-btn--ghost {
    background: transparent;
    border-color: var(--reg-border);
    color: var(--reg-fg);
}

.reg-btn--ghost:hover {
    background: var(--reg-bg);
    color: var(--reg-fg);
}

.reg-btn--icon {
    min-width: 44px;
    padding: 8px;
}

.reg-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--reg-muted);
}

.reg-empty svg {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    display: block;
}

.reg-empty p {
    margin: 0 0 16px;
}

.reg-notif {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--reg-border);
    border-radius: 10px;
    margin-bottom: 8px;
    background: var(--reg-surface);
    transition: border-color 160ms ease, background-color 160ms ease;
}

.reg-notif:hover {
    border-color: #94a3b8;
}

.reg-notif__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}

.reg-notif__icon svg {
    width: 18px;
    height: 18px;
}

.reg-notif--ticket .reg-notif__icon { background: var(--reg-ticket); }
.reg-notif--reply .reg-notif__icon { background: var(--reg-reply); }
.reg-notif--docs .reg-notif__icon { background: var(--reg-docs); }
.reg-notif--user .reg-notif__icon { background: var(--reg-muted); }

.reg-notif__body {
    min-width: 0;
    flex: 1;
}

.reg-notif__link {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.reg-notif__link:hover .reg-notif__text {
    text-decoration: underline;
}

.reg-notif__text {
    margin: 6px 0 4px;
    font-weight: 500;
    line-height: 1.6;
}

.reg-notif__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    color: var(--reg-muted);
    font-size: 0.8125rem;
}

.reg-table-wrap {
    overflow-x: auto;
}

.reg-table {
    width: 100%;
    border-collapse: collapse;
}

.reg-table th,
.reg-table td {
    padding: 12px 10px;
    text-align: right;
    border-bottom: 1px solid var(--reg-border);
    vertical-align: middle;
}

.reg-table th {
    font-size: 0.75rem;
    color: var(--reg-muted);
    font-weight: 600;
    white-space: nowrap;
}

.reg-table tbody tr:hover {
    background: var(--reg-bg);
}

.reg-identity {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 16px;
    align-items: center;
}

.reg-identity__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.reg-avatar {
    width: 88px;
    height: 88px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--reg-bg);
    border: 1px solid var(--reg-border);
}

.reg-avatar--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--reg-muted);
    font-size: 0.75rem;
    text-align: center;
    padding: 8px;
}

.reg-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px 16px;
    margin: 0;
}

@media (min-width: 640px) {
    .reg-fields {
        grid-template-columns: 1fr 1fr;
    }
}

.reg-field {
    min-width: 0;
    padding: 8px 0;
    border-bottom: 1px dashed var(--reg-border);
}

.reg-field dt {
    color: var(--reg-muted);
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.reg-field dd {
    margin: 0;
    font-weight: 500;
    word-break: break-word;
}

.reg-docs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 768px) {
    .reg-docs {
        grid-template-columns: 1fr 1fr;
    }
}

.reg-doc {
    border: 1px solid var(--reg-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--reg-bg);
}

.reg-doc__title {
    font-size: 0.8125rem;
    font-weight: 600;
    margin: 0;
    padding: 10px 12px;
    background: var(--reg-surface);
    border-bottom: 1px solid var(--reg-border);
    line-height: 1.5;
}

.reg-doc__link {
    display: block;
    position: relative;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
}

.reg-doc__link img {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: contain;
    background: #0f172a;
}

.reg-doc__open {
    display: block;
    padding: 8px 12px;
    font-size: 0.8125rem;
    color: var(--reg-info);
    background: var(--reg-surface);
}

.reg-doc__empty {
    margin: 0;
    padding: 32px 12px;
    text-align: center;
    color: var(--reg-muted);
    font-size: 0.875rem;
}

.reg-actions {
    position: sticky;
    bottom: 0;
    z-index: 30;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    margin-top: 16px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid var(--reg-border);
    border-radius: var(--reg-radius);
}

.dark .reg-actions {
    background: rgba(27, 35, 54, 0.92);
}

.reg-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: min(62vh, 640px);
    overflow-y: auto;
    padding: 8px 4px 16px;
}

.reg-bubble {
    max-width: min(78%, 640px);
    border-radius: 14px;
    padding: 12px 14px;
    border: 1px solid var(--reg-border);
}

.reg-bubble--admin {
    background: #eff6ff;
    margin-inline-end: auto;
}

.reg-bubble--user {
    background: #f0fdf4;
    margin-inline-start: auto;
}

.dark .reg-bubble--admin { background: #1e3a5f; }
.dark .reg-bubble--user { background: #14532d; }

.reg-bubble__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.75rem;
    color: var(--reg-muted);
}

.reg-bubble__text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
}

.reg-composer {
    border-top: 1px solid var(--reg-border);
    padding-top: 16px;
    margin-top: 8px;
}

.reg-label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 6px;
}

.reg-hint {
    color: var(--reg-muted);
    font-size: 0.75rem;
    margin: 6px 0 12px;
}

.reg-input,
.reg-textarea,
.reg-select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--reg-border);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--reg-surface);
    color: var(--reg-fg);
    -webkit-appearance: none;
    appearance: none;
}

.reg-select {
    min-height: 44px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgb(74, 85, 104)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-size: 15px;
    background-position: left 0.6rem center;
    background-repeat: no-repeat;
    padding-left: 2rem;
}

.reg-textarea {
    min-height: 160px;
    resize: vertical;
    overflow-x: hidden;
    overflow-y: auto;
    direction: rtl;
    line-height: 1.8;
}

.reg-textarea--short {
    min-height: 96px;
}

.reg-textarea::-webkit-resizer {
    background: transparent;
    border: 0;
}

.reg-template-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

@media (min-width: 768px) {
    .reg-template-list {
        grid-template-columns: 1fr 1fr;
    }
}

.reg-template {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--reg-border);
    border-radius: 10px;
    background: var(--reg-surface);
    cursor: pointer;
    min-height: 44px;
}

.reg-template:hover {
    border-color: #94a3b8;
}

.reg-template:has(input:checked) {
    border-color: var(--reg-info);
    background: #eff6ff;
}

.dark .reg-template:has(input:checked) {
    background: #1e3a5f;
}

.reg-template input {
    margin-top: 3px;
    flex-shrink: 0;
    cursor: pointer;
}

.reg-template strong {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.5;
}

.reg-form-group {
    margin-bottom: 16px;
}

.reg-recipient {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 1px solid #fdba74;
    background: #fff7ed;
    border-radius: 12px;
}

.dark .reg-recipient {
    background: #7c2d12;
    border-color: #c2410c;
}

.reg-user-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.reg-user-toolbar .reg-input {
    flex: 1 1 220px;
}

.reg-user-list {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--reg-border);
    border-radius: 10px;
    background: var(--reg-surface);
}

.reg-user-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    margin: 0;
    border-bottom: 1px solid var(--reg-border);
    cursor: pointer;
}

.reg-user-row:last-child {
    border-bottom: 0;
}

.reg-user-row:hover {
    background: var(--reg-bg);
}

.reg-user-row--target {
    background: #fff7ed;
}

.dark .reg-user-row--target {
    background: #7c2d12;
}

.reg-user-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 3px;
    flex-shrink: 0;
    cursor: pointer;
}

.reg-user-row__name {
    font-weight: 600;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.reg-user-row__meta {
    color: var(--reg-muted);
    font-size: 0.8125rem;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 4px;
}

.reg-errors {
    border: 1px solid var(--reg-danger);
    background: #fef2f2;
    color: #991b1b;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.dark .reg-errors {
    background: #7f1d1d;
    color: #fecaca;
}

.reg-errors h2 {
    font-size: 0.95rem;
    margin: 0 0 8px;
}

.reg-errors .reg-hint {
    color: inherit;
    margin-bottom: 0;
}

.reg-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.reg-alert--ok {
    background: #dcfce7;
    color: #166534;
}

.reg-alert--danger {
    background: #fee2e2;
    color: #991b1b;
}

.reg-page :focus-visible {
    outline: 2px solid var(--reg-info);
    outline-offset: 2px;
}

.reg-page .top-menu,
.reg-page .reg-btn,
.reg-page .reg-notif__link,
.reg-page .reg-doc__link,
.reg-page button {
    cursor: pointer;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    .reg-btn,
    .reg-notif,
    .reg-doc__link img {
        transition: none !important;
    }
}

.reg-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.reg-steps a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--reg-border);
    background: var(--reg-surface);
    color: var(--reg-fg);
    text-decoration: none;
    font-size: 0.8125rem;
    cursor: pointer;
}

.reg-steps a.is-current {
    border-color: var(--reg-info);
    background: #eff6ff;
    font-weight: 600;
}

.dark .reg-steps a.is-current {
    background: #1e3a5f;
}

.reg-steps__num {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--reg-bg);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.reg-upload-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 768px) {
    .reg-upload-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.reg-upload {
    border: 1px solid var(--reg-border);
    border-radius: 12px;
    padding: 14px;
    background: var(--reg-surface);
}

.reg-upload--done {
    border-color: #86efac;
}

.reg-upload__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.reg-upload__head h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.5;
}

.reg-upload__preview {
    display: block;
    margin-top: 12px;
    cursor: pointer;
}

.reg-upload__preview img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: #0f172a;
    border-radius: 8px;
}

.reg-upload__pdf,
.reg-doc__pdf {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 120px;
    margin-top: 12px;
    padding: 16px;
    border-radius: 8px;
    background: var(--reg-bg);
    color: var(--reg-info);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.reg-doc__pdf {
    margin-top: 0;
    min-height: 160px;
}

.reg-upload__pdf svg,
.reg-doc__pdf svg {
    width: 20px;
    height: 20px;
}

.reg-avatar--file {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--reg-info);
    text-decoration: none;
}

.reg-local {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 8px;
    padding: 12px;
    border: 1px solid var(--reg-border);
    border-radius: 10px;
    cursor: pointer;
}

.reg-local:has(input:checked) {
    border-color: var(--reg-info);
    background: #eff6ff;
}

.dark .reg-local:has(input:checked) {
    background: #1e3a5f;
}

.reg-local input {
    margin-top: 4px;
    flex-shrink: 0;
    cursor: pointer;
}

.reg-field-error {
    color: var(--reg-danger);
    font-size: 0.8125rem;
    margin: 4px 0 12px;
}

.reg-file {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--reg-border);
    border-radius: 10px;
    background: var(--reg-surface);
    color: var(--reg-fg);
    cursor: pointer;
}

.reg-upload .reg-btn {
    width: 100%;
    cursor: pointer;
}

.reg-track {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    background: var(--reg-bg);
    border: 1px dashed var(--reg-accent);
    border-radius: var(--reg-radius);
}

.reg-track__code {
    flex: 1 1 12rem;
    margin: 0;
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    font-weight: 700;
    letter-spacing: 0.06em;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    text-align: center;
    user-select: all;
    word-break: break-all;
}

.reg-track .reg-btn {
    flex: 0 0 auto;
}

.reg-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.reg-fieldset legend {
    padding: 0;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.875rem;
}

.reg-checklist {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (min-width: 768px) {
    .reg-checklist {
        grid-template-columns: 1fr 1fr;
    }
}

.reg-checklist a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--reg-border);
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.reg-checklist a:hover {
    background: var(--reg-bg);
}

.reg-choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.reg-select:disabled,
.reg-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.reg-input[readonly] {
    background: var(--reg-bg);
    cursor: default;
}

.reg-label--req::after {
    content: " *";
    color: var(--reg-danger);
}

.reg-date {
    display: grid;
    grid-template-columns: 1fr 1fr 1.3fr;
    gap: 8px;
}

.reg-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 8px;
    padding: 12px;
    border: 1px solid var(--reg-border);
    border-radius: 10px;
    cursor: pointer;
    min-height: 44px;
}

.reg-check:has(input:checked) {
    border-color: var(--reg-info);
    background: #eff6ff;
}

.dark .reg-check:has(input:checked) {
    background: #1e3a5f;
}

.reg-check input {
    margin-top: 3px;
    flex-shrink: 0;
    cursor: pointer;
}
