/**
 * Styles the local synchronization interface with the original high-contrast green operational layout.
 * The responsive rules preserve readable controls, keyboard focus, and reduced-motion preferences.
 */

:root {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182126;
  background: #edf0ec;
  font-synthesis: none;
  --ink: #182126;
  --muted: #647076;
  --paper: #fbfcf9;
  --line: #cbd2ce;
  --green: #006a55;
  --green-dark: #004b3d;
  --lime: #d7f352;
  --red: #a32b36;
  --scroll-track: #d8dfdb;
  --scroll-thumb: #006a55;
  --panel-offset: 8px;
}

* { box-sizing: border-box; }
main, .panel, form, label, input, button, .form-grid, .credential-form, .credential-footer, .credential-buttons, .schedule-row, .table-scroll { min-width: 0; }
[hidden] { display: none !important; }
html, .table-scroll { scrollbar-color: var(--scroll-thumb) var(--scroll-track); scrollbar-width: auto; }
html { scrollbar-gutter: stable; }
html::-webkit-scrollbar, .table-scroll::-webkit-scrollbar { width: 16px; height: 16px; }
html::-webkit-scrollbar-track, .table-scroll::-webkit-scrollbar-track { background: var(--scroll-track); }
html::-webkit-scrollbar-thumb, .table-scroll::-webkit-scrollbar-thumb { border: 4px solid var(--scroll-track); background: var(--scroll-thumb); }
html::-webkit-scrollbar-thumb:hover, .table-scroll::-webkit-scrollbar-thumb:hover { background: var(--green-dark); }
html::-webkit-scrollbar-corner, .table-scroll::-webkit-scrollbar-corner { background: var(--scroll-track); }
body { margin: 0; min-height: 100vh; background: linear-gradient(90deg, rgba(24, 33, 38, 0.035) 1px, transparent 1px) 0 0 / 32px 32px, #edf0ec; }
.site-header { width: min(1120px, calc(100% - 32px)); margin-inline: auto; }
.site-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 56px 0 32px; border-bottom: 3px solid var(--ink); }
.site-header > div:first-child { min-width: 0; }
.eyebrow, .step { margin: 0 0 8px; color: var(--green); font: 800 0.75rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.12em; }
h1, h2 { margin: 0; letter-spacing: -0.035em; }
h1 { max-width: 800px; overflow-wrap: anywhere; font-size: clamp(2.25rem, 7vw, 4.8rem); line-height: 0.95; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
main { width: min(1160px, 100%); margin-inline: auto; padding: 28px 16px 56px; }
.panel { width: calc(100% - var(--panel-offset)); margin: 22px 0; padding: clamp(20px, 4vw, 34px); border: 1px solid var(--ink); background: var(--paper); box-shadow: var(--panel-offset) var(--panel-offset) 0 rgba(24, 33, 38, 0.12); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 24px; }
.section-heading > p { max-width: 470px; margin: 0; color: var(--muted); text-align: right; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.credential-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.credential-footer { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 4px; }
.credential-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }
.form-message { min-height: 1.4em; margin: 14px 0 0; color: var(--green); font-weight: 750; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 52px; }
.icon-button { position: absolute; top: 1px; right: 1px; width: 44px; min-height: 42px; padding: 0; color: var(--ink); border: 0; background: transparent; font-size: 1.15rem; }
.password-icon { position: relative; display: inline-block; width: 20px; height: 14px; border: 2px solid currentColor; border-radius: 70% 15%; transform: rotate(45deg); }
.password-icon::after { position: absolute; top: 50%; left: 50%; width: 5px; height: 5px; border: 2px solid currentColor; border-radius: 50%; content: ""; transform: translate(-50%, -50%); }
.icon-button::after { position: absolute; top: 20px; left: 10px; width: 25px; height: 2px; background: currentColor; content: ""; transform: rotate(-45deg); }
.icon-button[aria-pressed="true"]::after { display: none; }
.icon-button:hover { background: rgba(0, 106, 85, 0.1); }
.remember-switch { position: relative; display: inline-flex; align-items: center; gap: 14px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); background: #eef3ef; cursor: default; font-size: 0.9rem; letter-spacing: 0; }
.switch-control { position: relative; display: block; width: 46px; height: 26px; margin-left: auto; cursor: pointer; }
.switch-control input { position: absolute; width: 1px; min-height: 1px; opacity: 0; }
.switch-track { position: relative; display: block; width: 46px; height: 26px; border: 1px solid var(--ink); background: var(--muted); }
.switch-track::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; content: ""; transition: transform 120ms ease; }
.remember-switch input:checked + .switch-track { background: var(--green); }
.remember-switch input:checked + .switch-track::after { transform: translateX(20px); }
.remember-switch input:focus-visible + .switch-track { outline: 3px solid #5f7cff; outline-offset: 3px; }
label { display: grid; gap: 7px; color: #364147; font-size: 0.82rem; font-weight: 750; letter-spacing: 0.02em; }
input, button { min-height: 44px; border: 1px solid var(--ink); border-radius: 0; font: inherit; }
input { width: 100%; padding: 10px 12px; color: var(--ink); background: #fff; }
input:focus-visible, button:focus-visible { outline: 3px solid #5f7cff; outline-offset: 3px; }
button { max-width: 100%; cursor: pointer; padding: 10px 18px; color: #fff; background: var(--green); font-weight: 800; white-space: normal; }
button:hover { background: var(--green-dark); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button.secondary { color: var(--ink); background: var(--lime); }
button.secondary:hover { background: #c8e348; }
button.danger { background: var(--red); }
button.text-button { min-height: auto; padding: 6px 0; color: var(--green); border: 0; background: transparent; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
progress { width: 100%; height: 14px; accent-color: var(--green); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 18px; }
.summary-item { padding: 14px; border-left: 4px solid var(--green); background: #eef3ef; }
.summary-item strong { display: block; margin-top: 5px; font-size: 1.2rem; }
.error-message { min-height: 1.4em; margin: 16px 0 0; color: var(--red); font-weight: 700; }
.schedule-row { display: grid; grid-template-columns: minmax(220px, 1fr) 180px auto minmax(150px, 1fr); align-items: end; gap: 16px; }
.checkbox-label { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.checkbox-label input { width: 20px; min-height: 20px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; table-layout: fixed; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
th:nth-child(1), td:nth-child(1) { width: 22%; }
th:nth-child(2), td:nth-child(2) { width: 10%; }
th:nth-child(3), td:nth-child(3) { width: 22%; }
th:nth-child(4), td:nth-child(4) { width: 32%; }
th:nth-child(5), td:nth-child(5) { width: 14%; }
th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
td button { width: 100%; max-width: 100%; min-height: 34px; padding: 6px; }
/* Keeps empty and unavailable Recent runs states visible inside the existing table and narrow-card layouts. */
.history-message { color: var(--muted); text-align: center; }

@media (max-width: 1000px) {
  .schedule-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .schedule-row > button { width: 100%; }
  .schedule-row > [role="status"] { align-self: center; }
}

@media (max-width: 820px) {
  .site-header, .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading > p { text-align: left; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .credential-footer { align-items: stretch; flex-direction: column; }
  .credential-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .credential-buttons button { width: 100%; }
}

@media (max-width: 620px) {
  .credential-form { grid-template-columns: 1fr; }
  .table-scroll { overflow: visible; }
  .table-scroll table, .table-scroll tbody { display: block; }
  .table-scroll thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .table-scroll tbody { display: grid; gap: 14px; }
  .table-scroll tbody tr { display: grid; gap: 0; padding: 12px; border: 1px solid var(--line); }
  .table-scroll tbody td { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 12px; width: 100%; padding: 7px 0; border: 0; }
  .table-scroll tbody td::before { color: var(--muted); content: attr(data-label); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
  .table-scroll tbody td button { width: auto; justify-self: start; }
}

@media (max-width: 520px) {
  .site-header { width: min(100% - 20px, 1120px); }
  .site-header { padding-top: 30px; }
  main { width: 100%; padding: 28px 10px 56px; }
  .form-grid, .schedule-row { grid-template-columns: 1fr; }
  .credential-buttons { display: grid; grid-template-columns: 1fr; }
  .actions button { width: 100%; }
  .schedule-row > [role="status"] { min-height: 1.4em; }
}

@media (max-width: 360px) {
  .site-header { width: min(100% - 16px, 1120px); }
  main { padding-inline: 8px; }
  .panel { padding-inline: 16px; }
  .remember-switch { gap: 10px; padding-inline: 10px; }
  .table-scroll tbody td { grid-template-columns: 72px minmax(0, 1fr); gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media (prefers-color-scheme: dark) {
  :root { color: #eef3ef; background: #151b1d; --ink: #eef3ef; --muted: #aeb9b5; --paper: #20282a; --line: #445052; --scroll-track: #20282a; --scroll-thumb: #008b70; }
  body { background: #151b1d; }
  input { color: #eef3ef; background: #151b1d; }
  label { color: #d8dfdc; }
  .remember-switch { background: #273331; }
  button.secondary { color: #182126; border-color: #eef3ef; box-shadow: 4px 4px 0 #eef3ef; }
  .panel { box-shadow: var(--panel-offset) var(--panel-offset) 0 rgba(255, 255, 255, 0.08); }
  .summary-item { background: #273331; }
}
