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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: #f9fafb;
  color: #333;
  line-height: 1.6;
}

h1,
h2,
h3 {
  font-weight: 600;
  color: #333;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 22px;
}

:root {
  --primary-color: #31c48d;
  --primary-hover: #2aa876;
  --blue-color: #76a9fa;
  --blue-hover: #3f83f8;
  --danger-color: #e74c3c;
  --danger-hover: #c0392b;
  --secondary-color: #95a5a6;
  --secondary-hover: #7f8c8d;
  --border-color: #e0e0e0;
  --bg-light: #fafafa;
  --bg-card: #ffffff;
  --text-primary: #333;
  --text-secondary: #555;
  --text-muted: #666;
  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* ============================================
   Form Elements
   ============================================ */

label {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"] {
  padding: 8px 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.3s ease;
  font-family: inherit;
  width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(49, 196, 141, 0.1);
}

/* ============================================
   Buttons
   ============================================ */

button {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

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

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

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

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

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

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

.btn-logout {
  background: var(--danger-color);
  color: white;
  padding: 10px 20px;
  font-size: 14px;
}

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

/* ============================================
   Cards & Containers
   ============================================ */

.card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

/* ============================================
   Login Page Specific
   ============================================ */

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

.login-container {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-container h1 {
  text-align: center;
  margin-bottom: 10px;
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 30px;
  font-size: 14px;
}

.login-container .form-group {
  margin-bottom: 20px;
}

.login-container label {
  display: block;
  margin-bottom: 8px;
}

.login-container button {
  width: 100%;
  margin-top: 10px;
  background-color: var(--primary-color);
}

.error-message {
  color: var(--danger-color);
  font-size: 14px;
  margin-top: 10px;
  text-align: center;
  min-height: 20px;
}

/* ============================================
   Main Page Specific
   ============================================ */

body.main-page {
  min-height: 100vh;
  padding: 20px;
}

.header {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px 30px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  margin: 0;
  background-color: #1e1e1e;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.form-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.main-page label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ============================================
   Stations
   ============================================ */

#stations {
  margin-top: 20px;
}

.station {
  padding: 10px;
}

.station-fieldset {
  border: none;
}

.station-fieldset legend {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 10px;
  color: var(--primary-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.station-id {
  font-weight: 600;
  color: var(--primary-color);
}

.station-row {
  display: flex;
  gap: 20px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.station-row label {
  flex: 1;
  min-width: 150px;
}

.station-group {
  border: 1px solid #e8e8e8;
  padding: 15px;
  margin-bottom: 15px;
  border-radius: 8px;
  background: #f8f9fa;
}

.station-group legend {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 8px;
}

.station-group label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  width: auto;
  min-width: 180px;
  margin-right: 15px;
  margin-bottom: 10px;
}

.station-group label input {
  margin-left: 8px;
  width: 120px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  gap: 15px;
  flex-wrap: wrap;
}

.field-row > label:first-child {
  flex: 1;
  min-width: 200px;
  margin: 0;
}

.field-row .expiration-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
}

.field-row .expiration-label input {
  padding: 8px 12px;
  font-size: 12px;
  width: auto;
  min-width: 180px;
  margin: 0;
}

.station .remove {
  background: var(--danger-color);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  margin-left: auto;
}

.station .remove:hover {
  background: var(--danger-hover);
}

.add-station-btn {
  background: var(--primary-color);
  color: white;
  margin-top: 10px;
}

.add-station-btn:hover {
  box-shadow: 0 4px 12px rgba(49, 196, 141, 0.4);
}

/* ============================================
   Log Display
   ============================================ */

#log {
  height: 400px;
  overflow-y: auto;
  border: 2px solid var(--border-color);
  padding: 20px;
  background: #1e1e1e;
  margin-top: 20px;
  border-radius: 10px;
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #d4d4d4;
}

#log::-webkit-scrollbar {
  width: 8px;
}

#log::-webkit-scrollbar-track {
  background: #2d2d2d;
  border-radius: 4px;
}

#log::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}

#log::-webkit-scrollbar-thumb:hover {
  background: #666;
}

#log p {
  margin: 5px 0;
  padding: 5px 0;
  border-bottom: 1px solid #333;
}

#log p:last-child {
  border-bottom: none;
}

@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .header {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }

  .form-group {
    grid-template-columns: 1fr;
  }

  .station-group label {
    width: 100%;
    margin-right: 0;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-buttons button {
    width: 100%;
  }

  .login-container {
    padding: 30px 20px;
  }
}
