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

:root {
  --green: #2a7d3f;
  --green-dark: #1e6030;
  --green-light: #e8f5e9;
  --orange: #bf5600;
  --orange-light: #fff3e0;
  --text: #1a1a1a;
  --text-sec: #888;
  --border: rgba(0, 0, 0, 0.09);
  --bg: #f5f5f3;
  --white: #ffffff;
  --radius: 10px;
  --fab-height: 64px;
}

html,
body {
  height: 100%;
  width: 100%;
  position: fixed;
  overflow: hidden;
  font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* splash */
.splash-body {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  background: var(--bg);
}

.splash-body .logo {
  animation: pulse 1.5s ease-in-out infinite;
}

.splash-body .title {
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* login  */
.login-body {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 32px 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.login-logo {
  margin-bottom: 4px;
}

.login-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.login-sub {
  font-size: 16px;
  color: var(--text-sec);
  text-align: center;
  margin-bottom: 4px;
}

.login-hint {
  font-size: 14px;
  color: var(--text-sec);
  margin-top: 4px;
}

.login-hint a {
  color: var(--green);
  font-weight: 600;
  text-decoration: none;
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

/* header */
.app-header {
  background: var(--green);
  padding-top: env(safe-area-inset-top);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 8px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.header-user {
  margin-left: auto;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
}

.header-logout {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  display: flex;
}

/* tabs fab btn list-row  */
.tab,
.fab-btn,
.btn,
.list-row {
  user-select: none;
  -webkit-user-select: none;
}

/* tabs  */
.tabs {
  display: flex;
  background: var(--green-dark);
}

.tab {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.tab.active {
  color: #fff;
  border-bottom-color: #fff;
}

.tab-content {
  display: none;
  flex-direction: column;
  height: calc(100vh - env(safe-area-inset-top) - 88px);
  overflow: hidden;
}

.tab-content.active {
  display: flex;
  flex: 1;
}

/* search */
.search-wrap {
  display: flex;
  position: relative;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border-bottom: 0.5px solid var(--border);
  padding: 10px 14px;
  flex-shrink: 0;
}

.search-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text);
  background: transparent;
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: #eee;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #666;
  cursor: pointer;
}

/* list */
.list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--fab-height);
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--white);
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  gap: 12px;
}

.list-row:active {
  background: var(--bg);
}

.list-row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row-sub {
  font-size: 12px;
  color: var(--text-sec);
  margin-top: 2px;
  white-space: nowrap;
}

.list-row-right {
  flex-shrink: 0;
  text-align: right;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.badge-green {
  background: var(--green-light);
  color: var(--green-dark);
}

.badge-orange {
  background: var(--orange-light);
  color: var(--orange);
}

.list-empty {
  padding: 40px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-sec);
}

.list-loading {
  padding: 20px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-sec);
}

/* fab */
.fab-row {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--white);
  border-top: 0.5px solid var(--border);
  z-index: 10;
}

.fab-btn {
  flex: 1;
  padding: 11px;
  border-radius: 8px;
  border: 0.5px solid var(--green);
  background: var(--white);
  color: var(--green);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

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

/* popup */
.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.popup-overlay.active {
  display: block;
  visibility: visible;
  opacity: 1;
}

.popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.popup-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: 16px 16px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom));

  transform: translateY(100%);
  transition: transform 0.3s ease-out;
}

.popup-overlay.active .popup-sheet {
  transform: translateY(0);
}

.popup-handle {
  width: 36px;
  height: 4px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.title-row .popup-title {
  margin-bottom: 0;
}

.ud-role {
  font-size: 13px;
  color: var(--text-sec);
  font-weight: 400;
}

.popup-sheet {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* form  */
.form-group {
  width: 100%;
  margin-bottom: 12px;
  position: relative;
}

.form-label {
  display: block;
  font-size: 11px;
  color: var(--text-sec);
  margin-bottom: 4px;
}

.form-input {
  width: 100%;
  background: var(--white);
  border: 0.5px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}

.form-input:focus {
  border-color: var(--green);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.form-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

/* suggestions */
.suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  z-index: 20;
  overflow: hidden;
}

.suggestion-item {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:active {
  background: var(--bg);
}

/* detail rows */
.detail-rows {
  margin-bottom: 16px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
  gap: 12px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 13px;
  color: var(--text-sec);
}

.detail-val {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

/* buttons */
.btn {
  width: 100%;
  padding: 11px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 4px;
}

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

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

.btn-cancel {
  background: var(--bg);
  color: var(--text);
  margin-top: 8px;
}

/* toast */
.toast {
  position: fixed;
  bottom: calc(var(--fab-height) + 12px + env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  text-align: center;
  background: #333;
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 20px;
  white-space: nowrap;
  z-index: 100;
  transition: opacity 0.3s;
}

.toast.fade {
  opacity: 0;
}

.hidden {
  display: none !important;
}