:root {
    color-scheme: dark;
    --bg: #0d1117;
    --panel: #151b23;
    --panel-2: #1b2330;
    --line: #303b4d;
    --text: #e6edf3;
    --muted: #8b98a9;
    --accent: #2f9e8f;
    --accent-2: #4c8eda;
    --danger: #d24b5a;
    --warning: #d4a93f;
    --shadow: rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px clamp(16px, 4vw, 40px);
    border-bottom: 1px solid var(--line);
    background: #101620;
    box-shadow: 0 14px 30px var(--shadow);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar-brand img {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border: 1px solid rgba(47, 158, 143, 0.36);
    border-radius: 8px;
    background: #0d1117;
}

.topbar-brand > div {
    min-width: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-actions > div:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-status-line {
    color: var(--muted);
    font-size: 12px;
}

.install-app-button {
    min-width: 92px;
}

.pwa-offline-notice {
    width: min(1360px, calc(100% - 32px));
    margin: 12px auto 0;
    border: 1px solid rgba(212, 169, 63, 0.62);
    border-radius: 8px;
    background: rgba(212, 169, 63, 0.12);
    color: #f1d58a;
    padding: 10px 14px;
    font-size: 13px;
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.auth-panel {
    display: grid;
    gap: 14px;
    width: min(420px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 20px 44px var(--shadow);
    padding: 20px;
}

.auth-panel p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 23px;
    font-weight: 700;
}

h2 {
    font-size: 16px;
    font-weight: 650;
}

.topbar p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.status-pill {
    min-width: 86px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
}

.status-pill.online {
    border-color: rgba(47, 158, 143, 0.55);
    color: #98e4da;
    background: rgba(47, 158, 143, 0.12);
}

.status-pill.live {
    border-color: rgba(47, 158, 143, 0.55);
    color: #98e4da;
    background: rgba(47, 158, 143, 0.12);
}

.status-pill.connecting,
.status-pill.reconnecting,
.status-pill.stale {
    border-color: rgba(212, 169, 63, 0.62);
    color: #f1d58a;
    background: rgba(212, 169, 63, 0.12);
}

.status-pill.error,
.status-pill.offline {
    border-color: rgba(210, 75, 90, 0.65);
    color: #ffccd2;
    background: rgba(210, 75, 90, 0.12);
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 40px;
}

.app-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    width: min(1360px, calc(100% - 32px));
}

.dashboard-nav {
    position: sticky;
    top: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #101620;
    padding: 8px;
}

.dashboard-nav nav {
    display: grid;
    gap: 2px;
}

.dashboard-nav a {
    display: flex;
    align-items: center;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    padding: 0 10px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 650;
}

.dashboard-nav a:hover,
.dashboard-nav a:focus-visible {
    border-color: rgba(76, 142, 218, 0.38);
    background: rgba(76, 142, 218, 0.1);
    color: var(--text);
    outline: none;
}

.dashboard-nav a.active {
    border-color: rgba(47, 158, 143, 0.58);
    background: rgba(47, 158, 143, 0.14);
    color: #a9eee4;
}

.app-content {
    min-width: 0;
}

.route-view {
    display: grid;
    gap: 16px;
}

.placeholder-view {
    display: grid;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 22px;
}

.placeholder-view h2 {
    font-size: 18px;
}

.placeholder-view p {
    color: var(--muted);
    font-size: 13px;
}

.activity-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(130px, 0.38fr) minmax(130px, 0.38fr) minmax(100px, 0.28fr);
    gap: 12px;
    align-items: end;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    background: #111822;
}

.activity-list {
    display: grid;
    gap: 1px;
    background: var(--line);
}

.activity-event {
    display: grid;
    gap: 8px;
    background: var(--panel);
    padding: 13px 16px;
}

.activity-event.warning {
    border-left: 3px solid var(--warning);
}

.activity-event.error {
    border-left: 3px solid var(--danger);
}

.activity-event-main {
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.activity-event-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.activity-event-title strong {
    font-size: 14px;
}

.activity-event p,
.activity-event time,
.activity-meta,
.activity-empty {
    color: var(--muted);
    font-size: 12px;
}

.activity-event p {
    margin-top: 4px;
}

.activity-level {
    border: 1px solid rgba(76, 142, 218, 0.55);
    border-radius: 999px;
    color: #b9d8ff;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 750;
}

.activity-event.warning .activity-level {
    border-color: rgba(212, 169, 63, 0.65);
    color: #f1d58a;
}

.activity-event.error .activity-level {
    border-color: rgba(210, 75, 90, 0.65);
    color: #ffccd2;
}

.activity-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.activity-meta span {
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 999px;
    padding: 2px 8px;
}

.activity-event details {
    border-top: 1px solid rgba(48, 59, 77, 0.72);
    padding-top: 8px;
}

.activity-event summary {
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.activity-event pre {
    overflow: auto;
    max-height: 220px;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 6px;
    background: #0d131d;
    color: #dce8f6;
    padding: 10px;
    font-size: 12px;
}

.activity-empty {
    background: var(--panel);
    padding: 24px 16px;
    text-align: center;
}

.media-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(140px, 0.3fr);
    gap: 12px;
    align-items: end;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    background: #111822;
}

.media-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
}

.media-stat {
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
    padding: 10px 12px;
}

.media-stat.enabled {
    border-color: rgba(47, 158, 143, 0.55);
}

.media-stat.disabled {
    border-color: rgba(210, 75, 90, 0.52);
}

.media-stat span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.media-stat strong {
    display: block;
    overflow: hidden;
    margin-top: 5px;
    color: var(--text);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    padding: 14px 16px 16px;
}

.media-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px 16px;
}

.media-pagination:empty {
    display: none;
}

.media-pagination-top {
    padding-top: 12px;
    padding-bottom: 0;
}

.media-pagination-summary {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.media-pagination-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.media-page-button {
    min-width: 40px;
    padding: 0 10px;
}

.media-page-button.active {
    border-color: rgba(47, 158, 143, 0.7);
    background: rgba(47, 158, 143, 0.18);
    color: #98e4da;
}

.media-page-ellipsis {
    color: var(--muted);
    padding: 0 2px;
    font-size: 12px;
}

.media-card {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 12px;
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
    padding: 12px;
}

.media-poster {
    display: grid;
    overflow: hidden;
    place-items: center;
    width: 96px;
    aspect-ratio: 2 / 3;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 7px;
    background: #0d131d;
}

.media-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-poster.empty span {
    color: var(--muted);
    font-size: 26px;
    font-weight: 800;
}

.media-card-body {
    display: grid;
    align-content: start;
    gap: 8px;
    min-width: 0;
}

.media-card-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.media-card-title strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 14px;
}

.media-card p {
    color: var(--muted);
    font-size: 12px;
}

.media-provider-row,
.media-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.media-provider-row span {
    border: 1px solid rgba(76, 142, 218, 0.42);
    border-radius: 999px;
    color: #b9d8ff;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
}

.media-detail {
    overflow: hidden;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 7px;
    color: var(--muted);
    font-size: 12px;
}

.media-detail.error {
    border-color: rgba(210, 75, 90, 0.55);
    color: #ffccd2;
    padding: 10px;
}

.jellyfin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px 16px 16px;
}

.jellyfin-section {
    min-width: 0;
    overflow: hidden;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
}

.jellyfin-section.span-2 {
    grid-column: 1 / -1;
}

.jellyfin-section h3 {
    margin: 0;
    padding: 11px 12px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    color: #cbd7e6;
    font-size: 13px;
}

.jellyfin-section .inline-status {
    padding: 12px;
}

.storage-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(160px, 0.35fr) auto;
    gap: 12px;
    align-items: end;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    background: #111822;
}

.storage-toolbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.storage-check-result:not(:empty) {
    padding: 14px 16px 0;
}

.storage-check-card {
    display: grid;
    gap: 10px;
}

.storage-check-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.storage-check-heading h3 {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.storage-path-list {
    display: grid;
    gap: 12px;
    padding: 14px 16px 16px;
}

.storage-card {
    display: grid;
    gap: 12px;
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
    padding: 12px;
}

.storage-card.warn {
    border-color: rgba(212, 169, 63, 0.58);
}

.storage-card.error {
    border-color: rgba(210, 75, 90, 0.6);
}

.storage-card.compact {
    background: #101722;
}

.storage-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.storage-card-heading h3 {
    margin: 0 0 5px;
    font-size: 14px;
}

.storage-card-heading code {
    display: block;
    overflow-wrap: anywhere;
    color: #dce8f6;
    font-size: 12px;
}

.storage-source-label,
.storage-auto-label {
    display: inline-flex;
    width: fit-content;
    margin-top: 7px;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 999px;
    color: var(--muted);
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
}

.storage-auto-label {
    margin-top: 0;
}

.storage-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.storage-space-bar {
    height: 11px;
    overflow: hidden;
    border-radius: 999px;
    background: #0d131d;
}

.storage-space-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.storage-card.warn .storage-space-bar span {
    background: var(--warning);
}

.storage-card.error .storage-space-bar span {
    background: var(--danger);
}

.storage-kv-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 7px;
    background: rgba(48, 59, 77, 0.72);
}

.storage-kv {
    min-width: 0;
    display: grid;
    gap: 4px;
    background: #121a26;
    padding: 9px 10px;
}

.storage-kv span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.storage-kv strong {
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.storage-warnings {
    display: grid;
    gap: 4px;
    margin: 0;
    border: 1px solid rgba(212, 169, 63, 0.45);
    border-radius: 7px;
    background: rgba(212, 169, 63, 0.09);
    color: #f1d58a;
    padding: 9px 12px 9px 28px;
    font-size: 12px;
}

.automation-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px 16px 16px;
}

.automation-card {
    display: grid;
    gap: 12px;
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
    padding: 12px;
}

.automation-card.span-2 {
    grid-column: 1 / -1;
}

.automation-card.muted-card {
    background: #101722;
}

.automation-card h3 {
    margin: 0;
    font-size: 14px;
}

.automation-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.automation-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.automation-toggle {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 8px;
    background: #0f1520;
    padding: 10px;
}

.automation-toggle input {
    width: 18px;
    min-height: 18px;
    margin-top: 2px;
    accent-color: var(--accent-2);
}

.automation-toggle strong,
.automation-toggle small {
    display: block;
}

.automation-toggle strong {
    font-size: 13px;
}

.automation-toggle small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.automation-execution-list {
    overflow: hidden;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 8px;
}

.notification-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 12px;
    padding: 14px 16px 16px;
}

.notification-card {
    display: grid;
    gap: 12px;
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
    padding: 12px;
}

.notification-card.span-2 {
    grid-column: 1 / -1;
}

.notification-card h3 {
    margin: 0;
    font-size: 14px;
}

.notification-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.notification-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.notification-form-grid .span-2 {
    grid-column: 1 / -1;
}

.notification-form-grid textarea {
    width: 100%;
    min-height: 88px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0f1520;
    color: var(--text);
    padding: 10px 12px;
    outline: none;
}

.notification-enabled-row {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
}

.notification-enabled-row input {
    width: 18px;
    min-height: 18px;
    accent-color: var(--accent-2);
}

.notification-form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.notification-list {
    display: grid;
    gap: 10px;
}

.notification-target {
    display: grid;
    gap: 8px;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 8px;
    background: #0f1520;
    padding: 10px;
}

.notification-target.disabled {
    opacity: 0.72;
}

.notification-target-main {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.notification-target p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.notification-event-list {
    overflow: hidden;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 8px;
}

.tracker-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
    gap: 12px;
    align-items: start;
    padding: 14px 16px 16px;
}

.tracker-card {
    display: grid;
    gap: 12px;
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
    padding: 12px;
}

.tracker-card.span-2 {
    grid-column: 1 / -1;
}

.tracker-active-card {
    grid-template-columns: 1fr;
    align-items: start;
}

.tracker-active-card .tracker-card-heading,
.tracker-active-card > label {
    grid-column: auto;
}

.tracker-active-card .tracker-info {
    grid-column: auto;
}

.tracker-active-card .tracker-health-list {
    grid-column: auto;
    grid-row: auto;
}

.tracker-card h3 {
    margin: 0;
    font-size: 14px;
}

.tracker-card-heading,
.tracker-actions,
.tracker-add-row,
.tracker-test-row,
.detail-section-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tracker-card-heading {
    justify-content: space-between;
}

.tracker-add-row,
.tracker-test-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(88px, 0.25fr) auto;
    align-items: end;
}

.tracker-test-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.tracker-add-row input[type="number"] {
    max-width: none;
}

.tracker-card textarea {
    width: 100%;
    min-height: 130px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0f1520;
    color: var(--text);
    padding: 10px 12px;
    outline: none;
}

.tracker-info,
.tracker-health-list,
.tracker-preset-list {
    min-width: 0;
}

.heading-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.heading-title-row .sort-summary {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.label-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
    gap: 12px;
    align-items: start;
    padding: 14px 16px 16px;
}

.label-card {
    display: grid;
    gap: 12px;
    align-content: start;
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
    padding: 12px;
}

.label-card.span-2 {
    grid-column: 1 / -1;
}

.label-card h3 {
    margin: 0;
    font-size: 14px;
}

.label-card-heading,
.label-form-actions,
.label-item-main,
.label-item-actions,
.label-assign-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.label-card-heading {
    justify-content: space-between;
}

.label-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 92px;
    gap: 12px;
}

.label-form-grid .span-2 {
    grid-column: 1 / -1;
}

.label-form-grid input[type="color"] {
    min-height: 40px;
    padding: 4px;
}

.label-list {
    display: grid;
    gap: 10px;
}

.label-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 8px;
    background: #0f1520;
    padding: 12px;
}

.label-item-main {
    display: grid;
    gap: 6px;
    align-items: start;
    justify-content: start;
    min-width: 0;
}

.label-item-main p {
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.label-item-actions {
    display: flex;
    justify-content: flex-end;
    align-self: center;
}

.label-assigned-torrents {
    grid-column: 1 / -1;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.label-assigned-torrents span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    padding: 3px 6px 3px 9px;
    font-size: 11px;
}

.label-assigned-torrents button {
    min-width: 22px;
    min-height: 22px;
    padding: 0;
}

.label-assign-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.6fr) auto;
    align-items: end;
}

.label-assign-row label {
    min-width: 0;
}

.logs-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1.2fr) minmax(120px, 0.4fr) minmax(180px, 0.8fr) minmax(110px, 0.35fr);
    gap: 12px;
    align-items: end;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    background: #111822;
}

.log-list {
    display: grid;
    gap: 1px;
    overflow: hidden;
    background: var(--line);
}

.log-line {
    display: grid;
    gap: 7px;
    min-width: 0;
    background: #111822;
    padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
}

.log-line.warn {
    background: rgba(212, 169, 63, 0.08);
}

.log-line.error {
    background: rgba(210, 75, 90, 0.1);
}

.log-line-main {
    display: grid;
    grid-template-columns: 74px 64px minmax(160px, 0.55fr) auto;
    gap: 8px;
    align-items: center;
    min-width: 0;
}

.log-line-main button {
    justify-self: end;
    min-height: 30px;
    padding: 0 10px;
}

.log-time,
.log-logger {
    color: var(--muted);
}

.log-logger {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-level {
    width: fit-content;
    border: 1px solid rgba(139, 152, 169, 0.45);
    border-radius: 999px;
    color: #c4cfdd;
    padding: 2px 7px;
    font-weight: 800;
}

.log-level.info {
    border-color: rgba(76, 142, 218, 0.55);
    color: #b9d8ff;
}

.log-level.warn {
    border-color: rgba(212, 169, 63, 0.7);
    color: #f1d58a;
}

.log-level.error {
    border-color: rgba(210, 75, 90, 0.75);
    color: #ffccd2;
}

.log-message,
.log-throwable {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.log-throwable {
    color: #ffccd2;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 16px;
}

.settings-section {
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 7px;
    overflow: hidden;
    background: #0f1520;
}

.settings-section-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    padding: 13px 14px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    background: #141d29;
}

.settings-section-heading h3 {
    margin: 0;
    font-size: 15px;
}

.settings-section-heading p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.settings-section-heading span {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.settings-list {
    display: grid;
    gap: 1px;
    background: rgba(48, 59, 77, 0.72);
}

.settings-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.55fr);
    gap: 14px;
    align-items: start;
    min-width: 0;
    padding: 12px 14px;
    background: #0f1520;
}

.settings-row-main,
.settings-row-value {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.settings-row-main strong {
    font-size: 13px;
}

.settings-row-main small {
    color: var(--muted);
    line-height: 1.4;
}

.settings-row-value {
    justify-items: end;
    text-align: right;
}

.settings-input-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    width: min(260px, 100%);
}

.settings-input-wrap input {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 12px;
}

.settings-input-unit {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.settings-switch {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-height: 34px;
    color: var(--text);
}

.settings-switch input {
    width: 16px;
    min-height: 16px;
    margin: 0;
}

.settings-switch span {
    min-width: 64px;
    color: var(--muted);
    text-align: left;
}

.settings-row-value code {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #dce7f3;
    background: rgba(20, 29, 41, 0.86);
    border: 1px solid rgba(139, 152, 169, 0.24);
    border-radius: 6px;
    padding: 4px 6px;
}

.settings-badges,
.settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.settings-badges {
    justify-content: flex-end;
}

.settings-badge {
    border: 1px solid rgba(139, 152, 169, 0.38);
    border-radius: 999px;
    color: #b8c5d6;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
}

.settings-badge.restart {
    border-color: rgba(212, 169, 63, 0.68);
    color: #f0cf7f;
}

.settings-badge.live {
    border-color: rgba(47, 158, 143, 0.68);
    color: #a9eee4;
}

.settings-badge.read-only {
    border-color: rgba(139, 152, 169, 0.34);
    color: #b8c5d6;
}

.settings-badge.sensitive {
    border-color: rgba(210, 75, 90, 0.62);
    color: #ffb8c1;
}

.settings-actions {
    padding: 16px;
}

.settings-section-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    border-top: 1px solid rgba(48, 59, 77, 0.72);
    background: #111822;
}

.settings-section-status {
    flex: 1 1 220px;
    min-height: 0;
}

#settingsJellyfinStatus,
#localPreferenceStatus,
#pwaSettingsStatus {
    display: block;
    padding: 12px 16px;
    border-top: 1px solid rgba(48, 59, 77, 0.72);
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    background: #111822;
}

#localPreferenceStatus,
#pwaSettingsStatus {
    border-top: 0;
}

.pwa-status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    padding: 16px;
    background: rgba(48, 59, 77, 0.72);
}

.pwa-status-item {
    min-width: 0;
    display: grid;
    gap: 5px;
    padding: 10px 12px;
    background: #0f1520;
}

.pwa-status-item span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}

.pwa-status-item strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tracker-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 7px;
    background: rgba(48, 59, 77, 0.72);
}

.tracker-info-grid div {
    min-width: 0;
    display: grid;
    gap: 4px;
    background: #0f1520;
    padding: 9px 10px;
}

.tracker-info-grid span,
.tracker-preset p {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.tracker-info-grid strong {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tracker-health-list,
.tracker-preset-list {
    display: grid;
    gap: 10px;
}

.tracker-tier,
.tracker-preset {
    display: grid;
    gap: 8px;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 8px;
    background: #0f1520;
    padding: 10px;
}

.tracker-tier code {
    display: block;
    overflow-wrap: anywhere;
    color: #dce8f6;
    font-size: 12px;
}

.tracker-preset {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.tracker-preset strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tracker-preset p {
    margin: 4px 0 0;
}

.recovery-session-list {
    display: grid;
    gap: 12px;
    padding: 14px 16px 16px;
}

.recovery-session {
    display: grid;
    gap: 10px;
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
    padding: 12px;
}

.recovery-session.active {
    border-color: rgba(47, 158, 143, 0.56);
}

.recovery-session-main {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.recovery-session p {
    margin: 6px 0;
    color: var(--muted);
    font-size: 12px;
}

.recovery-session code {
    display: block;
    overflow-wrap: anywhere;
    color: #dce8f6;
    font-size: 12px;
}

.add-wizard-panel {
    overflow: hidden;
}

.wizard-steps {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.wizard-steps span {
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 700;
}

.wizard-steps span.active {
    border-color: rgba(47, 158, 143, 0.65);
    background: rgba(47, 158, 143, 0.13);
    color: #a9eee4;
}

.wizard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
    padding: 14px 16px 16px;
}

.wizard-card {
    display: grid;
    gap: 12px;
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
    padding: 12px;
}

.wizard-card:first-child,
.wizard-card:nth-child(2) {
    align-content: start;
}

.wizard-card.span-2 {
    grid-column: 1 / -1;
}

.wizard-card h3 {
    margin: 0;
    font-size: 14px;
}

.wizard-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.wizard-summary {
    display: grid;
    gap: 1px;
    overflow: hidden;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 6px;
    background: rgba(48, 59, 77, 0.52);
    color: var(--muted);
    font-size: 13px;
}

.wizard-empty {
    display: grid;
    place-items: center;
    min-height: 118px;
    gap: 6px;
    border: 1px dashed rgba(139, 152, 169, 0.32);
    border-radius: 7px;
    background: rgba(13, 19, 29, 0.62);
    color: var(--muted);
    padding: 18px;
    text-align: center;
}

.wizard-empty strong {
    color: var(--text);
    font-size: 13px;
}

.wizard-empty span {
    font-size: 12px;
}

.wizard-summary:not(:has(.wizard-kv)) {
    border: 0;
    background: transparent;
}

.wizard-kv {
    display: grid;
    grid-template-columns: minmax(100px, 0.38fr) minmax(0, 1fr);
    gap: 10px;
    background: #121a26;
    padding: 8px 10px;
}

.wizard-kv span {
    color: var(--muted);
}

.wizard-kv strong {
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--text);
}

.wizard-tracker-list {
    display: grid;
    gap: 6px;
}

.wizard-tracker-list code {
    overflow-wrap: anywhere;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 6px;
    background: #0d131d;
    color: #dce8f6;
    padding: 7px 8px;
    font-size: 12px;
}

.wizard-file-list {
    display: grid;
    min-height: 88px;
    max-height: 340px;
    overflow: auto;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 8px;
}

.custom-file-picker {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0f1520;
    color: var(--text);
    overflow: hidden;
}

.custom-file-picker button {
    align-self: stretch;
    min-height: 40px;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    background: #1d2938;
    color: var(--text);
    padding: 0 14px;
}

.custom-file-picker span {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    padding: 0 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.visually-hidden-file {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.wizard-file-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid rgba(48, 59, 77, 0.62);
    background: #0f1520;
    color: var(--text);
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 500;
}

.wizard-file-row:last-child {
    border-bottom: 0;
}

.wizard-file-row input,
.checkbox-label input {
    width: auto;
    min-height: 0;
}

.wizard-file-row span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.wizard-file-row strong {
    color: var(--muted);
    font-weight: 650;
}

.checkbox-label {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
}

.nav-drawer-button {
    display: none;
}

.panel,
.metric {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.add-panel {
    padding: 16px;
}

.add-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.add-header p,
.panel-toggle span span + span,
.toggle-title + span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.panel-toggle,
.section-toggle {
    display: inline-flex;
    align-items: flex-start;
    gap: 9px;
    min-height: 0;
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    text-align: left;
}

.panel-toggle:hover,
.section-toggle:hover,
.panel-toggle:focus-visible,
.section-toggle:focus-visible {
    background: transparent;
    color: var(--text);
    outline: 2px solid rgba(76, 142, 218, 0.42);
    outline-offset: 3px;
}

.panel-toggle > span:last-child,
.section-toggle > span:last-child {
    display: grid;
    gap: 3px;
}

.panel-toggle > .server-info-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.server-info-title-row .toggle-title + span {
    margin-top: 0;
}

.toggle-title {
    color: var(--text);
    font-size: 16px;
    font-weight: 650;
}

.chevron {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1;
    transition: transform 140ms ease;
}

.collapsed > .add-header .chevron,
.collapsed > .panel-heading .chevron,
.collapsed > .section-toggle .chevron,
.collapsed > .detail-section-toggle .chevron {
    transform: rotate(-90deg);
}

.collapsed > .collapsible-content,
.collapsed > .server-info-grid,
.collapsed > .chart-grid,
.collapsed > #torrentsContent,
.collapsed > #addTorrentContent {
    display: none !important;
}

.add-tabs {
    display: flex;
    gap: 8px;
}

.add-tabs button {
    min-width: 82px;
}

.add-tabs button.selected {
    border-color: rgba(47, 158, 143, 0.7);
    background: rgba(47, 158, 143, 0.18);
    color: #98e4da;
}

.download-dir-field {
    margin-bottom: 12px;
}

.add-pane {
    display: none;
}

.add-pane.active {
    display: grid;
    gap: 12px;
}

.add-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.inline-status {
    min-height: 20px;
    color: var(--muted);
    font-size: 13px;
}

.inline-status.success {
    color: #a9eee4;
}

.inline-status.error {
    color: #ffccd2;
}

.inline-status.warning {
    color: #f1d58a;
}

.inline-status.busy {
    color: #b9d8ff;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0f1520;
    color: var(--text);
    padding: 0 12px;
    outline: none;
}

input {
    min-height: 40px;
}

textarea {
    min-height: 92px;
    padding-top: 10px;
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(76, 142, 218, 0.16);
}

button {
    min-height: 40px;
    border: 1px solid rgba(47, 158, 143, 0.55);
    border-radius: 6px;
    background: #1c6f67;
    color: #f5fffd;
    padding: 0 14px;
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

button:hover {
    background: #247f76;
    border-color: rgba(98, 211, 196, 0.7);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

button.loading {
    position: relative;
    padding-left: 32px;
}

button.loading::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    border: 2px solid rgba(245, 255, 253, 0.38);
    border-top-color: #f5fffd;
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

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

button:disabled:hover {
    background: #1c6f67;
    border-color: rgba(47, 158, 143, 0.55);
}

button.secondary:disabled:hover {
    background: #202b39;
    border-color: var(--line);
}

button:active {
    transform: translateY(1px);
}

button.secondary {
    background: #202b39;
    border-color: var(--line);
    color: var(--text);
}

button.danger {
    background: rgba(210, 75, 90, 0.12);
    border-color: rgba(210, 75, 90, 0.55);
    color: #ffb8c0;
}

.form-message {
    min-height: 20px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
}

.form-message.error {
    color: #ffb8c0;
}

.drop-zone {
    display: grid;
    gap: 5px;
    min-height: 112px;
    align-content: center;
    justify-items: center;
    border: 1px dashed rgba(139, 152, 169, 0.7);
    border-radius: 8px;
    background: #0f1520;
    color: var(--muted);
    cursor: pointer;
    text-align: center;
    transition: background 140ms ease, border-color 140ms ease;
}

.drop-zone strong {
    max-width: 100%;
    overflow: hidden;
    color: var(--text);
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drop-zone span {
    font-size: 13px;
}

.drop-zone:hover,
.drop-zone.drag-over,
.drop-zone:focus-visible {
    border-color: var(--accent-2);
    background: rgba(76, 142, 218, 0.1);
    outline: none;
}

.drop-zone[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.58;
}

.drop-zone.busy {
    border-style: solid;
    border-color: rgba(76, 142, 218, 0.7);
    background: rgba(76, 142, 218, 0.12);
}

.upload-progress {
    display: none;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #0d131d;
}

.upload-progress.visible {
    display: block;
}

.upload-progress span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
    transition: width 180ms ease;
}

.upload-progress.indeterminate span {
    width: 38%;
    animation: indeterminate 1050ms ease-in-out infinite;
}

@keyframes indeterminate {
    0% {
        transform: translateX(-110%);
    }
    100% {
        transform: translateX(285%);
    }
}

.toast-region {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 20;
    display: grid;
    gap: 10px;
    width: min(380px, calc(100vw - 32px));
}

.toast {
    position: relative;
    border: 1px solid rgba(47, 158, 143, 0.45);
    border-radius: 8px;
    background: #111a25;
    box-shadow: 0 16px 34px var(--shadow);
    color: var(--text);
    padding: 11px 40px 11px 12px;
    font-size: 13px;
}

.toast.success {
    border-color: rgba(47, 158, 143, 0.65);
}

.toast.error {
    border-color: rgba(210, 75, 90, 0.65);
    color: #ffccd2;
}

.toast.warning {
    border-color: rgba(212, 169, 63, 0.7);
    color: #f1d58a;
}

.toast.info {
    border-color: rgba(76, 142, 218, 0.65);
}

.toast-close {
    position: absolute;
    right: 7px;
    top: 6px;
    width: 28px;
    min-width: 28px;
    min-height: 28px;
    border-color: transparent;
    background: transparent;
    color: inherit;
    padding: 0;
}

.toast-close:hover {
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.05);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    align-items: center;
    justify-items: center;
    background: rgba(4, 8, 13, 0.72);
    padding: 20px;
}

.modal-backdrop.hidden {
    display: none;
}

.modal {
    width: min(560px, 100%);
    overflow: hidden;
    border: 1px solid rgba(48, 59, 77, 0.9);
    border-radius: 10px;
    background: #111a25;
    box-shadow: 0 26px 60px rgba(0, 0, 0, 0.45);
}

.modal-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
}

.modal-heading h2 {
    margin: 0;
    font-size: 18px;
}

.modal-heading p,
.remove-target span,
.remove-options small {
    color: var(--muted);
    font-size: 12px;
}

.modal form {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.remove-target {
    display: grid;
    gap: 4px;
}

.remove-target strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remove-options {
    display: grid;
    gap: 8px;
    margin: 0;
    border: 0;
    padding: 0;
}

.remove-options legend {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.remove-options label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    border: 1px solid rgba(48, 59, 77, 0.72);
    border-radius: 8px;
    background: #0f1520;
    padding: 10px;
}

.remove-options input {
    width: auto;
    min-height: 0;
    margin-top: 3px;
}

.remove-options strong,
.remove-options small {
    display: block;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.metric {
    padding: 15px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.metric strong {
    display: block;
    margin-top: 5px;
    font-size: 24px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.panel-heading p,
.sort-summary {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.panel-heading-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.torrent-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(120px, 0.5fr) minmax(140px, 0.55fr) minmax(150px, 0.7fr) minmax(98px, auto) auto;
    gap: 12px;
    align-items: end;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    background: #111822;
}

.search-wrap {
    display: grid;
    gap: 7px;
}

.search-control {
    display: flex;
    gap: 8px;
}

.search-control input {
    min-width: 0;
}

select {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0f1520;
    color: var(--text);
    padding: 0 36px 0 12px;
    outline: none;
}

select:focus {
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(76, 142, 218, 0.16);
}

.icon-button {
    min-width: 66px;
}

.hidden {
    display: none !important;
}

.reset-button {
    align-self: end;
}

.filter-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    background: #101722;
}

.filter-chip {
    min-height: 30px;
    border-color: var(--line);
    background: #172130;
    color: var(--muted);
    padding: 0 10px;
    font-size: 12px;
}

.filter-chip.active {
    border-color: rgba(47, 158, 143, 0.7);
    background: rgba(47, 158, 143, 0.16);
    color: #98e4da;
}

.batch-toolbar {
    display: grid;
    grid-template-columns: minmax(180px, auto) minmax(280px, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    background: #111822;
}

.batch-selection-group {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.batch-select-visible,
.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.batch-select-visible input,
.checkbox-inline input,
.torrent-select input {
    width: 16px;
    min-height: 16px;
    margin: 0;
}

.batch-selection-summary {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.batch-command-group {
    display: flex;
    align-items: end;
    gap: 10px;
    min-width: 0;
}

.batch-field {
    min-width: 170px;
}

.batch-field-wide {
    min-width: 240px;
}

.batch-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

#batchStatus {
    grid-column: 1 / -1;
    min-height: 0;
    margin: 0;
    padding: 0;
}

.server-info-panel {
    margin-top: 16px;
}

.server-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
        "runtime network"
        "torrent discovery"
        "torrent jvm";
    gap: 12px;
    align-items: start;
    padding: 14px 16px 16px;
}

.server-info-section {
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
}

.server-runtime-section {
    grid-area: runtime;
}

.server-network-section {
    grid-area: network;
}

.server-torrent-section {
    grid-area: torrent;
}

.server-feature-section {
    grid-area: discovery;
}

.server-jvm-section {
    grid-area: jvm;
}

.server-info-section .section-toggle {
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    color: #cbd7e6;
    font-size: 13px;
    font-weight: 700;
}

.server-info-section.collapsed .section-toggle {
    border-bottom: 0;
}

.info-kv-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    background: rgba(48, 59, 77, 0.52);
}

.info-kv {
    min-width: 0;
    display: grid;
    gap: 4px;
    padding: 9px 12px;
    background: #121a26;
}

.info-kv span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.info-kv strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feature-pill-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px;
}

.info-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
}

.info-pill.enabled,
.info-pill.up {
    border-color: rgba(47, 158, 143, 0.65);
    background: rgba(47, 158, 143, 0.13);
    color: #a9eee4;
}

.info-pill.disabled {
    border-color: rgba(139, 152, 169, 0.45);
    background: rgba(139, 152, 169, 0.1);
    color: #c4cfdd;
}

.info-pill.unknown {
    border-color: rgba(212, 169, 63, 0.65);
    background: rgba(212, 169, 63, 0.12);
    color: #f1d58a;
}

.info-pill.down,
.info-pill.error {
    border-color: rgba(210, 75, 90, 0.65);
    background: rgba(210, 75, 90, 0.13);
    color: #ffccd2;
}

.telemetry-panel {
    margin: 16px 0;
}

.compact-label {
    min-width: 140px;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px 16px 16px;
}

.chart-card {
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
}

.chart-card-wide {
    grid-column: 1 / -1;
}

.chart-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
}

.chart-card h3 {
    margin: 0;
    font-size: 14px;
}

.chart-card p,
.chart-stats,
.chart-legend {
    color: var(--muted);
    font-size: 12px;
}

.chart-card p {
    margin-top: 4px;
}

.chart-stats {
    display: grid;
    gap: 4px;
    justify-items: end;
    text-align: right;
}

.chart-canvas-wrap {
    position: relative;
    height: 260px;
    padding: 10px 10px 4px;
}

.chart-canvas-wrap.compact {
    height: 190px;
}

.chart-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.chart-legend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    padding: 0 12px 12px;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-swatch {
    display: inline-block;
    width: 16px;
    height: 3px;
    border-radius: 999px;
}

.legend-swatch.download {
    background: #4c8eda;
}

.legend-swatch.upload {
    background: #2f9e8f;
}

.legend-swatch.peers {
    background: #d4a93f;
}

.legend-swatch.active-torrents {
    background: #c785ff;
}

.torrent-list {
    display: grid;
    gap: 1px;
    background: var(--line);
}

.loading-state,
.stale-notice {
    display: none;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    color: var(--muted);
    font-size: 13px;
}

.loading-state.visible {
    display: block;
}

.loading-state::before {
    content: "";
    display: inline-block;
    width: 13px;
    height: 13px;
    margin-right: 8px;
    border: 2px solid rgba(139, 152, 169, 0.32);
    border-top-color: var(--accent-2);
    border-radius: 50%;
    vertical-align: -2px;
    animation: spin 800ms linear infinite;
}

.stale-notice {
    border-color: rgba(212, 169, 63, 0.45);
    background: rgba(212, 169, 63, 0.09);
    color: #f1d58a;
}

.stale-notice:not(.hidden) {
    display: block;
}

.torrent-card {
    background: var(--panel);
    transition: background 140ms ease;
}

.torrent-card:hover {
    background: var(--panel-2);
}

.torrent-card.expanded {
    background: var(--panel-2);
}

.torrent-summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1.8fr) minmax(140px, 0.8fr) minmax(160px, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 15px 16px;
    cursor: pointer;
}

.torrent-select {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    cursor: pointer;
}

.torrent-summary:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: -2px;
}

.torrent-title {
    min-width: 0;
}

.torrent-title strong {
    display: block;
    overflow: hidden;
    overflow-wrap: anywhere;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.torrent-title span,
.torrent-meta,
.speed-row {
    color: var(--muted);
    font-size: 13px;
}

.torrent-meta {
    display: grid;
    gap: 4px;
}

.status-chip {
    width: fit-content;
    max-width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.status-chip.running {
    border-color: rgba(76, 142, 218, 0.65);
    background: rgba(76, 142, 218, 0.13);
    color: #b9d8ff;
}

.status-chip.complete {
    border-color: rgba(47, 158, 143, 0.72);
    background: rgba(47, 158, 143, 0.15);
    color: #a9eee4;
}

.status-chip.pending {
    border-color: rgba(212, 169, 63, 0.68);
    background: rgba(212, 169, 63, 0.13);
    color: #f1d58a;
}

.status-chip.flushing {
    border-color: rgba(127, 113, 255, 0.68);
    background: rgba(127, 113, 255, 0.14);
    color: #d5d0ff;
}

.status-chip.stopped {
    border-color: rgba(139, 152, 169, 0.48);
    background: rgba(139, 152, 169, 0.1);
    color: #c4cfdd;
}

.status-chip.error {
    border-color: rgba(210, 75, 90, 0.65);
    background: rgba(210, 75, 90, 0.13);
    color: #ffccd2;
}

.status-chip.unknown {
    border-color: rgba(139, 152, 169, 0.48);
    background: rgba(139, 152, 169, 0.1);
    color: #c4cfdd;
}

.torrent-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

.label-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 22px;
    border: 1px solid var(--label-color, var(--accent-2));
    border-radius: 999px;
    background: color-mix(in srgb, var(--label-color, var(--accent-2)) 18%, transparent);
    color: var(--text);
    padding: 0 8px;
    font-size: 11px;
    font-weight: 750;
}

.progress-wrap {
    display: grid;
    gap: 7px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 12px;
}

.progress {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #0d131d;
}

.progress span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width 350ms ease;
}

.speed-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.actions button {
    min-width: 72px;
}

.torrent-detail {
    border-top: 1px solid var(--line);
    background: #101722;
}

.detail-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
}

.detail-toolbar h3 {
    margin: 0;
    font-size: 15px;
}

.detail-toolbar p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.detail-content {
    padding: 14px 16px 16px;
}

.detail-action-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.detail-section {
    min-width: 0;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 8px;
    background: #121a26;
}

.detail-section.span-2 {
    grid-column: 1 / -1;
}

.detail-section.has-error {
    border-color: rgba(210, 75, 90, 0.55);
}

.detail-section .section-toggle {
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.72);
    color: #cbd7e6;
    font-size: 13px;
    font-weight: 700;
}

.detail-section.collapsed .section-toggle {
    border-bottom: 0;
}

.kv-list {
    display: grid;
    gap: 1px;
    background: rgba(48, 59, 77, 0.52);
}

.kv-row {
    display: grid;
    grid-template-columns: minmax(120px, 0.45fr) minmax(0, 1fr);
    gap: 12px;
    padding: 8px 12px;
    background: #121a26;
}

.kv-row span {
    color: var(--muted);
    font-size: 12px;
}

.kv-row strong {
    min-width: 0;
    overflow: hidden;
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: normal;
}

.server-path-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
}

.server-path-field code {
    min-width: 0;
    overflow: hidden;
    overflow-wrap: anywhere;
    border: 1px solid rgba(48, 59, 77, 0.8);
    border-radius: 6px;
    background: #0d131d;
    color: #dce8f6;
    padding: 9px 10px;
    white-space: normal;
}

.detail-hint {
    margin: 0;
    padding: 0 12px 12px;
    color: var(--muted);
    font-size: 12px;
}

.table-wrap {
    max-height: 260px;
    overflow: auto;
    overscroll-behavior-x: contain;
}

.files-table {
    max-height: 340px;
}

table {
    min-width: 620px;
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

th,
td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(48, 59, 77, 0.65);
    text-align: left;
    vertical-align: top;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #172130;
    color: #cbd7e6;
    font-weight: 700;
}

td {
    max-width: 360px;
    overflow: hidden;
    overflow-wrap: anywhere;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: normal;
}

.detail-state,
.detail-empty {
    padding: 18px 12px;
    color: var(--muted);
    font-size: 13px;
}

.detail-state.error {
    color: #ffb8c0;
}

.empty-state {
    display: none;
    padding: 34px 16px;
    color: var(--muted);
    text-align: center;
}

.empty-state strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 15px;
}

.empty-state p {
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 13px;
}

.empty-hint {
    display: inline-block;
    color: #b9d8ff;
    font-size: 12px;
}

.empty-state.visible {
    display: block;
}

@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
        width: calc(100% - 20px);
        margin-top: 14px;
    }

    .nav-drawer-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .dashboard-nav {
        position: fixed;
        inset: 76px 10px auto 10px;
        z-index: 18;
        display: none;
        max-height: calc(100vh - 96px);
        overflow: auto;
        box-shadow: 0 18px 42px var(--shadow);
    }

    .dashboard-nav.open {
        display: block;
    }

    .dashboard-nav nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metrics,
    .chart-grid,
    .server-info-grid,
    .torrent-toolbar,
    .batch-toolbar,
    .activity-toolbar,
    .media-toolbar,
    .media-stats,
    .jellyfin-grid,
    .label-grid,
    .label-form-grid,
    .logs-toolbar,
    .settings-grid,
    .pwa-status-grid,
    .storage-toolbar,
    .storage-kv-grid,
    .wizard-grid,
    .torrent-summary,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .server-info-grid {
        grid-template-areas:
            "runtime"
            "network"
            "torrent"
            "discovery"
            "jvm";
    }

    .wizard-card.span-2 {
        grid-column: auto;
    }

    .jellyfin-section.span-2 {
        grid-column: auto;
    }

    .tracker-card.span-2 {
        grid-column: auto;
    }

    .tracker-active-card,
    .tracker-add-row,
    .tracker-test-row,
    .label-assign-row {
        grid-template-columns: 1fr;
    }

    .tracker-active-card .tracker-card-heading,
    .tracker-active-card > label,
    .tracker-active-card .tracker-info,
    .tracker-active-card .tracker-health-list {
        grid-column: auto;
        grid-row: auto;
    }

    .label-card.span-2,
    .label-form-grid .span-2 {
        grid-column: auto;
    }

    .torrent-summary {
        align-items: stretch;
    }

    .batch-toolbar {
        align-items: stretch;
    }

    .batch-selection-group,
    .batch-command-group,
    .batch-actions {
        justify-content: flex-start;
    }

    .batch-command-group {
        flex-wrap: wrap;
    }

    .batch-field,
    .batch-field-wide {
        flex: 1 1 180px;
        min-width: 0;
    }

    .actions {
        justify-content: flex-start;
    }

    .torrent-summary {
        gap: 12px;
    }

    .chart-canvas-wrap {
        height: 220px;
    }

    .log-line-main {
        grid-template-columns: 74px 64px minmax(0, 1fr);
    }

    .log-line-main button {
        justify-self: start;
    }
}

@media (max-width: 520px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions,
    .topbar-actions > div:first-child {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }

    .shell {
        width: calc(100% - 20px);
        margin-top: 14px;
    }

    .app-shell {
        width: calc(100% - 20px);
    }

    .dashboard-nav {
        top: 136px;
        inset: 136px 10px auto 10px;
    }

    .dashboard-nav nav {
        grid-template-columns: 1fr;
    }

    .add-header {
        align-items: stretch;
        flex-direction: column;
    }

    .add-tabs {
        flex-wrap: wrap;
    }

    .panel-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .panel-heading-actions {
        align-items: stretch;
        justify-content: flex-start;
    }

    .panel-heading-actions > *,
    .add-tabs,
    .add-tabs button,
    .actions button,
    .detail-action-bar button {
        width: 100%;
    }

    .compact-label {
        min-width: 0;
    }

    .chart-card-heading {
        flex-direction: column;
    }

    .activity-event-main {
        flex-direction: column;
    }

    .info-kv-grid {
        grid-template-columns: 1fr;
    }

    .chart-stats {
        justify-items: start;
        text-align: left;
    }

    .search-control {
        flex-direction: column;
    }

    .torrent-title strong {
        white-space: normal;
    }

    .progress-label,
    .speed-row {
        gap: 6px;
        flex-direction: column;
    }

    .media-list {
        grid-template-columns: 1fr;
        padding-left: 12px;
        padding-right: 12px;
    }

    .media-pagination {
        align-items: stretch;
        flex-direction: column;
        padding-left: 12px;
        padding-right: 12px;
    }

    .media-pagination-controls {
        justify-content: flex-start;
    }

    .storage-card-heading {
        flex-direction: column;
    }

    .storage-card-actions {
        justify-content: flex-start;
    }

    .automation-grid {
        grid-template-columns: 1fr;
        padding-left: 12px;
        padding-right: 12px;
    }

    .automation-card.span-2 {
        grid-column: auto;
    }

    .notification-grid,
    .notification-form-grid {
        grid-template-columns: 1fr;
    }

    .notification-card.span-2,
    .notification-form-grid .span-2 {
        grid-column: auto;
    }

    .notification-target-main {
        flex-direction: column;
    }

    .tracker-grid,
    .tracker-info-grid,
    .settings-row {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        padding-left: 12px;
        padding-right: 12px;
    }

    .settings-row-value {
        justify-items: start;
        text-align: left;
    }

    .settings-input-wrap {
        width: 100%;
    }

    .settings-switch {
        justify-content: flex-start;
    }

    .settings-badges {
        justify-content: flex-start;
    }

    .tracker-preset {
        grid-template-columns: 1fr;
    }

    .label-item {
        grid-template-columns: 1fr;
    }

    .label-item-actions {
        justify-content: flex-start;
    }

    .recovery-session-main {
        flex-direction: column;
    }

    .media-card {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .media-poster {
        width: 72px;
    }

    .chart-canvas-wrap,
    .chart-canvas-wrap.compact {
        height: 180px;
    }

    .metric strong {
        font-size: 20px;
    }

    .detail-content,
    .detail-toolbar,
    .torrent-summary {
        padding-left: 12px;
        padding-right: 12px;
    }

    .kv-row {
        grid-template-columns: 1fr;
        gap: 3px;
    }

    .server-path-field {
        grid-template-columns: 1fr;
    }

    .modal-actions {
        justify-content: stretch;
    }

    .modal-actions button {
        flex: 1;
    }
}
