/* Basic readable styling */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  margin: 0;
  padding: 0;
  background: #f5f6f7;
  color: #333;
}

#app {
  max-width: 960px;
  margin: 40px auto;
  padding: 24px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

@media (max-width: 640px) {
  #app {
    margin: 0 auto;
    padding: 16px;
    border-radius: 0;
    box-shadow: none;
  }

  body {
    background: #fff;
  }
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 16px;
}

.hidden {
  display: none !important;
}

.error {
  color: #c00;
  font-size: 0.9rem;
  min-height: 1.2em;
}

form, .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

label {
  font-weight: 500;
}

input[type="password"],
input[type="date"],
input[type="text"] {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}

input[type="text"] {
  min-width: 160px;
}

@media (max-width: 480px) {
  input[type="date"],
  input[type="text"] {
    min-width: 0;
    flex: 1;
  }

  form, .controls {
    gap: 8px;
  }
}

button {
  padding: 8px 14px;
  border: 1px solid #1677ff;
  background: #1677ff;
  color: #fff;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
}

button:hover {
  background: #0958d9;
}

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

#logout-btn {
  background: #fff;
  color: #1677ff;
}

#logout-btn:hover {
  background: #e6f4ff;
}

#results, #summary {
  margin-top: 16px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.summary-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.summary-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: #222;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed #eee;
  font-size: 0.95rem;
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-total {
  font-weight: 600;
  color: #1677ff;
}

@media (max-width: 480px) {
  .summary-cards {
    grid-template-columns: 1fr;
  }

  .details-table {
    font-size: 0.82rem;
  }

  .details-table th,
  .details-table td {
    padding: 7px 8px;
  }
}

.empty-state {
  text-align: center;
  color: #888;
  padding: 24px 0;
  font-size: 1rem;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

.details-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.details-table thead tr {
  background: #f0f2f5;
}

.details-table th,
.details-table td {
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
}

.details-table th {
  text-align: center;
}

.details-table td {
  text-align: center;
}

.details-table th {
  font-weight: 600;
  color: #222;
}

.details-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.details-table tbody tr:hover {
  background: #f5faff;
}

.details-table .numeric {
  text-align: center;
}

/* Hide less-critical columns on very narrow screens */
.col-order-no {
  white-space: nowrap;
}

@media (max-width: 480px) {
  .col-order-no {
    display: none;
  }
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

.pagination-info {
  font-size: 0.9rem;
  color: #666;
}

.pagination-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.page-btn {
  padding: 6px 10px;
  border: 1px solid #d0d0d0;
  background: #fff;
  color: #333;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  min-width: 32px;
}

.page-btn:hover:not(:disabled) {
  background: #f0f2f5;
  border-color: #1677ff;
  color: #1677ff;
}

.page-btn.active {
  background: #1677ff;
  color: #fff;
  border-color: #1677ff;
}

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

.page-ellipsis {
  padding: 6px 4px;
  color: #999;
  font-size: 0.9rem;
}

.page-size {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  color: #666;
}

.page-size select {
  padding: 4px 8px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 0.9rem;
  background: #fff;
}

@media (max-width: 640px) {
  .pagination {
    flex-direction: column;
    align-items: flex-start;
  }

  .pagination-controls {
    flex-wrap: wrap;
  }
}

#chart {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  margin-top: 16px;
}

#chart canvas {
  display: block;
}

/* ========== Login Page (Sketch 002 Variant A) ========== */
#login-view {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #f5f6f7;
}

.login-brand {
  text-align: center;
  margin-bottom: 48px;
}

.login-brand h1 {
  font-size: 2rem;
  font-weight: 600;
  color: #333;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 1rem;
  color: #6b7280;
  margin: 0;
}

.login-form {
  width: 100%;
  max-width: 360px;
  display: block;
}

.login-field {
  width: 100%;
  margin-bottom: 32px;
}

.login-field label {
  display: block;
  font-size: 1rem;
  font-weight: 500;
  color: #333;
  margin-bottom: 12px;
}

.login-field input {
  width: 100%;
  padding: 12px 16px;
  font-size: 1.0625rem;
  font-family: inherit;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  background: #fff;
  color: #333;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-field input:focus {
  border-color: #1677ff;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1);
}

.login-field input.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

#login-btn {
  width: 100%;
  padding: 13px 20px;
  font-size: 1.0625rem;
  font-weight: 500;
  border: none;
  border-radius: 12px;
  background: #1677ff;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

#login-btn:hover {
  background: #0958d9;
}

#login-btn:active {
  transform: scale(0.98);
}

#login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-error {
  font-size: 0.875rem;
  color: #ef4444;
  margin-top: 12px;
  min-height: 20px;
  transition: opacity 0.2s ease;
}

.login-error:empty {
  opacity: 0;
}

.login-hint {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 24px;
  text-align: center;
}

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

.chart-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  color: #222;
}

.chart-subtitle {
  font-size: 0.875rem;
  color: #888;
  margin: 4px 0 0;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #666;
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.legend-item:hover {
  background: #f3f4f6;
}

.legend-item.inactive {
  opacity: 0.35;
}

.legend-line {
  display: inline-block;
  width: 20px;
  height: 0;
  flex-shrink: 0;
}

.chart-canvas-wrap {
  position: relative;
  height: 380px;
}
