:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --primary: #1e6fd9;
  --primary-dark: #1558ad;
  --text: #1a2332;
  --muted: #5c6b7a;
  --danger: #c0392b;
  --border: #d8dee8;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(26, 35, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

.screen.hidden,
.hidden {
  display: none !important;
}

.hero {
  text-align: center;
  margin: 24px 0 32px;
}

.hero h1 {
  margin: 0;
  font-size: 2rem;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.topbar-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.topbar-value {
  margin: 4px 0 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.field-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.1rem;
  background: var(--surface);
}

.field-input:focus {
  outline: none;
  border-color: var(--primary);
}

.pin-display {
  margin: 24px auto 16px;
  width: 180px;
  text-align: center;
  font-size: 2rem;
  letter-spacing: 0.35em;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.keypad button {
  padding: 18px 0;
  font-size: 1.4rem;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.keypad button:active {
  transform: scale(0.97);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: #e8eef7;
  color: var(--text);
  white-space: nowrap;
}

.btn-block {
  width: 100%;
  margin-bottom: 16px;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-row .field-input {
  margin-bottom: 0;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  padding: 8px 10px;
}

.btn-sm {
  font-size: 0.9rem;
}

.error {
  color: var(--danger);
  margin: 12px 0;
}

.info {
  color: var(--primary);
  margin: 12px 0;
  font-weight: 600;
}

.success {
  color: #2e7d32;
  margin: 12px 0;
  font-weight: 600;
}

.status {
  text-align: center;
  color: var(--muted);
  margin: 12px 0 20px;
}

.card-list {
  display: grid;
  gap: 12px;
}

.order-card {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.order-card:active {
  border-color: var(--primary);
}

.order-card strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.order-card span {
  color: var(--muted);
  font-size: 0.95rem;
}

.operation-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.mode-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 10px;
  font-size: 0.95rem;
  font-weight: 700;
}

.mode-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.scanner-wrap {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 320px;
  margin-bottom: 12px;
  position: relative;
}

#scanner-video {
  display: block;
  width: 100%;
  min-height: 320px;
  max-height: 420px;
  object-fit: contain;
  background: #000;
}

.scanner-wrap--starting #scanner-video {
  visibility: hidden;
}

.scanner-wrap--starting {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.95rem;
}

#scanner-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 16px;
  text-align: center;
  z-index: 2;
  pointer-events: none;
}

.manual-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}

.btn-finish {
  width: 100%;
  background: #2e7d32;
  color: #fff;
  margin-bottom: 12px;
}

.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.recent-list li {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid transparent;
}

.recent-list li.session-entry-withdraw {
  background: #e9f7ef;
  border-color: #27ae60;
  color: #1e5631;
}

.recent-list li.session-entry-withdraw .recent-qty {
  color: #1e8449;
}

.recent-list li.session-entry-return {
  background: #fdeeee;
  border-color: #e74c3c;
  color: #7b241c;
}

.recent-list li.session-entry-return .recent-qty {
  color: #c0392b;
}

.recent-list li.session-entry-withdraw small,
.recent-list li.session-entry-return small {
  color: inherit;
  opacity: 0.85;
}

.recent-list li.session-entry-withdraw,
.recent-list li.session-entry-return {
  align-items: center;
}

.recent-main {
  min-width: 0;
}

.recent-qty {
  font-weight: 700;
  white-space: nowrap;
  text-align: right;
  flex-shrink: 0;
}

.recent-list small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.recent-list li.work-time-session-entry {
  align-items: center;
}

.session-entry-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-session-remove {
  width: 32px;
  height: 32px;
  border: 1px solid #e74c3c;
  border-radius: 8px;
  background: #fff;
  color: #c0392b;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.btn-session-remove:active {
  background: #fdeeee;
}

.quantity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.quantity-label {
  font-weight: 600;
  color: var(--muted);
}

.quantity-field {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.quantity-unit {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  min-width: 2.5rem;
}

.quantity-input {
  width: 110px;
  font-size: 1.6rem;
  text-align: right;
  margin-bottom: 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 20px 20px 14px 14px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-header-text {
  min-width: 0;
  flex: 1;
}

.modal-header h2 {
  margin-bottom: 8px;
}

.modal-product-image {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f3f6fa;
  flex-shrink: 0;
}

.modal-product-image.hidden {
  display: none;
}

.modal-product {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.modal-index {
  color: var(--muted);
  margin: 0;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.modal-actions-single {
  grid-template-columns: 1fr;
}

.modal-message {
  margin: 0 0 8px;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--text);
}

h2, h3 {
  margin: 0 0 14px;
}

h3 {
  font-size: 1rem;
  color: var(--muted);
}

.hub-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.hub-tile {
  text-align: left;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.hub-tile:active,
.hub-tile:focus-visible {
  border-color: var(--primary);
}

.hub-tile-title {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.hub-tile-desc {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.35;
}

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.category-tile {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 12px;
  min-height: 64px;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
}

.category-tile.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.section-hint {
  margin: 0 0 12px;
  font-size: 0.92rem;
  color: var(--muted);
}

#my-work-hours-summary h3 {
  margin-top: 24px;
}

.work-hours-grid {
  display: grid;
  gap: 12px;
}

.work-hours-tile {
  width: 100%;
  text-align: left;
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  cursor: pointer;
  font: inherit;
}

.work-hours-tile-ok {
  background: #e9f7ef;
  border-color: #27ae60;
  color: #1e5631;
}

.work-hours-tile-low {
  background: #fdeeee;
  border-color: #e74c3c;
  color: #7b241c;
}

.work-hours-date {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 6px;
}

.work-hours-total {
  display: block;
  font-size: 0.92rem;
  opacity: 0.9;
}

.order-card,
.hub-tile,
.category-tile,
.mode-btn,
.work-hours-tile,
.btn-secondary.btn-block,
.keypad button,
.recent-list li {
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
  .order-card:hover {
    border-color: var(--primary);
    box-shadow: 0 12px 28px rgba(30, 111, 217, 0.2);
    transform: translateY(-2px);
  }

  .hub-tile:hover {
    border-color: var(--primary);
    box-shadow: 0 12px 28px rgba(30, 111, 217, 0.2);
    transform: translateY(-2px);
  }

  .category-tile:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 20px rgba(30, 111, 217, 0.15);
  }

  .category-tile.active:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
  }

  .mode-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 20px rgba(30, 111, 217, 0.15);
  }

  .mode-btn.active:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
  }

  .work-hours-tile-ok:hover {
    border-color: #1e8449;
    box-shadow: 0 10px 24px rgba(39, 174, 96, 0.22);
    transform: translateY(-2px);
  }

  .work-hours-tile-low:hover {
    border-color: #c0392b;
    box-shadow: 0 10px 24px rgba(231, 76, 60, 0.2);
    transform: translateY(-2px);
  }

  .btn-secondary.btn-block:hover {
    background: #d6e4f7;
    box-shadow: 0 10px 24px rgba(30, 111, 217, 0.14);
    transform: translateY(-1px);
  }

  .btn-secondary:not(.btn-block):hover {
    background: #d6e4f7;
  }

  .keypad button:hover {
    border: 2px solid var(--primary);
    box-shadow: 0 8px 20px rgba(30, 111, 217, 0.15);
  }

  .recent-list li:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(26, 35, 50, 0.12);
  }

  .recent-list li.session-entry-withdraw:hover {
    border-color: #1e8449;
    box-shadow: 0 10px 24px rgba(39, 174, 96, 0.22);
  }

  .recent-list li.session-entry-return:hover {
    border-color: #c0392b;
    box-shadow: 0 10px 24px rgba(231, 76, 60, 0.2);
  }

  .recent-list li.work-time-session-entry:hover {
    border-color: var(--primary);
  }

  .btn-session-remove:hover {
    background: #fdeeee;
    border-color: #c0392b;
    transform: scale(1.05);
  }

  .btn-ghost:hover {
    background: #e8eef7;
  }

  .btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
  }
}
