:root {
  --primary: #16423C;
  --primary-light: #1E5C53;
  --gold: #C9962C;
  --bg: #F7F5F0;
  --card: #FFFFFF;
  --text: #232323;
  --muted: #8A8578;
  --border: #E7E3D8;
  --danger: #A6432E;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-header {
  background: var(--primary);
  color: white;
  padding: 16px 20px 14px;
  flex-shrink: 0;
}

.login-bar {
  background: rgba(0, 0, 0, 0.15);
  color: rgba(255, 255, 255, 0.85);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  flex-shrink: 0;
}

.login-bar #loginStatus {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.login-bar #loginStatus::before {
  content: "●";
  font-size: 8px;
  color: var(--gold);
}

.login-bar button {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: white;
  color: var(--primary);
  letter-spacing: 0.01em;
}

.login-bar button:hover {
  opacity: 0.92;
}

.login-bar button.danger {
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.manager-only {
  display: none !important;
}

body.is-manager .manager-only {
  display: inherit !important;
}

body.is-manager li.manager-only {
  display: flex !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px 22px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.modal-card h3 {
  margin: 0 0 16px;
  color: var(--primary);
  font-size: 18px;
}

.modal-card input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  margin-bottom: 10px;
  background: var(--bg);
  color: var(--text);
}

.modal-card input:focus {
  outline: 2px solid var(--primary-light);
  outline-offset: 1px;
}

.modal-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 10px;
  min-height: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-actions button {
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
}

.modal-actions button.primary {
  background: var(--primary);
  color: white;
}

.modal-actions #loginCancelBtn {
  background: var(--bg);
  color: var(--text);
}

.app-name {
  display: block;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

.app-tab-title {
  display: block;
  font-size: 22px;
  font-weight: 700;
  margin-top: 2px;
}

.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 90px;
  -webkit-overflow-scrolling: touch;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.18s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 22px 0 10px;
  font-weight: 700;
}

.add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  align-items: stretch;
}

.add-row select {
  min-width: 0;
}

.add-row button {
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

input[type="text"], select {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: var(--card);
  color: var(--text);
}

input[type="text"]:focus, select:focus {
  outline: 2px solid var(--primary-light);
  outline-offset: 1px;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

#addBtn, #chatBtn {
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 600;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
}

.list li.empty {
  color: var(--muted);
  font-style: italic;
  justify-content: flex-start;
  background: transparent;
  border-style: dashed;
}

.list li button.small {
  padding: 5px 10px;
  border-radius: 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  margin-left: 6px;
}

.list li button.danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.history-list li {
  display: block;
  line-height: 1.6;
}

.pot-wrap {
  display: flex;
  justify-content: center;
  margin: 10px 0 24px;
}

.pot-badge {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.pot-badge.spin {
  animation: spin 1.8s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(1440deg); }
}

.primary-btn {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 16px;
  font-weight: 700;
}

.winner-line {
  text-align: center;
  font-weight: 700;
  font-size: 17px;
  margin: 16px 0 4px;
  color: var(--primary);
}

.deadline-line {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.assistant-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 20px;
}

.chat-response {
  margin: 0 0 12px;
  font-size: 15px;
  min-height: 20px;
}

.danger-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  font-weight: 600;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.nav-btn {
  flex: 1;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  color: var(--muted);
  font-size: 11px;
  border-radius: 10px;
}

.nav-icon {
  font-size: 20px;
}

.nav-btn.active {
  color: var(--primary);
  background: rgba(22, 66, 60, 0.08);
}

@media (max-width: 380px) {
  .app-header { padding: 14px 16px 12px; }
  .app-tab-title { font-size: 19px; }
}