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

:root {
  --navy: #1a2a3a;
  --navy-light: #2a3f55;
  --text: #222;
  --text-light: #667;
  --bg: #f4f4f4;
  --card: #fff;
  --border: #e0e0e0;
  --accent: #2a6b9c;
  --accent-hover: #1f5580;
  --danger: #b33;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  -webkit-user-select: none;
}

.topbar-brand {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.topbar-nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.topbar-nav a {
  color: #b0c4d8;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  white-space: nowrap;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.topbar-nav a:hover,
.topbar-nav a.active {
  background: var(--navy-light);
  color: #fff;
  text-decoration: none;
}

.topbar-nav a.active {
  font-weight: 600;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1rem;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  opacity: 0.9;
}

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

.btn-outline:hover {
  background: #f0f0f0;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  min-height: 36px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th,
table td {
  text-align: left;
  padding: 0.7rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

table th {
  font-weight: 600;
  color: var(--text-light);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table tr:last-child td {
  border-bottom: none;
}

table tr:hover td {
  background: #fafafa;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.3rem;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(42,107,156,0.15);
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

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

.empty-state p {
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  margin-top: 2rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

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

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  padding: 0.25rem;
  line-height: 1;
}

.modal-body {
  padding: 1.25rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-success {
  background: #dff0d8;
  color: #3c763d;
}

.alert-danger {
  background: #f2dede;
  color: #a94442;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 1.3rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 0.25rem;
}

.login-card p {
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-card .form-group {
  margin-bottom: 1.25rem;
}

.login-card .btn {
  width: 100%;
  font-size: 1rem;
  padding: 0.7rem;
}

.grid-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.dash-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 1.25rem;
  text-align: center;
}

.dash-card h3 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.25rem;
}

.dash-card p {
  color: var(--text-light);
  font-size: 0.85rem;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.action-grid a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  color: var(--text);
  font-weight: 500;
  font-size: 0.9rem;
  min-height: 60px;
  transition: box-shadow 0.15s;
}

.action-grid a:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  text-decoration: none;
}

.section-divider {
  border-top: 1px solid var(--border);
  margin: 1rem 0;
  padding-top: 0.5rem;
}

.section-divider h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.appliance-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.65rem;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  gap: 0.5rem;
}

.appliance-item .info {
  flex: 1;
  min-width: 0;
}

.appliance-item .manufacturer {
  font-weight: 600;
}

.appliance-item .model {
  color: var(--text-light);
}

.appliance-item.selected {
  border-color: #2a6b9c;
  background: #d4e6f5;
}

.appliance-item {
  cursor: pointer;
}

.view-section {
  margin-bottom: 0.75rem;
}

.view-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 0.15rem;
}

.view-value {
  font-size: 0.95rem;
}

.cond-fields {
  display: none;
}

.cond-fields.visible {
  display: block;
}

.select-add-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.select-add-row select {
  flex: 1;
}

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 0.5rem 0.75rem; gap: 0.25rem; }
  .topbar-nav { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .grid-cards { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: 1fr; }
}
