/* IronDesk shell styles (T07). Plain CSS, same-origin only.
   No inline styles exist in templates; this file is the single
   style source (CSP style-src 'self'). */

:root {
  color-scheme: light dark;
  --fg: #1c2430;
  --fg-muted: #55606e;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --line: #d5dbe3;
  --accent: #1c5fae;
  --accent-contrast: #ffffff;
  --danger: #a02121;
  --focus: #0a66d0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6ebf2;
    --fg-muted: #a5aeb9;
    --bg: #14181f;
    --surface: #1d232c;
    --line: #37404c;
    --accent: #7db1ee;
    --accent-contrast: #0d1420;
    --danger: #f08c8c;
    --focus: #9ec8ff;
  }
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

/* Keyboard accessibility: one highly visible focus ring for EVERY
   interactive element; :focus-visible keeps mouse clicks clean. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Skip link: hidden until focused, then first in tab order. */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--surface);
  color: var(--fg);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { margin: 0; font-weight: 700; }

.nav-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0;
}

.nav-list a {
  color: var(--accent);
  text-decoration: none;
  padding: 0.25rem 0.1rem;
}
.nav-list a[aria-current="page"] {
  color: var(--fg);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}

.user-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.user-name { margin: 0; color: var(--fg-muted); }

.site-main {
  flex: 1;
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
}
.site-main:focus { outline: none; }

.site-footer {
  padding: 0.75rem 1rem;
  color: var(--fg-muted);
  border-top: 1px solid var(--line);
}

/* Forms: stacked, labeled, comfortable hit targets. */
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: 0.25rem; font-weight: 600; }

input[type="text"],
input[type="password"] {
  width: 100%;
  max-width: 24rem;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  font: inherit;
  border-radius: 4px;
  border: 1px solid var(--accent);
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-secondary {
  background: transparent;
  color: var(--accent);
}

.alert {
  padding: 0.6rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  max-width: 34rem;
}
.alert-error { border-color: var(--danger); color: var(--danger); }
.alert-info { color: var(--fg-muted); }

.login-main { max-width: 24rem; }

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 4px;
  padding: 1rem;
  color: var(--fg-muted);
  background: var(--surface);
}

/* T12 devices surfaces: stale-data badge and the copy-ID input. */
.stale-badge {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--danger);
  color: var(--danger);
  font-weight: 600;
}

.copy-id-input {
  max-width: 16rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Visually hidden but screen-reader available (copy-ID label). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.device-facts {
  display: grid;
  grid-template-columns: minmax(8rem, auto) 1fr;
  gap: 0.4rem 1rem;
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.device-facts dt { font-weight: 600; color: var(--fg-muted); }
.device-facts dd { margin: 0; overflow-wrap: anywhere; }

.device-notes { white-space: pre-wrap; }

.device-search {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.device-search .field { margin-bottom: 0; flex: 1 1 14rem; }

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
  align-items: center;
}
.device-delete { display: inline-block; }

.id-note { color: var(--fg-muted); font-size: 0.9rem; }

.loading-note { color: var(--fg-muted); }
.loading-indicator { font-style: italic; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
}
.data-table caption { text-align: left; padding: 0.5rem 0; color: var(--fg-muted); }
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.data-table thead th { background: var(--bg); }

/* Narrow viewports: content reflows, nothing is lost at 320px.
   The navigation wraps; tables scroll horizontally instead of
   clipping; no horizontal page overflow. */
@media (max-width: 480px) {
  .site-header { padding: 0.5rem; }
  .user-box { margin-left: 0; }
  .site-main { padding: 0.75rem; }
}

@media (max-width: 320px) {
  html { font-size: 15px; }
  .nav-list { flex-direction: column; gap: 0.25rem; }
  .data-table { display: block; overflow-x: auto; }
  .btn { width: 100%; }
  input[type="text"],
  input[type="password"] { max-width: 100%; }
}
