/* Threeum Defense — operational console (builds on styles.css) */

body.ds-body { background: var(--surface-2); }

/* Slim app topbar */
.ds-topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface); border-bottom: 1px solid var(--line);
  height: 60px; display: flex; align-items: center;
}
.ds-topbar__inner { width: 100%; max-width: 1360px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 16px; }
.ds-topbar__title { font-size: .82rem; color: var(--slate-500); font-weight: 600; letter-spacing: .02em; padding-left: 16px; margin-left: 4px; border-left: 1px solid var(--line-2); }
.ds-topbar__spacer { flex: 1 1 auto; }
.ds-topbar__right { display: flex; align-items: center; gap: 12px; }
.ds-conn { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--slate-600); }
.ds-conn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok-600); box-shadow: 0 0 0 3px var(--ok-050); }
.ds-conn__meta { color: var(--slate-400); font-family: var(--font-mono); font-size: .74rem; }

.ds-main { padding: 24px 0 80px; min-height: calc(100vh - 60px); }
.ds-wrap { width: 100%; max-width: 1360px; margin: 0 auto; padding: 0 24px; }

/* Centered single-panel screens (connecting / disconnected / key entry) */
.ds-center { display: grid; place-items: center; min-height: 62vh; }
.ds-panel { max-width: 560px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 34px; box-shadow: var(--shadow-sm); }
.ds-panel--wide { max-width: 640px; }
.ds-panel h1 { font-size: 1.5rem; }
.ds-panel .note { margin: 20px 0; }
.ds-panel pre { margin: 12px 0 0; }

/* Key entry form */
.ds-form { margin-top: 22px; display: flex; flex-direction: column; gap: 8px; }
.ds-form label { font-size: var(--fs-control); font-weight: 600; color: var(--ink-800); }
.ds-input { font-family: var(--font-mono); font-size: var(--fs-control); padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface-2); color: var(--ink-900); width: 100%; }
.ds-input:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 1px; background: #fff; }
.ds-form__msg { color: var(--danger-700); font-size: .88rem; min-height: 1em; margin: 4px 0 0; }
.ds-form .btn { margin-top: 10px; }

/* App shell: sidebar + content */
.ds-shell { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 900px) { .ds-shell { grid-template-columns: 216px 1fr; } }

.ds-side { align-self: start; }
@media (min-width: 900px) { .ds-side { position: sticky; top: 84px; } }
.ds-side__label { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--slate-400); font-weight: 600; padding: 0 12px 10px; }
.ds-nav { display: flex; flex-direction: column; gap: 1px; }
.ds-nav__item { display: flex; align-items: center; gap: 10px; text-align: left; font-family: inherit; font-size: var(--fs-control); font-weight: 500; color: var(--slate-600); background: transparent; border: 0; border-radius: 8px; padding: 9px 12px; cursor: pointer; width: 100%; }
.ds-nav__item:hover { background: var(--surface-3); color: var(--ink-900); }
.ds-nav__item[aria-current="true"] { background: var(--surface); color: var(--ink-900); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.ds-nav__item .ic { width: 16px; height: 16px; color: currentColor; flex: none; }
.ds-nav__sep { height: 1px; background: var(--line); margin: 10px 4px; }
.ds-nav__item--danger { color: var(--slate-500); }
.ds-nav__item--danger:hover { color: var(--danger-700); background: var(--danger-050); }

.ds-content { min-width: 0; }
.ds-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.ds-head h1 { font-size: 1.4rem; margin: 0; letter-spacing: -0.02em; }
.ds-head .sub { margin: 0; color: var(--slate-400); font-size: .86rem; flex: 1 1 200px; }
.ds-head .actions { display: flex; gap: 8px; margin-left: auto; }

/* KPI cards */
.ds-kpis { display: grid; gap: 14px; margin-bottom: 22px; }
@media (min-width: 620px) { .ds-kpis { grid-template-columns: repeat(3, 1fr); } }
.ds-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.ds-kpi__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-400); font-weight: 600; }
.ds-kpi__value { font-size: 1.9rem; font-weight: 680; color: var(--ink-900); letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.ds-kpi__value small { font-size: .8rem; font-weight: 500; color: var(--slate-400); }

/* Panels */
.ds-panel-box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ds-panel-box__head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.ds-panel-box__head h3 { margin: 0; font-size: .98rem; }
.ds-panel-box__body { padding: 4px 0; }
.ds-grid2 { display: grid; gap: 16px; }
@media (min-width: 860px) { .ds-grid2 { grid-template-columns: 1fr 1fr; } }

/* Toolbar (filter/search) */
.ds-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.ds-search { position: relative; flex: 1 1 240px; }
.ds-search input { width: 100%; font-family: inherit; font-size: var(--fs-control); padding: 9px 12px 9px 34px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); color: var(--ink-800); }
.ds-search input:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.ds-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--slate-400); }
.ds-count { font-size: .82rem; color: var(--slate-400); }

/* Data tables (dense, readable) */
.ds-table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.ds-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.ds-table th, .ds-table td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ds-table thead th { position: sticky; top: 0; background: var(--surface-2); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-500); font-weight: 600; z-index: 1; }
.ds-table tbody tr:last-child td { border-bottom: 0; }
.ds-table tbody tr.clickable { cursor: pointer; }
.ds-table tbody tr.clickable:hover { background: var(--accent-050); }
.ds-table td.mono, .ds-table td .mono { font-family: var(--font-mono); font-size: .82rem; color: var(--slate-600); }
.ds-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.ds-list { margin: 0; padding-left: 1.1em; }
.ds-pre { background: var(--ink-surface); color: #e7ecf5; border-radius: 8px; padding: 14px; overflow-x: auto; font-size: .8rem; margin: 0; }

/* Detail drawer */
.ds-drawer { position: fixed; inset: 0; z-index: 200; display: none; }
.ds-drawer[data-open="true"] { display: block; }
.ds-drawer__scrim { position: absolute; inset: 0; background: rgba(10,12,16,.36); }
.ds-drawer__panel { position: absolute; top: 0; right: 0; height: 100%; width: min(560px, 94vw); background: var(--surface); border-left: 1px solid var(--line-2); box-shadow: -12px 0 40px rgba(10,12,16,.14); display: flex; flex-direction: column; }
.ds-drawer__head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.ds-drawer__titles { min-width: 0; flex: 1 1 auto; }
.ds-drawer__head h2 { margin: 0; font-size: 1.05rem; line-height: 1.3; letter-spacing: -0.01em; }
.ds-drawer__idrow { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.ds-id { font-family: var(--font-mono); font-size: .74rem; color: var(--slate-400); background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.ds-copy { font-family: inherit; font-size: .72rem; font-weight: 600; color: var(--slate-500); background: transparent; border: 1px solid var(--line-2); border-radius: 6px; padding: 3px 8px; cursor: pointer; }
.ds-copy:hover { background: var(--surface-2); color: var(--ink-900); }
.ds-drawer__close { flex: none; width: 34px; height: 34px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; cursor: pointer; color: var(--slate-600); display: grid; place-items: center; }
.ds-drawer__close:hover { background: var(--surface-2); color: var(--ink-900); }
.ds-drawer__body { padding: 20px; overflow-y: auto; }
.ds-drawer h4 { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--slate-400); margin: 22px 0 10px; }
.ds-drawer h4:first-child { margin-top: 0; }
.ds-fineprint { font-size: .78rem; color: var(--slate-400); margin: 8px 0 0; }
.ds-raw { margin-top: 6px; }
.ds-raw > summary { font-size: .76rem; color: var(--slate-500); cursor: pointer; list-style: revert; }
.ds-raw > summary:hover { color: var(--ink-900); }
.ds-raw .ds-pre { margin-top: 6px; }
.ds-timeline .t-meta { color: var(--slate-400); font-size: .78rem; margin-top: 3px; }
.ds-timeline .t-reasons { margin: 4px 0 0; padding-left: 1.1em; }
.ds-timeline .t-reasons li { color: var(--slate-600); font-size: .82rem; margin: 1px 0; }
.ds-table td.when { white-space: nowrap; color: var(--slate-600); }

/* Timeline */
.ds-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.ds-timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--line-2); }
.ds-timeline li { position: relative; padding: 0 0 16px 22px; }
.ds-timeline li::before { content: ""; position: absolute; left: 0; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.ds-timeline .t-time { font-family: var(--font-mono); font-size: .75rem; color: var(--slate-400); }
.ds-timeline .t-text { color: var(--ink-700); font-size: .9rem; }
.ds-timeline .t-detail { color: var(--slate-500); font-size: .8rem; font-family: var(--font-mono); margin-top: 2px; word-break: break-word; }

/* Status blocks */
.ds-status { border-radius: 10px; padding: 18px 20px; border: 1px solid var(--line); background: var(--surface); margin: 16px 0; }
.ds-status__title { font-weight: 620; color: var(--ink-900); margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.ds-status__detail { margin: 0; color: var(--slate-500); font-size: .9rem; }
.ds-status--loading .ds-status__title::after { content: ""; width: 13px; height: 13px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: ds-spin .7s linear infinite; }
@keyframes ds-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ds-status--loading .ds-status__title::after { animation: none; } }
.ds-status--empty { background: var(--surface-2); border-style: dashed; }
.ds-status--offline { background: var(--warn-050); border-color: #efe0bd; }
.ds-status--offline .ds-status__title { color: var(--warn-700); }
.ds-status--forbidden, .ds-status--error { background: var(--danger-050); border-color: #eec7c1; }
.ds-status--forbidden .ds-status__title, .ds-status--error .ds-status__title { color: var(--danger-700); }
.ds-status--note { background: var(--accent-050); border-color: var(--accent-100); }
.ds-status--note .ds-status__title { color: var(--info-700); }
.ds-status code { font-size: .8rem; }
