*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  background: #f5f5f7;
  color: #111827;
}

.hidden {
  display: none !important;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid #e5e7eb;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-weight: 700;
  font-size: 18px;
  color: #16a34a;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  font-size: 13px;
  color: #4b5563;
}

.lang-btn {
  border: 1px solid #d1d5db;
  background: #f9fafb;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

/* main */
.main-content {
  flex: 1;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.center-screen {
  margin-top: 120px;
  text-align: center;
}

/* buttons */
.primary-btn,
.secondary-btn,
.icon-btn,
.link-btn {
  cursor: pointer;
  border: none;
  outline: none;
}

.primary-btn {
  background: #16a34a;
  color: #ffffff;
  font-weight: 600;
  border-radius: 999px;
  padding: 8px 20px;
  border: none;
}

.primary-btn:hover {
  background: #15803d;
}

.secondary-btn {
  background: #e5e7eb;
  color: #111827;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
}

.secondary-btn.small {
  padding: 4px 10px;
  font-size: 12px;
}

.icon-btn {
  background: transparent;
  font-size: 20px;
}

.link-btn {
  background: none;
  color: #2563eb;
  font-size: 12px;
  padding: 0;
}

/* tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  border: none;
  background: #e5e7eb;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}

.tab.active {
  background: #111827;
  color: #ffffff;
}

.tab-content {
  display: none;
}

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

/* layout */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #e5e7eb;
}

.card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-title {
  font-weight: 600;
  font-size: 14px;
}

.card-sub {
  font-size: 12px;
  color: #6b7280;
}

.card-actions {
  display: flex;
  gap: 6px;
}

/* text */
.muted {
  color: #6b7280;
  font-size: 13px;
}

.muted.small {
  font-size: 12px;
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-content {
  position: relative;
  max-height: 90vh;
  width: 900px;
  background: #ffffff;
  border-radius: 18px;
  padding: 16px 20px 16px 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 4px 8px;
}

.modal-footer {
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
}

/* forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.form-group span {
  font-size: 13px;
  color: #374151;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select {
  border-radius: 10px;
  border: 1px solid #d1d5db;
  padding: 6px 10px;
  font-size: 13px;
  background: #ffffff;
}

.two-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* selectors */
.targets-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 8px;
}

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

.selector-list {
  max-height: 150px;
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 6px 8px;
}

.selector-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 8px;
  font-size: 12px;
}

.selector-item input {
  margin: 0;
}

.selector-item.active {
  background: #dcfce7;
}

/* conditions */
.conditions-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.condition-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 80px 120px 40px;
  gap: 6px;
  align-items: center;
}

.condition-row select,
.condition-row input {
  font-size: 12px;
}

.condition-row .logic-select.first {
  opacity: 0.5;
}

/* system test */
.system-test {
  margin-top: 20px;
  padding: 12px;
  border-radius: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}

.system-log {
  margin-top: 8px;
  max-height: 120px;
  overflow-y: auto;
  font-size: 11px;
  background: #111827;
  color: #e5e7eb;
  padding: 6px 8px;
  border-radius: 8px;
}

.app-footer {
  padding: 12px 24px;
  font-size: 12px;
  color: #6b7280;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: #ffffff;
}

.app-footer a {
  color: #2563eb;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}
