:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --radius: 0.5rem;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 100vh;
}

.header {
  margin-bottom: 1.5rem;
}

.header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.button-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

button {
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
}

.table-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  padding: 1rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.compare-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  align-items: center;
}

.btn-clear {
  padding: 0.25rem 0.5rem;
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: none;
}

.btn-clear:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  transform: none;
}

.compare-row:hover {
  box-shadow: var(--shadow-lg);
}

input[type="number"] {
  width: 100%;
  padding: 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  text-align: right;
  transition: all 0.2s;
  background: var(--bg);
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

input[type="number"]:read-only {
  background: var(--bg);
  color: var(--primary);
  font-weight: 600;
  cursor: default;
}

dialog {
  max-width: 90%;
  max-height: 80vh;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.history-entry {
  border: 1px solid var(--border);
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card-bg);
}

.history-entry:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateX(4px);
}

.history-date {
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.history-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text-light);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--success);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(1rem);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  font-weight: 500;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 640px) {
  .container {
    padding: 1rem;
  }
  
  .table-header,
  .compare-row,
  .history-row {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.75rem;
  }
  
  .compare-row {
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 0.25rem;
    padding: 0.5rem;
  }
  
  input[type="number"] {
    padding: 0.5rem;
    font-size: 0.875rem;
  }
  
  .button-group {
    gap: 0.5rem;
  }
  
  button {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
  }
  
  .btn-clear {
    padding: 0.25rem 0.375rem;
    font-size: 1rem;
  }
  
  dialog {
    max-width: 100%;
    width: 100%;
    max-height: 100vh;
    height: 100vh;
    margin: 0;
    border-radius: 0;
  }
  
  .modal-header {
    padding: 1rem;
  }
  
  .modal-body {
    max-height: calc(100vh - 80px);
  }
}
