:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #20262b;
  background: #f4f5f6;
  --ink: #20262b;
  --muted: #6b747b;
  --line: #e1e4e6;
  --panel: #fff;
  --soft: #f7f8f8;
  --brand: #176b63;
  --brand-soft: #e9f3f1;
  --danger: #a83c3c;
  --sidebar: 232px;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f4f5f6; }
a { color: var(--brand); text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

header {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar);
  padding: 22px 14px 16px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 20px; color: var(--ink); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #183d39;
  color: #fff;
  font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.nav-toggle { display: none; }
nav { display: flex; flex: 1; flex-direction: column; gap: 22px; }
.nav-group { display: grid; gap: 3px; }
.nav-group small {
  margin: 0 10px 6px;
  color: #98a0a5;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
nav a {
  padding: 9px 10px;
  border-radius: 8px;
  color: #59636a;
  font-size: 13px;
  font-weight: 650;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
nav a:hover { color: var(--ink); background: var(--soft); transform: translateX(2px); }
nav a.active { color: #164e48; background: var(--brand-soft); }
.nav-logout { margin-top: auto; }
.nav-logout button {
  width: 100%;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #646d73;
  background: #fff;
  font-weight: 650;
}

main { margin-left: var(--sidebar); padding: 28px clamp(18px, 3vw, 42px) 42px; }
.signed-out header { position: static; width: auto; height: 70px; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); }
.signed-out main { margin-left: 0; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  max-width: 1500px;
  margin: 0 auto 20px;
}
.page-head h1 { margin: 2px 0 4px; font-size: 28px; letter-spacing: -.035em; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }
.eyebrow { color: var(--brand) !important; font-size: 10px !important; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}
.sync-state i, .status-dot { width: 7px; height: 7px; border-radius: 50%; background: #a9b0b4; }
.sync-state i, .status-dot.online { background: #3e9d72; box-shadow: 0 0 0 4px rgba(62,157,114,.12); }

button, input, select {
  min-height: 36px;
  border: 1px solid #d7dcde;
  border-radius: 8px;
  padding: 8px 11px;
  background: #fff;
  color: var(--ink);
}
button { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; transition: transform .15s ease, opacity .15s ease; }
button:hover { transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: default; transform: none; }
button.danger { background: var(--danger); border-color: var(--danger); }
input:focus, select:focus { outline: 3px solid rgba(23,107,99,.12); border-color: #79a9a4; }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 1500px;
  margin: 0 auto 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
}
.stats-strip article, .stats-strip a { padding: 13px 16px; border-right: 1px solid var(--line); color: var(--ink); }
.stats-strip > :last-child { border-right: 0; }
.stats-strip span, .stats-strip strong { display: block; }
.stats-strip span { margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.stats-strip strong { font-size: 17px; letter-spacing: -.02em; }

.workspace {
  display: grid;
  grid-template-columns: minmax(210px, 280px) minmax(0, 1fr);
  max-width: 1500px;
  height: calc(100vh - 210px);
  min-height: 520px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.folder-pane { display: flex; min-width: 0; flex-direction: column; border-right: 1px solid var(--line); background: #fafbfb; }
.file-pane { display: flex; min-width: 0; flex-direction: column; }
.pane-head {
  min-height: 63px;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.pane-head h2 { margin: 0; font-size: 14px; letter-spacing: -.01em; }
.pane-head span { color: var(--muted); font-size: 11px; }
.icon-button { min-height: 29px; padding: 5px 9px; border-color: var(--line); background: #fff; color: #5c666c; font-size: 11px; }
.icon-button.selected { color: #fff; border-color: var(--brand); background: var(--brand); }
.pane-search { min-height: 34px; margin: 10px; background: #fff; font-size: 12px; }
.folder-list { min-height: 0; overflow-y: auto; padding: 0 6px 10px; }
.folder-row {
  width: 100%;
  min-height: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 500;
}
.folder-row:hover, .folder-row.selected { transform: none; background: #edf2f1; }
.folder-row.selected { color: #164e48; }
.folder-icon { position: relative; flex: 0 0 auto; width: 15px; height: 11px; border-radius: 2px; background: #b8c7c4; }
.folder-icon::before { content: ""; position: absolute; top: -3px; left: 1px; width: 7px; height: 4px; border-radius: 2px 2px 0 0; background: inherit; }
.folder-name { min-width: 0; }
.folder-name strong, .folder-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-name strong { font-size: 12px; font-weight: 650; }
.folder-name small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.file-pane-head { flex-wrap: wrap; }
.file-tools { display: flex; gap: 7px; }
.file-tools input { width: min(260px, 25vw); }
.file-tools input, .file-tools select { min-height: 34px; font-size: 12px; }
.file-table-head, .file-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 90px 150px 72px;
  gap: 12px;
  align-items: center;
}
.file-table-head {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  color: #8a9297;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
#file-list { min-height: 0; flex: 1; overflow-y: auto; }
.file-row { min-height: 48px; padding: 7px 14px; border-bottom: 1px solid #eef0f1; transition: background .12s ease; }
.file-row:hover { background: #f8faf9; }
.file-path { min-width: 0; overflow: hidden; color: #30383d; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.file-size, .file-time { color: var(--muted); font-size: 11px; }
.file-row button { min-height: 29px; padding: 5px 8px; border-color: var(--line); background: #fff; color: #53625f; font-size: 11px; }
.pager { min-height: 48px; display: flex; justify-content: center; align-items: center; gap: 12px; border-top: 1px solid var(--line); }
.pager button { min-height: 29px; padding: 5px 9px; border-color: var(--line); background: #fff; color: #53625f; font-size: 11px; }
.pager span { min-width: 110px; color: var(--muted); font-size: 11px; text-align: center; }
.empty { padding: 20px; color: var(--muted); font-size: 12px; text-align: center; }

.devices-panel, .card, .hero {
  max-width: 1500px;
  margin: 16px auto 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.devices-panel summary { padding: 13px 15px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; list-style: none; }
.devices-panel summary::-webkit-details-marker { display: none; }
.devices-panel summary strong, .devices-panel summary small { display: block; }
.devices-panel summary strong { font-size: 13px; }
.devices-panel summary small, .devices-panel summary > span:last-child { margin-top: 2px; color: var(--muted); font-size: 11px; }
.device-list { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.device-row { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 13px 15px; border-right: 1px solid var(--line); }
.device-row strong, .device-row span { display: block; }
.device-row strong { font-size: 12px; }
.device-row div span, .device-row time { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.preview-modal { position: fixed; inset: 0; z-index: 100; padding: 5vh 5vw; display: grid; place-items: center; background: rgba(28,34,37,.56); backdrop-filter: blur(4px); }
.preview-dialog { width: min(1000px, 100%); max-height: 90vh; overflow: auto; border-radius: 12px; background: #fff; box-shadow: 0 24px 80px rgba(0,0,0,.22); }
#preview-content { padding: 18px; }
#preview-content img, #preview-content iframe { max-width: 100%; max-height: 70vh; }
#preview-content iframe { width: 100%; height: 70vh; border: 0; }
#preview-content pre { margin: 0; padding: 15px; overflow: auto; border-radius: 8px; background: #f5f6f6; white-space: pre-wrap; }
.hidden { display: none !important; }

.card, .hero { padding: 20px; }
.card { max-height: 78vh; overflow: auto; }
.card h1, .hero h1 { margin: 0 0 8px; font-size: 24px; }
.card h2 { margin-top: 24px; font-size: 17px; }
.card p, .card li, .hero p { color: var(--muted); font-size: 13px; line-height: 1.65; }
.card > table { max-height: 62vh; }
.narrow { max-width: 430px; margin: 10vh auto; }
.toolbar, .inline { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
form { display: grid; gap: 11px; }
label { display: grid; gap: 5px; font-size: 12px; font-weight: 700; }
.token { display: block; padding: 11px; overflow-wrap: anywhere; border-radius: 8px; background: #f1f4f3; font-size: 12px; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 10px; border-bottom: 1px solid #edf0f1; text-align: left; vertical-align: top; }
.conflict-card { padding: 15px 0; border-bottom: 1px solid var(--line); }
.conflict-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.conflict-grid > div { padding: 13px; border-radius: 8px; background: var(--soft); }

@media (max-width: 1000px) {
  :root { --sidebar: 205px; }
  .stats-strip { grid-template-columns: repeat(3, 1fr); }
  .stats-strip > :nth-child(3) { border-right: 0; }
  .workspace { grid-template-columns: 220px minmax(0, 1fr); }
  .file-table-head, .file-row { grid-template-columns: minmax(180px,1fr) 70px 72px; }
  .file-table-head span:nth-child(3), .file-time { display: none; }
}

@media (max-width: 760px) {
  header { inset: 0 0 auto 0; width: auto; height: 62px; padding: 12px 14px; flex-direction: row; align-items: center; justify-content: space-between; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .brand small { display: none; }
  .nav-toggle { display: block; min-height: 32px; padding: 5px 9px; border-color: var(--line); background: #fff; color: var(--ink); }
  nav { position: fixed; inset: 62px 0 auto; display: none; max-height: calc(100vh - 62px); padding: 14px; overflow-y: auto; border-bottom: 1px solid var(--line); background: #fff; box-shadow: 0 14px 30px rgba(20,30,34,.12); }
  nav.open { display: flex; }
  main { margin: 62px 0 0; padding: 18px 12px 28px; }
  .page-head { align-items: start; flex-direction: column; }
  .head-actions { width: 100%; justify-content: space-between; }
  .stats-strip { display: flex; overflow-x: auto; }
  .stats-strip article, .stats-strip a { min-width: 105px; }
  .workspace { display: block; height: auto; min-height: 0; overflow: visible; border: 0; background: transparent; }
  .folder-pane, .file-pane { margin-bottom: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
  .folder-pane { height: 245px; }
  .file-pane { height: 68vh; min-height: 480px; }
  .file-pane-head { align-items: start; flex-direction: column; }
  .file-tools, .file-tools input { width: 100%; }
  .file-tools input { min-width: 0; }
  .file-table-head, .file-row { grid-template-columns: minmax(130px,1fr) 60px 64px; gap: 7px; }
  .file-table-head, .file-row { padding-left: 10px; padding-right: 10px; }
  .device-list { grid-template-columns: 1fr; }
  .conflict-grid { grid-template-columns: 1fr; }
}

/* Landing page */
.landing { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

.hero-section {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 60px;
  align-items: center;
  padding: 80px 0 70px;
}
.hero-text h1 {
  margin: 0 0 20px;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.1;
  color: var(--ink);
}
.hero-sub {
  margin: 0 0 36px;
  max-width: 480px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}
.hero-features { display: grid; gap: 16px; }
.feat {
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
}
.feat strong { display: block; margin-bottom: 3px; font-size: 13px; color: var(--ink); }
.feat span { color: var(--muted); font-size: 12px; line-height: 1.5; }

.hero-login { display: flex; align-items: flex-start; justify-content: flex-end; }
.login-box {
  width: 100%;
  max-width: 340px;
  padding: 32px 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 40px rgba(20,30,34,.06);
}
.login-box h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.02em; }
.login-box p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

.features-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 0 0 70px;
}
.fs-item {
  padding: 20px 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}
.fs-item strong { display: block; margin-bottom: 6px; font-size: 13px; color: var(--ink); }
.fs-item span { color: var(--muted); font-size: 12px; line-height: 1.6; }

.how-section { padding: 0 0 80px; }
.how-section h2 { margin: 0 0 28px; font-size: 22px; letter-spacing: -.03em; }
.how-steps { display: grid; gap: 20px; }
.step {
  display: flex;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}
.step-n {
  flex: 0 0 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #183d39;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}
.step strong { display: block; margin-bottom: 4px; font-size: 14px; color: var(--ink); }
.step p { margin: 0 0 8px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.step .token { margin-top: 8px; font-size: 11px; padding: 9px 12px; }

.landing-footer {
  padding: 24px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.signed-out .landing { padding-top: 10px; }

@media (max-width: 900px) {
  .hero-section { grid-template-columns: 1fr; gap: 40px; padding: 50px 0 50px; }
  .hero-login { justify-content: flex-start; }
  .login-box { max-width: 100%; }
  .features-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .features-strip { grid-template-columns: 1fr; }
  .hero-text h1 { font-size: 28px; }
}
