* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  background: #fff;
  color: #37352f;
  line-height: 1.5;
}

/* Login form */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.login-form {
  width: 100%;
  max-width: 320px;
}

.login-form h1 {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.login-form label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  color: #37352f;
}

.login-form input[type="password"] {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid #e9e9e7;
  border-radius: 3px;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.login-form input[type="password"]:focus {
  outline: none;
  border-color: #2eaadc;
  box-shadow: 0 0 0 2px rgba(46, 170, 220, 0.2);
}

.login-form .btn-primary {
  width: 100%;
}

.login-error {
  color: #e03e3e;
  font-size: 0.875rem;
  margin: 0 0 1rem;
}

/* Main header with tabs and logout */
.main-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e9e9e7;
}

.main-tabs {
  display: flex;
  gap: 0;
  flex: 1;
}

.main-tabs button {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  cursor: pointer;
  color: #9b9a97;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}

.main-tabs button:hover {
  background: #f7f6f3;
  border-radius: 4px 4px 0 0;
}

.main-tabs button.active {
  color: #37352f;
  border-bottom-color: #37352f;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.75rem;
  background: #f7f6f3;
  border-radius: 4px;
}

.category {
  margin-bottom: 0.25rem;
  cursor: default;
}

.category.dragging {
  opacity: 0.4;
}

.category.drag-over {
  border-top: 2px solid #2eaadc;
  margin-top: -2px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0;
  position: relative;
}

.category-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  color: #37352f;
}

.category-header input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: #2eaadc;
}

.category-header .category-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.category-header:hover .category-actions {
  opacity: 1;
}

.preference {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.25rem 0 0.25rem 1.5rem;
  border-radius: 3px;
  transition: background 0.1s;
  position: relative;
}

.preference:hover {
  background: #f7f6f3;
}

.preference.dragging {
  opacity: 0.4;
  background: #e3f2fd;
}

.preference.drag-over {
  box-shadow: inset 0 2px 0 #2eaadc;
}

.preference input[type="checkbox"] {
  margin-top: 0.25rem;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  accent-color: #2eaadc;
}

.preference-actions {
  display: flex;
  gap: 0.125rem;
  opacity: 0;
  transition: opacity 0.15s;
  margin-left: auto;
  flex-shrink: 0;
}

.preference:hover .preference-actions {
  opacity: 1;
}

.icon-btn {
  background: none;
  border: none;
  padding: 0.25rem 0.375rem;
  cursor: pointer;
  color: #9b9a97;
  border-radius: 3px;
  font-size: 1rem;
  transition: all 0.1s;
}

.icon-btn:hover {
  background: #e9e9e7;
  color: #37352f;
}

.add-category {
  padding: 0.5rem 0;
  margin-top: 1.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.add-category input[type="text"] {
  flex: 1;
  padding: 0.375rem 0.5rem;
  border: 1px solid #e9e9e7;
  border-radius: 3px;
  font-size: 0.875rem;
  background: transparent;
}

.add-category input[type="text"]:focus {
  outline: none;
  border-color: #2eaadc;
  box-shadow: 0 0 0 2px rgba(46,170,220,0.2);
}

.add-category button {
  background: transparent;
  color: #9b9a97;
  border: 1px dashed #e9e9e7;
  padding: 0.375rem 0.75rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.15s;
}

.add-category button:hover {
  background: #f7f6f3;
  color: #37352f;
  border-color: #d3d3d0;
}

.swapped-rules {
  background: #fbf3db;
  border-radius: 3px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.swapped-rules h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: #9b9a97;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.swapped-rules .preference {
  padding-left: 0.5rem;
}

.preference-text {
  flex: 1;
  font-size: 0.9375rem;
  color: #37352f;
  cursor: text;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  margin: -0.125rem -0.25rem;
}

.preference-text:hover {
  background: rgba(55, 53, 47, 0.04);
}

.preference-text:focus {
  outline: none;
  background: rgba(46, 170, 220, 0.1);
}

.btn-primary {
  background: #37352f;
  color: white;
  border: none;
  padding: 0.5rem 0.875rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: #2f2f2f;
}

.btn-secondary {
  background: transparent;
  color: #9b9a97;
  border: none;
  padding: 0.375rem 0.625rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: #e9e9e7;
  color: #37352f;
}

.add-rule {
  display: flex;
  gap: 0.5rem;
  padding: 0.25rem 0 0.25rem 1.5rem;
  align-items: center;
}

.add-rule input[type="text"] {
  flex: 1;
  padding: 0.25rem 0.5rem;
  border: none;
  border-radius: 3px;
  font-size: 0.9375rem;
  background: transparent;
  color: #9b9a97;
}

.add-rule input[type="text"]::placeholder {
  color: #c4c4c0;
}

.add-rule input[type="text"]:focus {
  outline: none;
  background: #f7f6f3;
  color: #37352f;
}

.add-rule button {
  background: transparent;
  color: #9b9a97;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.add-rule:hover button,
.add-rule input:focus ~ button {
  opacity: 1;
}

.add-rule button:hover {
  background: #e9e9e7;
  color: #37352f;
}

.save-status {
  font-size: 0.75rem;
  color: #9b9a97;
  margin-left: auto;
}

.save-status.saving {
  color: #d4a72c;
}

.save-status.saved {
  color: #4d9a5f;
}

.save-status.error {
  color: #e03e3e;
}

.line-count {
  font-size: 0.75rem;
  color: #9b9a97;
}

.line-count.warning {
  color: #d4a72c;
}

.line-count.danger {
  color: #e03e3e;
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #37352f;
  color: white;
  padding: 0.625rem 1rem;
  border-radius: 3px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  font-size: 0.875rem;
}

.toast.visible {
  opacity: 1;
  pointer-events: auto;
}

.toast button {
  background: transparent;
  color: #81b2d9;
  border: none;
  cursor: pointer;
  font-weight: 500;
  padding: 0;
}

.toast button:hover {
  text-decoration: underline;
}

.drag-handle {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  cursor: grab;
  color: #c4c4c0;
  font-size: 0.75rem;
  transition: opacity 0.15s;
  padding: 0.25rem;
}

.preference:hover .drag-handle {
  opacity: 1;
}

.drag-handle:hover {
  color: #9b9a97;
}
