:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #15202b;
  --muted: #5f6b7a;
  --line: #d8e0e7;
  --blue: #1167b1;
  --blue-strong: #0b4f8a;
  --green: #16803c;
  --amber: #946200;
  --red: #b42318;
  --shadow: 0 8px 24px rgba(21, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  background: var(--blue-strong);
}

button.secondary {
  background: #e8eef4;
  color: var(--text);
}

button.danger {
  background: var(--red);
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar h1,
.panel h2 {
  margin: 0;
}

.topbar p,
.panel p,
#order-meta {
  margin: 4px 0 0;
  color: var(--muted);
}

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

.hidden {
  display: none !important;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 22px;
}

.login-form,
.import-form,
.scan-form {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}

.login-form label {
  flex: 1;
  color: var(--muted);
  font-weight: 700;
}

.import-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.import-form {
  min-width: min(360px, 100%);
  margin-top: 0;
}

.sync-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px;
}

.orders-list,
.items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.order-card,
.item-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.order-card {
  text-align: left;
  color: var(--text);
  background: #fff;
  width: 100%;
  min-height: 0;
  font-weight: 400;
}

.order-card:hover,
.order-card.active {
  border-color: var(--blue);
  background: #eef6ff;
}

.order-card strong,
.item-card strong {
  display: block;
  margin-bottom: 4px;
}

.order-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 14px;
}

.progress-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e8eef4;
  color: var(--text);
  font-weight: 700;
  min-height: 30px;
  padding: 0 10px;
  white-space: nowrap;
}

.status-badge.done {
  background: #dcf7e5;
  color: var(--green);
}

.status-badge.partial {
  background: #fff4d6;
  color: var(--amber);
}

.status-badge.problem {
  background: #ffe7e4;
  color: var(--red);
}

.scan-form {
  margin: 0 0 12px;
}

.scan-form input {
  font-size: 20px;
  font-weight: 700;
}

.scan-message {
  min-height: 24px;
  color: var(--muted);
  font-weight: 700;
}

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

.scan-message.ok {
  color: var(--green);
}

.item-card {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.item-photo {
  width: 88px;
  height: 88px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  object-fit: cover;
}

.item-photo-placeholder {
  width: 88px;
  height: 88px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 12px;
  padding: 8px;
}

.item-meta {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.item-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(42px, auto));
  gap: 8px;
}

.empty-state {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .app {
    padding: 12px;
  }

  .import-panel,
  .sync-actions,
  .login-form,
  .import-form,
  .scan-form,
  .order-heading {
    flex-direction: column;
    align-items: stretch;
  }

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

  .item-card {
    grid-template-columns: 1fr;
  }

  .item-photo,
  .item-photo-placeholder {
    width: 100%;
    max-width: 220px;
    height: 180px;
  }
}
