:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-strong: #eef5f2;
  --text: #17211f;
  --muted: #5c6b66;
  --line: #d9e2df;
  --accent: #0b7a75;
  --accent-dark: #075c58;
  --blue: #285d9b;
  --amber: #9a6200;
  --red: #b13b42;
  --green: #147b45;
  --shadow: 0 14px 36px rgba(24, 36, 32, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  display: grid;
  gap: 16px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.topbar {
  min-height: 92px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.05;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

.status-strip,
.actions,
.quick-row,
.panel-title,
.panel-actions,
.split-fields,
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-strip {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  min-height: calc(100vh - 93px);
}

.side-panel {
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #eef2f0;
  display: grid;
  align-content: start;
  gap: 16px;
}

.workspace {
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.tool-panel,
.query-panel,
.results-band {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.tool-panel {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.query-panel,
.results-band {
  padding: 18px;
}

.panel-title {
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel-title.wide {
  align-items: flex-start;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.advanced-settings {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.advanced-settings[open] {
  gap: 12px;
}

.advanced-settings summary {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.advanced-settings label,
.advanced-settings .split-fields,
.advanced-settings .meta-line {
  margin-top: 12px;
}

.profile-admin {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7faf9;
}

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

.profile-actions .secondary-button {
  flex: 1;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--text);
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(11, 122, 117, 0.22);
  outline-offset: 2px;
}

.split-fields {
  align-items: start;
}

.split-fields > * {
  flex: 1;
}

.check-row {
  grid-template-columns: 18px 1fr;
  color: var(--text);
  font-weight: 600;
}

.check-row input {
  min-height: 18px;
}

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

.form-grid label:nth-last-child(2),
.form-grid label:nth-last-child(1) {
  grid-column: span 2;
}

.primary-button,
.secondary-button,
.icon-button,
.quick-row button,
.row-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.quick-row button,
.row-button {
  color: var(--accent-dark);
  background: var(--panel-strong);
  border: 1px solid #c6ddd7;
}

.secondary-button:hover,
.quick-row button:hover,
.row-button:hover {
  background: #ddece8;
}

.danger-button {
  color: #8a242b;
  background: #fff0f1;
  border-color: #f2c4c8;
}

.danger-button:hover {
  background: #ffe2e5;
}

.icon-button {
  color: #ffffff;
  background: #203531;
}

.compact-button {
  min-height: 34px;
  padding: 0 10px;
}

.ghost-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.ghost-link:hover {
  text-decoration: underline;
}

.pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.pill.muted {
  color: var(--muted);
  background: #e7ecea;
}

.pill.ok {
  color: #ffffff;
  background: var(--green);
}

.pill.wait {
  color: #ffffff;
  background: var(--amber);
}

.pill.bad {
  color: #ffffff;
  background: var(--red);
}

.meta-line {
  min-height: 18px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.job-note {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.error-text {
  color: var(--red);
}

.debug-text {
  font-family: Consolas, "Liberation Mono", monospace;
}

.progress-track {
  width: 100%;
  height: 10px;
  margin: 8px 0 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ecea;
}

.progress-bar {
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.progress-bar-indeterminate {
  animation: progress-slide 1.2s ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(300%);
  }
}

.job-progress {
  min-width: 120px;
}

.job-progress .progress-track {
  margin: 4px 0;
}

.link-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.device-list {
  display: grid;
  gap: 8px;
  max-height: 330px;
  overflow: auto;
}

.device-row {
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.device-row:hover,
.device-row.active {
  border-color: var(--accent);
  background: var(--panel-strong);
}

.device-name {
  display: block;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.file-name {
  display: block;
  max-width: 520px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.device-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.calendar-day {
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-day.has-video {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.calendar-day.blank {
  visibility: hidden;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f7faf9;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  font-size: 14px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.record-downloaded td {
  background: #f1faf5;
}

.empty-state {
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.token-output {
  min-height: 76px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1917;
  color: #eaf5f1;
  overflow: auto;
}

.notice {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 15px;
  border-radius: 8px;
  background: #17211f;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.notice.show {
  opacity: 1;
  transform: translateY(0);
}

.notice.error {
  background: var(--red);
}

.notice.ok {
  background: var(--green);
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }

  .side-panel .tool-panel:first-child {
    grid-column: 1 / -1;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar,
  .panel-title.wide,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .side-panel,
  .workspace {
    padding: 12px;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

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

  .form-grid label:nth-last-child(2),
  .form-grid label:nth-last-child(1) {
    grid-column: auto;
  }

  .quick-row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .quick-row button {
    flex: 1 1 92px;
  }
}
