/* Sulla Cloud app: shared components (buttons, controls, cards, tables,
   dialogs, toast) plus the loading / error / empty / coming-soon primitives
   every screen uses. Ported from the approved mockup. */

/* ── Buttons & controls (FilesBrowser) ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card-solid); font-size: 12.5px; font-weight: 500; color: var(--text); box-shadow: 0 1px 1px rgba(var(--tint), .03); white-space: nowrap; line-height: 1.45; }
.btn:hover { border-color: var(--accent-line); color: var(--accent-2); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.pri:hover { background: var(--accent-2); color: var(--on-accent); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 3px 8px; font-size: 11.5px; border-radius: 6px; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--ink-05); color: var(--text); }
.btn .bi { display: grid; width: 13px; height: 13px; flex: none; } .btn .bi svg { width: 13px; height: 13px; }
.btn.ico { padding: 6px; width: 30px; height: 30px; justify-content: center; }
.btn.ico svg { width: 15px; height: 15px; }
.btn.round { border-radius: 999px; padding: 7px 16px 7px 12px; font-size: 13.5px; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; background: var(--card-solid); padding: 2px; gap: 2px; }
.seg button { white-space: nowrap; border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 500; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; line-height: 1.45; }
.seg button .bi { display: grid; width: 13px; height: 13px; } .seg button .bi svg { width: 13px; height: 13px; }
.seg button.on { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.seg button:hover:not(.on) { color: var(--text); }
.seg button span.n { color: var(--dim); font-size: 10.5px; }
.sel { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--card-solid); font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; cursor: pointer; }
.sel > span { color: var(--dim); font-weight: 400; }
.sel::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--dim); border-bottom: 1.5px solid var(--dim); transform: rotate(45deg) translateY(-2px); }
.sel select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 12px; }
.sel.active { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-2); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.pill.idle { background: var(--idle-soft); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.acc { background: var(--accent-soft); color: var(--accent-2); }
.pill .bi { width: 11px; height: 11px; display: grid; } .pill .bi svg { width: 11px; height: 11px; }
.chk { width: 14px; height: 14px; padding: 0; border: 1.5px solid var(--line-2); border-radius: 4px; background: var(--card-solid); display: inline-block; vertical-align: middle; position: relative; }
.chk.on { background: var(--accent); border-color: var(--accent); }
.chk.on::after { content: ""; position: absolute; left: 3.5px; top: .5px; width: 4px; height: 7px; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(45deg); }
.switch { position: relative; display: inline-block; width: 30px; height: 18px; flex: none; }
.switch input { position: absolute; opacity: 0; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + i { background: var(--accent); } .switch input:checked + i::after { transform: translateX(12px); }

/* ── Pages ── */
.view { min-height: 0; overflow: auto; position: relative; }
.content { padding: 20px 28px 60px; max-width: 1480px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar h1, .h1 { font-size: 20px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
.toolbar .meta { color: var(--dim); font-size: 12px; }
.toolbar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.page-head { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.page-head h1 { margin: 0 0 3px; font-size: 24px; line-height: 1.2; font-weight: 680; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--muted); font-size: 12.5px; }
.page-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.stream { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.stream i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok) 5%, transparent); } }
.filters { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters .clear { font-size: 12px; color: var(--muted); padding: 5px 8px; border-radius: 7px; border: 0; background: transparent; }
.filters .view-r { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card { background: var(--card); backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 8px; padding: 13px 16px 10px; }
.card-h h2 { margin: 0; font-size: 13px; font-weight: 650; }
.card-h .r { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-h a.more { color: var(--accent-2); font-size: 12px; font-weight: 500; }
.muted { color: var(--muted); } .dim { color: var(--dim); }
.mono { font-family: var(--mono); font-size: 12px; }
.kicker { color: var(--accent-2); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }

/* Summary cards (AgentsTab) */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-card { min-height: 100px; padding: 14px 16px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.summary-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11.5px; font-weight: 550; }
.summary-card strong { display: block; margin: 7px 0 2px; font-size: 27px; line-height: 1.05; font-weight: 680; letter-spacing: -.03em; }
.summary-card strong small { font-size: 15px; color: var(--dim); font-weight: 600; letter-spacing: 0; }
.summary-card > span { color: var(--dim); font-size: 11px; }
.summary-card.warning strong { color: var(--warn); } .summary-card.danger strong { color: var(--bad); }

/* Tables (FilesBrowser .tbl) */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); font-weight: 600; text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th:first-child, .tbl td:first-child { padding-left: 16px; } .tbl th:last-child, .tbl td:last-child { padding-right: 14px; }
.tbl .r { text-align: right; }
.tbl td.muted, .tbl td.r, .tbl td .src, .tbl td .own, .tbl td .res { white-space: nowrap; }
.tbl tr.row { cursor: default; } .tbl tr.row.click { cursor: pointer; }
.tbl tr.row:hover td { background: color-mix(in srgb, var(--accent) 4.5%, transparent); }
.tbl tr.row.is-sel td { background: var(--accent-soft); }
.tbl tr.sechead td { padding: 12px 16px 4px; border-bottom: 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); font-weight: 600; }

/* Modal (AgentsTab .action-modal) */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; padding: 24px; background: rgba(6, 10, 16, .52); backdrop-filter: blur(5px); }
.modal-backdrop.open { display: grid; }
.action-modal { width: min(460px, 100%); padding: 22px; border: 1px solid var(--line-2); border-radius: 14px; color: var(--text); background: var(--card-solid); box-shadow: 0 24px 70px rgba(0,0,0,.24); }
.action-modal h2 { margin: 7px 0 5px; font-size: 20px; }
.action-modal p { margin: 0 0 16px; color: var(--muted); font-size: 12.5px; }
.action-modal textarea, .field { width: 100%; resize: vertical; padding: 10px 11px; border: 1px solid var(--line-2); border-radius: 9px; outline: 0; color: var(--text); background: var(--paper); font-size: 13px; line-height: 1.45; }
.action-modal textarea:focus, .field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 90; padding: 9px 13px; border: 1px solid var(--line-2); border-radius: 9px; color: var(--text); background: var(--card-solid); box-shadow: 0 10px 35px rgba(0,0,0,.18); display: none; align-items: center; gap: 8px; }
.toast.open { display: flex; }

/* ── State primitives (js/cloud/shell/states.js) ── */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 56px 24px; color: var(--muted); }
.state.compact { padding: 22px 16px; }
.state .state-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-2); margin-bottom: 4px; }
.state .state-ico svg { width: 22px; height: 22px; }
.state.error .state-ico { background: var(--bad-soft); color: var(--bad); }
.state b { color: var(--text); font-size: 15px; font-weight: 650; }
.state p { margin: 0; max-width: 440px; font-size: 12.5px; line-height: 1.55; }
.state .state-acts { display: flex; gap: 8px; margin-top: 8px; }
.state .state-detail { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
.state.loading { flex-direction: row; gap: 10px; font-size: 12.5px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--ink-05), var(--ink-08), var(--ink-05)); background-size: 200% 100%; animation: skel 1.4s ease-in-out infinite; }
@keyframes skel { to { background-position: -200% 0; } }

/* Coming-soon body: an honest placeholder until the screen's chunk lands. */
.soon { max-width: 760px; }
.soon .card { padding: 4px 0; }
.soon ul { margin: 6px 0 0; padding: 0 0 0 18px; color: var(--muted); font-size: 12.5px; line-height: 1.7; text-align: left; }
.soon .state { padding: 40px 24px 34px; }

/* Secure-channel pairing modal (js/secure-channel.js) on Cloud pages. */
.sc-modal-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 20px; }
.sc-modal { width: min(460px, 100%); background: var(--card-solid); color: var(--text); border: 1px solid var(--line-2); border-radius: 14px; padding: 24px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.sc-modal h3 { display: flex; align-items: center; gap: 8px; font-size: 17px; margin: 0 0 10px; }
.sc-modal h3 .material-symbols-outlined { display: none; }
.sc-modal p, .sc-modal li { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.sc-modal ol { padding-left: 20px; margin: 10px 0; }
.sc-code { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 34px; font-weight: 600; letter-spacing: .18em; text-align: center; padding: 14px; margin: 8px 0 4px; background: var(--paper-2); border: 1px dashed var(--line-2); border-radius: 10px; }
.sc-err { color: var(--bad); font-size: 13px; margin-top: 8px; }
.sc-err.hidden { display: none; }
.sc-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
