.nas-page { width: auto; height: auto; min-width: 1920px; overflow: hidden; }
.nas-page:not(.auth-locked) { overflow: auto; }
.nas-brand-icon { background: linear-gradient(145deg, #1699a4, #6558e8); }
/* Preserve the desktop panels; native page scroll exposes them in small windows. */
.nas-main { display: flex; height: max(1010px, calc(100vh - 70px)); min-height: 0; flex-direction: column; overflow: hidden; padding: 12px 18px 14px; }
.nas-panel { border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }

.nas-grid { display: grid; min-height: 0; flex: 1; grid-template-columns: minmax(1050px, 1.62fr) minmax(610px, .9fr); gap: 14px; align-items: stretch; }
.nas-left, .nas-right { display: grid; min-width: 0; min-height: 0; gap: 14px; }
.nas-left { grid-template-rows: clamp(390px, 43vh, 500px) minmax(0, 1fr); }
.nas-right { position: static; grid-template-rows: minmax(0, 1fr) clamp(280px, 31vh, 360px); }
.nas-panel { min-width: 0; overflow: hidden; border-radius: 15px; }
.search-panel, .library-panel { display: flex; min-height: 0; flex-direction: column; }
.panel-head { display: flex; height: 65px; align-items: center; justify-content: space-between; gap: 16px; padding: 0 17px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 19px; letter-spacing: -.03em; }
.panel-head > p { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; }

.model-search { display: grid; grid-template-columns: minmax(380px, 1fr) 148px; gap: 8px; padding: 14px 16px 10px; }
.search-input { display: flex; height: 52px; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-soft); }
.search-input:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(21,157,165,.1); }
.search-input > span { color: var(--cyan); font-size: 22px; }
.search-input input { min-width: 0; flex: 1; border: 0; outline: none; color: var(--text); background: transparent; font-size: 14px; }
.search-input button { width: 28px; height: 28px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; }
.search-submit { border: 0; border-radius: 10px; color: #fff; background: linear-gradient(135deg, var(--cyan), var(--primary)); box-shadow: 0 9px 20px rgba(55,92,196,.2); font-size: 13px; font-weight: 850; cursor: pointer; }
.search-submit:disabled { opacity: .55; cursor: wait; }
.search-submit b { margin-left: 8px; }
.search-meta { display: flex; justify-content: space-between; gap: 12px; padding: 0 17px 12px; color: var(--muted); font-size: 11px; }
.search-results { display: grid; min-height: 0; flex: 1; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: max-content; align-content: start; gap: 8px; overflow-y: auto; padding: 0 16px 16px; }
.search-results.is-empty { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
.search-empty { display: grid; min-height: 0; place-content: center; justify-items: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 11px; background: var(--surface-soft); }
.search-empty i { font: 400 34px/1 sans-serif; }
.search-empty strong { margin: 9px 0 5px; color: var(--text); font-size: 15px; }
.search-empty span { font-size: 12px; }
.repo-card { display: flex; min-width: 0; flex-direction: column; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.repo-card:hover { border-color: color-mix(in srgb, var(--cyan), var(--line) 40%); }
.repo-title { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; }
.repo-title h3 { min-width: 0; overflow: hidden; margin: 0 0 4px; font-size: 15px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.repo-title span { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.repo-card > code { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.repo-tags { display: flex; gap: 5px; min-height: 22px; margin: 10px 0; overflow: hidden; }
.repo-tags span { flex: 0 0 auto; padding: 4px 6px; color: var(--muted); border-radius: 4px; background: var(--surface-strong); font-size: 11px; font-weight: 700; }
.repo-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.repo-actions a, .repo-actions button { display: grid; height: 32px; place-items: center; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; text-decoration: none; font-size: 11px; font-weight: 800; }
.repo-actions a { color: var(--muted); }
.repo-actions button { width: 96px; flex: 0 0 96px; color: #fff; border-color: var(--primary); background: var(--primary); white-space: nowrap; cursor: pointer; }
.repo-actions button:disabled { color: var(--muted); border-color: var(--line); background: var(--surface-strong); cursor: not-allowed; }

.panel-tools { display: flex; align-items: center; gap: 6px; }
.panel-tools label { display: flex; height: 34px; align-items: center; gap: 6px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.panel-tools input { width: 170px; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 11px; }
.panel-tools button, .task-log-panel .panel-head > button { height: 34px; padding: 0 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); font-size: 11px; font-weight: 800; cursor: pointer; }
.model-inventory { display: grid; min-height: 0; flex: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; overflow-y: auto; padding: 13px 16px 16px; }
.inventory-empty { grid-column: 1/-1; padding: 50px; color: var(--muted); text-align: center; }
.inventory-card { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main actions" "meta actions"; align-content: center; align-items: center; gap: 8px 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.inventory-main { display: flex; grid-area: main; align-items: start; justify-content: space-between; gap: 10px; }
.inventory-main > div { min-width: 0; }
.inventory-main strong { display: block; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.inventory-main code { display: block; overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.inventory-main > span { flex: 0 0 auto; padding: 5px 7px; color: var(--green-dark); border-radius: 5px; background: var(--green-soft); font-size: 11px; font-weight: 800; }
.inventory-main > span.unmanaged { color: var(--amber); background: var(--amber-soft); }
.inventory-meta { display: flex; grid-area: meta; flex-wrap: wrap; gap: 6px 13px; margin: 0; color: var(--muted); font-size: 11px; }
.inventory-meta .verification-progress { color: var(--cyan); font-family: ui-monospace, "Cascadia Code", monospace; font-weight: 850; white-space: nowrap; }
.inventory-actions { display: flex; grid-area: actions; justify-content: flex-end; gap: 6px; }
.inventory-actions button { width: auto; min-width: 92px; height: 34px; padding: 0 11px; color: var(--text); border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 11px; font-weight: 800; white-space: nowrap; cursor: pointer; }
.inventory-actions button:nth-child(2) { color: var(--primary-dark); border-color: color-mix(in srgb, var(--primary), transparent 68%); }
.inventory-actions button.delete { min-width: 58px; color: var(--red); border-color: color-mix(in srgb, var(--red), transparent 64%); background: var(--red-soft); }

.task-panel, .task-log-panel { display: flex; min-height: 0; flex-direction: column; }
.live-chip { display: flex; align-items: center; gap: 6px; color: var(--green-dark); font-size: 11px; font-weight: 800; }
.live-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green), transparent 84%); }
.task-head-tools { display: flex; align-items: center; gap: 11px; }
.task-head-tools > button { height: 32px; padding: 0 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); font-size: 11px; font-weight: 800; cursor: pointer; }
.task-head-tools > button:disabled { opacity: .42; cursor: not-allowed; }
.task-list { min-height: 0; flex: 1; overflow-y: auto; padding: 11px 13px 13px; }
.task-list.is-empty { display: grid; grid-template-rows: minmax(0, 1fr); }
.task-empty { display: grid; min-height: 0; place-items: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 10px; font-size: 12px; }
.task-card { padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); cursor: pointer; }
.task-card + .task-card { margin-top: 7px; }
.task-card.selected { border-color: var(--cyan); box-shadow: inset 3px 0 0 var(--cyan); }
.task-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.task-head > div { min-width: 0; }
.task-head strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.task-head small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.task-status { flex: 0 0 auto; padding: 5px 7px; color: var(--muted); border-radius: 5px; background: var(--surface-strong); font-size: 11px; font-weight: 850; }
.task-status.running, .task-status.queued { color: var(--cyan); background: color-mix(in srgb, var(--cyan), transparent 89%); }
.task-status.succeeded { color: var(--green-dark); background: var(--green-soft); }
.task-status.failed { color: var(--red); background: var(--red-soft); }
.task-progress { height: 5px; overflow: hidden; margin: 10px 0 7px; border-radius: 5px; background: var(--surface-strong); }
.task-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--primary)); transition: width .3s; }
.task-stats { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font: 700 11px/1.3 ui-monospace, monospace; }
.task-message { overflow: hidden; margin: 7px 0 0; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.task-actions { display: flex; gap: 5px; margin-top: 8px; }
.task-actions button { height: 29px; padding: 0 8px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; background: var(--surface); font-size: 11px; font-weight: 800; cursor: pointer; }
.task-actions .stop { color: var(--red); }
.task-log-panel pre { min-height: 0; flex: 1; overflow: auto; margin: 0; padding: 13px; color: #335054; background: #eef7f6; font: 11px/1.6 ui-monospace, "Cascadia Code", monospace; white-space: pre-wrap; }

.download-dialog { width: 620px; padding: 0; color: var(--text); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 30px 90px rgba(9,19,48,.3); }
.download-dialog::backdrop { background: rgba(5,8,23,.72); backdrop-filter: blur(7px); }
.download-dialog form > header { display: flex; align-items: center; justify-content: space-between; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.download-dialog h2 { margin: 0; font-size: 20px; }
.download-dialog header button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); cursor: pointer; }
.dialog-repo { padding: 16px 19px 8px; }
.dialog-repo small { color: var(--cyan); font: 800 10px/1 ui-monospace, monospace; }
.dialog-repo strong { display: block; margin: 7px 0 4px; font-size: 17px; }
.dialog-repo span { color: var(--muted); font-size: 11px; }
.dialog-fields { display: grid; grid-template-columns: 1.2fr 1fr; gap: 7px; padding: 10px 19px; }
.dialog-fields label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 800; }
.dialog-fields input { width: 100%; height: 38px; padding: 0 9px; color: var(--text); border: 1px solid var(--line-strong); border-radius: 7px; outline: none; background: var(--surface-soft); font-size: 12px; }
.download-dialog footer { display: flex; justify-content: end; gap: 8px; padding: 16px 19px 19px; }
.download-dialog footer button { height: 39px; padding: 0 15px; border-radius: 8px; font-size: 12px; font-weight: 850; cursor: pointer; }
.dialog-cancel { color: var(--muted); border: 1px solid var(--line); background: var(--surface-soft); }
.dialog-submit { color: #fff; border: 0; background: linear-gradient(135deg, var(--cyan), var(--primary)); }
.dialog-submit:disabled { opacity: .55; cursor: wait; }
.delete-warning { display: flex; gap: 9px; margin: 10px 19px 2px; padding: 11px; color: var(--red); border: 1px solid color-mix(in srgb, var(--red), transparent 68%); border-radius: 8px; background: var(--red-soft); font-size: 11px; line-height: 1.5; }
.delete-warning i { display: grid; width: 19px; height: 19px; flex: 0 0 auto; place-items: center; color: #fff; border-radius: 50%; background: var(--red); font: 900 11px/1 ui-monospace, monospace; }
.delete-fields { grid-template-columns: 1fr; }
.dialog-delete-submit { color: #fff; border: 0; background: linear-gradient(135deg, #ff6f82, var(--red)); }
.dialog-delete-submit:disabled { opacity: .4; cursor: not-allowed; filter: saturate(.4); }

@media (min-width: 2500px) {
  .nas-main { padding-right: 24px; padding-left: 24px; }
  .nas-grid { grid-template-columns: minmax(1450px, 1.7fr) minmax(760px, .85fr); }
  .search-results { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .model-inventory { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
