:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: #334155;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  max-width: 600px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

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

.tab {
  flex: 1;
  padding: 10px;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.tab.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.contact-list, .call-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contact-item, .call-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.contact-info, .call-info {
  flex: 1;
  min-width: 0;
}

.contact-name, .call-name {
  font-weight: 600;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-phone, .call-phone {
  color: var(--text-dim);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.call-time {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 4px;
}

.call-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.call-status.success {
  background: rgba(34, 197, 94, 0.2);
  color: var(--accent);
}

.call-status.error {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.actions {
  display: flex;
  gap: 8px;
}

button {
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.05s;
}

button:active {
  transform: scale(0.97);
}

button.primary {
  background: var(--accent);
  color: var(--bg);
}

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

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 8px 12px;
  font-size: 14px;
}

button.ghost {
  background: var(--surface-2);
  color: var(--text);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.call-btn {
  background: var(--accent);
  color: var(--bg);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.fab {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 30px;
  font-weight: 300;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 10;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal h2 {
  margin: 0;
  font-size: 18px;
}

.modal label {
  font-size: 14px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
}

.modal input, .modal select, .login input {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
}

.modal input:focus, .modal select:focus, .login input:focus {
  outline: none;
  border-color: var(--accent);
}

.phone-row {
  display: flex;
  gap: 8px;
}

.phone-row select {
  flex: 0 0 110px;
}

.phone-row input {
  flex: 1;
  min-width: 0;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.error-msg {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
}

.success-msg {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
}

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
}

.login {
  max-width: 320px;
  margin: 100px auto 0;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login h1 {
  margin: 0;
  text-align: center;
  font-size: 20px;
}

.login input {
  text-align: center;
  font-size: 24px;
  letter-spacing: 8px;
  font-variant-numeric: tabular-nums;
}

.login button {
  padding: 14px;
  font-size: 17px;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
