:root {
    --app-accent: #3859c8;
    --app-accent-soft: #eef1ff;
    --app-background: #f5f7fb;
    --app-border: #e4e9f2;
}

[data-bs-theme="dark"] {
    --app-accent: #a4b4ff;
    --app-accent-soft: #252f50;
    --app-background: #111827;
    --app-border: #354156;
}

body { background: var(--app-background); }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
h1:focus { outline: none; }
.app-header { background: var(--bs-body-bg); border-bottom: 1px solid var(--app-border); }
.app-main { min-height: calc(100vh - 11rem); padding-top: 2rem; padding-bottom: 3rem; }
.app-footer { border-top: 1px solid var(--app-border); color: var(--bs-secondary-color); font-size: .8rem; padding-top: 1.3rem; padding-bottom: 1.5rem; }
.brand { display: flex; align-items: center; gap: .75rem; color: var(--bs-body-color); font-size: 1.1rem; line-height: 1.05; }
.brand:hover { color: var(--bs-body-color); text-decoration: none; }
.brand small { display: block; color: var(--bs-secondary-color); font-size: .56rem; font-weight: 700; letter-spacing: .12em; margin-top: .35rem; }
.brand-mark { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: .75rem; color: #fff; background: #3859c8; font-weight: 800; font-size: 1.25rem; }
.nav-link { font-weight: 600; color: var(--bs-secondary-color); }
.nav-link.active { color: var(--app-accent) !important; }
.avatar { width: 2.3rem; height: 2.3rem; display: grid; place-items: center; border-radius: 50%; color: var(--app-accent); background: var(--app-accent-soft); font-weight: 700; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.75rem; }
.eyebrow { color: var(--app-accent); font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin-bottom: .5rem; }
.page-heading h1 { font-weight: 750; letter-spacing: -.035em; margin-bottom: .35rem; }
.surface { background: var(--bs-body-bg); border: 1px solid var(--app-border); border-radius: 1rem; box-shadow: 0 2px 12px rgba(28, 42, 69, .035); }
.surface-header { padding: 1.2rem 1.4rem; border-bottom: 1px solid var(--app-border); }
.surface-body { padding: 1.4rem; }
.metric-card { height: 100%; padding: 1.2rem 1.3rem; }
.metric-card .metric-label { color: var(--bs-secondary-color); font-size: .82rem; font-weight: 600; }
.metric-card .metric-value { font-size: 1.9rem; font-weight: 750; letter-spacing: -.04em; line-height: 1.2; margin-top: .55rem; }
.metric-card .metric-caption { font-size: .76rem; color: var(--bs-secondary-color); }
.ticket-table { font-size: .875rem; }
.ticket-table th { color: var(--bs-secondary-color); background: var(--bs-tertiary-bg); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; padding: .8rem 1rem; }
.ticket-table td { padding: 1rem; border-color: var(--app-border); }
.ticket-link { color: var(--app-accent); font-weight: 700; }
.ticket-title { font-weight: 600; margin-top: .25rem; min-width: 13rem; }
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-icon { width: 3.2rem; height: 3.2rem; border-radius: 1rem; display: grid; place-items: center; margin: 0 auto 1rem; background: var(--app-accent-soft); color: var(--app-accent); font-size: 1.4rem; font-weight: 700; }
.field-label { font-size: .82rem; font-weight: 650; margin-bottom: .4rem; }
.form-control, .form-select { border-color: var(--app-border); }
.form-control:focus, .form-select:focus { border-color: #8398e5; box-shadow: 0 0 0 .2rem rgba(56, 89, 200, .15); }
.valid.modified:not([type=checkbox]) { border-color: var(--bs-success); }
.invalid { border-color: var(--bs-danger); }
.validation-message { color: var(--bs-danger-text-emphasis); font-size: .85rem; }
.conversation-message { border: 1px solid var(--app-border); border-radius: .85rem; padding: 1rem; margin-bottom: .8rem; }
.conversation-message.internal { border-left: 4px solid #d59d2c; background: var(--bs-warning-bg-subtle); }
.message-body { overflow-wrap: anywhere; }
.message-body ul { margin-bottom: .4rem; }
.message-image { display: block; max-width: min(100%, 36rem); max-height: 28rem; object-fit: contain; margin: .5rem 0; border-radius: .5rem; }
#descrizione-toolbar.ql-toolbar, #descrizione.ql-container, .rich-toolbar.ql-toolbar, .rich-editor.ql-container { border-color: var(--app-border); }
#descrizione.ql-container, .rich-editor.ql-container { height: auto; font-family: inherit; font-size: 1rem; border-radius: 0 0 .375rem .375rem; }
#descrizione .ql-editor, .rich-editor .ql-editor { min-height: 10rem; }
#descrizione .ql-editor img, .rich-editor .ql-editor img { display: block; max-width: min(100%, 36rem); max-height: 28rem; object-fit: contain; }
[data-bs-theme="dark"] #descrizione-toolbar .ql-stroke, [data-bs-theme="dark"] .rich-toolbar .ql-stroke { stroke: var(--bs-body-color); }
.detail-list dt { font-size: .75rem; color: var(--bs-secondary-color); font-weight: 600; }
.detail-list dd { font-weight: 600; margin-bottom: 1rem; }
.admin-section + .admin-section { margin-top: 1.5rem; }
.hero { background: linear-gradient(130deg, var(--app-accent-soft), var(--bs-body-bg) 75%); padding: clamp(2rem, 5vw, 4rem); }
.hero h1 { max-width: 14ch; font-size: clamp(2.2rem, 5vw, 3.6rem); font-weight: 750; letter-spacing: -.05em; }
.hero p { max-width: 34rem; }
#blazor-error-ui { display: none; position: fixed; bottom: 0; width: 100%; z-index: 1100; padding: .8rem 3rem .8rem 1rem; background: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); }
#blazor-error-ui .dismiss { position: absolute; right: 1rem; top: .5rem; border: 0; background: transparent; color: inherit; font-size: 1.4rem; }
@media (max-width: 767.98px) { .page-heading { flex-direction: column; } .app-main { padding-top: 1.25rem; } .surface-body { padding: 1rem; } }
