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

:root {
  --blue:       #007AFF;
  --blue-dark:  #0062CC;
  --green:      #34C759;
  --red:        #FF3B30;
  --orange:     #FF9500;
  --gray1:      #1C1C1E;
  --gray2:      #3A3A3C;
  --gray3:      #636366;
  --gray4:      #AEAEB2;
  --gray5:      #E5E5EA;
  --gray6:      #F2F2F7;
  --white:      #FFFFFF;
  --bg:         #F2F2F7;
  --card:       #FFFFFF;
  --border:     rgba(60,60,67,0.12);
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow:     0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 30px rgba(0,0,0,0.12);
}

body {
  font-family: -apple-system, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--gray1);
  min-height: 100vh;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* ── Landing ─────────────────────────────────── */
.landing-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 48px 24px;
  background: var(--bg);
}

.landing-header {
  text-align: center;
  margin-bottom: 52px;
}
.landing-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--gray1);
  margin-bottom: 6px;
}
.landing-header p {
  font-size: 15px;
  color: var(--gray3);
  font-weight: 400;
}

.role-cards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.role-card {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  min-width: 160px;
  border: 1px solid var(--border);
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s ease;
}
.role-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
}
.role-card:active { transform: scale(0.97); }

.role-icon {
  width: 60px; height: 60px;
  border-radius: 16px;
  background: rgba(0,122,255,0.1);
  color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  margin: 0 auto 16px;
  letter-spacing: 0.3px;
}
.admin-card .role-icon {
  background: rgba(255,149,0,0.1);
  color: var(--orange);
}
.role-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--gray1);
}
.role-card p {
  color: var(--gray3);
  font-size: 13px;
}

/* ── Navigation bar ──────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: rgba(242,242,247,0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.page-header h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  flex: 1;
}
.btn-back {
  background: none; border: none;
  color: var(--blue); cursor: pointer;
  font-size: 15px; font-weight: 400;
  padding: 4px 8px 4px 0;
  display: flex; align-items: center; gap: 3px;
}
.btn-back::before { content: "‹"; font-size: 22px; line-height: 1; margin-top: -1px; }

/* ── Form layout ─────────────────────────────── */
.form-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px;
}

.form-section {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 0.5px solid var(--border);
  overflow: hidden;
}
.form-section > h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 14px 16px 0;
  margin-bottom: 4px;
}
.form-group {
  padding: 11px 16px;
  border-bottom: 0.5px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.form-group:last-child { border-bottom: none; }
.form-group label {
  font-size: 12px;
  color: var(--gray3);
  font-weight: 500;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: 8px 0;
  border: none;
  background: transparent;
  font-size: 15px;
  color: var(--gray1);
  outline: none;
  font-family: inherit;
}
select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23AEAEB2' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  padding-right: 20px;
}
input::placeholder, select option[value=""] { color: var(--gray4); }

/* ── Search row ──────────────────────────────── */
.search-row {
  padding: 12px 16px;
  display: flex; gap: 10px; align-items: flex-start;
}
.search-input-wrap {
  flex: 1; position: relative;
}
.search-input-wrap input {
  background: var(--gray6);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 15px;
  color: var(--gray1);
}
.search-row select {
  width: 100px; flex-shrink: 0;
  background: var(--gray6);
  border-radius: var(--radius-sm);
  padding: 8px 28px 8px 10px;
  font-size: 14px;
}

.dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 0.5px solid var(--border);
  z-index: 100;
  max-height: 240px; overflow-y: auto;
  overflow: hidden;
}
.dropdown-item {
  padding: 11px 14px;
  cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 0.5px solid var(--border);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: rgba(0,122,255,0.05); }
.dropdown-item:active { background: rgba(0,122,255,0.1); }
.co-name { font-size: 15px; font-weight: 500; }
.co-date { font-size: 12px; color: var(--gray3); }

.auth-date-notice {
  margin: 0 16px 12px;
  padding: 10px 14px;
  background: rgba(255,149,0,0.08);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--orange);
  font-size: 13px; color: #6B4400;
}

/* ── Batch items ─────────────────────────────── */
.batch-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--border);
}
.batch-item:last-child { border-bottom: none; }
.batch-item-main { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.batch-item-main strong { font-size: 15px; font-weight: 500; }
.batch-item-date { font-size: 12px; color: var(--gray3); }
.purpose-tag {
  display: inline-block;
  background: rgba(0,122,255,0.1);
  color: var(--blue);
  font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 6px;
  align-self: flex-start;
}
.btn-icon {
  background: none; border: none;
  color: var(--gray4); cursor: pointer;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: background 0.15s;
}
.btn-icon:hover { background: rgba(255,59,48,0.1); color: var(--red); }

.empty-hint {
  color: var(--gray4);
  font-size: 14px;
  text-align: center;
  padding: 24px 16px;
}

.form-actions { margin-top: 4px; padding: 0; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  font-size: 15px; font-weight: 500;
  font-family: inherit;
  background: var(--gray6); color: var(--blue);
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-dark); opacity: 1; }
.btn-success { background: var(--green); color: white; }
.btn-danger { background: none; color: var(--red); }
.btn-danger:hover { background: rgba(255,59,48,0.08); opacity: 1; }
.btn-ghost { background: none; color: var(--gray3); }
.btn-ghost:hover { background: var(--gray6); opacity: 1; }
.btn-large { width: 100%; padding: 14px; font-size: 17px; border-radius: var(--radius); }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ── Operator view ───────────────────────────── */
.op-subheader {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 0.5px solid var(--border);
  font-size: 15px; font-weight: 500;
}
.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--blue); color: white;
  font-size: 12px; font-weight: 600;
  min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: 10px; margin-left: 6px;
}

.pending-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 0.5px solid var(--border);
}
.pending-item-main { flex: 1; }
.pending-item-main strong { font-size: 16px; font-weight: 500; }
.pending-item-meta { font-size: 12px; color: var(--gray3); margin-top: 4px; line-height: 1.5; }

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--gray4);
  font-size: 15px;
}

/* ── Admin ───────────────────────────────────── */
.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: rgba(242,242,247,0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.admin-header h2 {
  font-size: 17px; font-weight: 600; letter-spacing: -0.2px;
}

.tab-nav {
  display: flex;
  background: var(--card);
  border-bottom: 0.5px solid var(--border);
  padding: 0 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  background: none; border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 14px;
  font-size: 14px; font-weight: 500;
  color: var(--gray3);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-btn:hover:not(.active) { color: var(--gray1); }

.tab-content { padding: 16px; }
.tab-toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }

/* ── Tables ──────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 0.5px solid var(--border);
  background: var(--card);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  background: var(--gray6);
  font-weight: 500;
  font-size: 12px;
  color: var(--gray3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 0.5px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 0.5px solid var(--border);
  vertical-align: middle;
  color: var(--gray1);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,122,255,0.02); }

.status-done {
  display: inline-block; padding: 2px 8px;
  border-radius: 6px; font-size: 12px; font-weight: 600;
  background: rgba(52,199,89,0.1); color: #1A7A33;
}
.status-pending {
  display: inline-block; padding: 2px 8px;
  border-radius: 6px; font-size: 12px; font-weight: 600;
  background: rgba(255,149,0,0.1); color: #995A00;
}

/* ── Login ───────────────────────────────────── */
.login-wrap {
  max-width: 360px; margin: 60px auto;
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  border: 0.5px solid var(--border);
}
.login-wrap .form-group {
  border-bottom: 0.5px solid var(--border);
  padding: 12px 0;
}
.login-wrap .form-group:last-of-type { border-bottom: none; }
.login-wrap .form-group label { font-size: 12px; color: var(--gray3); margin-bottom: 2px; }
.login-wrap input {
  background: transparent;
  font-size: 16px;
  padding: 4px 0;
}
.error-msg { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 10px; }

/* ── Operator management ─────────────────────── */
.add-row {
  display: flex; gap: 10px; margin-bottom: 20px; max-width: 400px;
}
.add-row input {
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 15px;
  box-shadow: var(--shadow-sm);
}
.operator-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  border: 0.5px solid var(--border);
  max-width: 400px;
  font-size: 15px; font-weight: 500;
}

/* ── Account tab inputs ──────────────────────── */
.tab-content .form-section .form-group input {
  background: transparent;
  border: none;
  padding: 8px 0;
  font-size: 15px;
}

/* ── Success screen ──────────────────────────── */
.success-wrap {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh; text-align: center; padding: 40px 24px;
}
.success-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(52,199,89,0.12);
  color: var(--green);
  font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
  border: 2px solid rgba(52,199,89,0.3);
}
.success-wrap h2 {
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.3px; margin-bottom: 8px;
}
.success-wrap p { color: var(--gray3); font-size: 15px; }

/* ── Modal ───────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200;
  padding: 0;
}
.modal-content {
  background: var(--card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 20px 36px;
  width: 100%; max-width: 600px;
  animation: slide-up 0.3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes slide-up {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-content h3 {
  font-size: 17px; font-weight: 600;
  letter-spacing: -0.2px; margin-bottom: 20px;
  text-align: center;
}
.modal-content .form-group {
  border-bottom: 0.5px solid var(--border);
  padding: 10px 0; margin: 0;
}
.modal-content .form-group:last-of-type { border-bottom: none; }
.modal-content .form-group label { font-size: 12px; color: var(--gray3); }
.modal-content input {
  background: transparent; border: none;
  font-size: 15px; padding: 5px 0;
}
.modal-actions {
  display: flex; gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn { flex: 1; padding: 13px; border-radius: var(--radius); font-size: 15px; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 480px) {
  .role-cards { flex-direction: column; align-items: stretch; max-width: 300px; }
  .search-row { flex-wrap: wrap; }
  .search-row select { width: 100%; }
  .landing-header h1 { font-size: 1.6rem; }
}

@media (min-width: 768px) {
  .modal {
    align-items: center;
    padding: 20px;
  }
  .modal-content {
    border-radius: var(--radius-xl);
    animation: fade-scale 0.2s ease;
  }
  @keyframes fade-scale {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
  }
}
